I'd like to know which processes use the network:

  1. To inspect if any unknown to me (and potentially malicious) programs on my system use the network;
  2. To learn the amount of network traffic by the process, and further broken down by protocol HTTP, TCP, UDP, ICMP,..) and also by incoming/outgoing traffic.
  • 3
    did you post this to the right site? im not sure u&l is the proper form for discussions on time travel. it is interesting though. – mikeserv Nov 26 '15 at 7:56
  • in my opinion, that is a question for a security and networking group, though I normally use open source for that purposes. The question is too broad and too vague. I do not feel like writing a treaty in Unix, security and networking. What do you exactly want to do? Is it at home or work? Are you part of the network team? Can you enlist their help? Can you modify the configuration of border gateway routers? The answer can vary a lot depending if you are doing it at home or work, and of your level of experience. I may give it a go. – Rui F Ribeiro Nov 26 '15 at 8:09
  • I don't think that's possible for the past. Although /proc/<PID>/ contains various counters for read and written bytes there is no distinction between storage and network. The same applies to live-monitoring the application via /proc/. The only solution that comes to my mind involves using pcap. Which means you have to monitor the application all the time in order to do proper accounting. – scai Nov 26 '15 at 8:14

Just like top is for CPU usage, iftop is for network usage.

  • iftop is only as good as too debug temporarily things, I am afraid. – Rui F Ribeiro Nov 26 '15 at 8:10
  • You can periodically store the output of iftop and process it later using awk – user135284 Nov 26 '15 at 8:18
  • You can, however iftop is just sampling what you are doing, is not viable to run in the long term for a variety of reasons. – Rui F Ribeiro Nov 26 '15 at 8:19
  • True. If you are not able to find a tool that meets your requirements, then you are better of starting a github project on it :) – user135284 Nov 26 '15 at 8:25
  • I was already network and system administrator at two cable ISP providers...there are tools and protocols out there, it just gives you work piecing it all together. – Rui F Ribeiro Nov 26 '15 at 8:26

What you are asking is a bit broad, so I will try to stick to the general terms. To rephrase it, you would like to have an idea over time of your network usage broken down by process AND by protocol.

For domestic use, try ntop. It will do more than you probably need, and to top if off, it shows historical graphics.


There are tools that fit that job temporarily. For a general glance of what is happening, nethogs breaks down the applicational usage of network quite nicely.


"NetHogs is a small 'net top' tool. Instead of breaking the traffic down per protocol or per subnet, like most tools do, it groups bandwidth by process. "

You also have dtrace4linux and sysdig, which can do very surprising things for accounting almost all aspects of server usage. There is a very interesting book about dtrace "Systems Performance: Enterprise and the Cloud" from Brendan Gregg.

For global accounting of traffic usage, you can either sample ifconfig, or the rx/tx transferred bytes in proc. If managing multiple servers, better use an NMS and SNMP.

If managing a network of servers, you would want to do iptables accounting in the router, or setup Netflow in your firewall or router, and listen and store the data in a DB. nfSen is particularly useful to visualize that kind of that.

As for security related attacks, IDS is a very interesting technology. You can run Snort in your box, however it is generally ran in a box that can listen to the traffic flowing.

  • Running late for work, will come back to add more. – Rui F Ribeiro Nov 26 '15 at 8:33

You can use netstat -p to get the list of processes with active connections

  • The key point is over time. netstat is cool for debbuging, not for accounting. – Rui F Ribeiro Nov 26 '15 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.