Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running gkrellm which shows that some process on my Debian Linux system is writing approx 500KB/s to eth0. I'd like to find out which process it is. I know a little bit about netstat, but it shows a gazillion open TCP connections and I can't seem to make it produce any information about traffic.

Does anybody know how I can get a list of processes that are actually using the eth0 interface so that I can track down the offender?


FOLLOWUP: The Debian Linux distribution contains a nethogs package which solves this problem definitively. Related tools that are not quite on the mark include iftop, netstat, and lsof.

share|improve this question
add comment

5 Answers 5

up vote 9 down vote accepted

I prefer nethogs. It's a small ncurses-based console program that displays per-process network traffic status in a convenient way.

share|improve this answer
add comment

Use tcpdump to sniff some packets on this interface:

# tcpdump -vv -s0 -i eth0 -c 100 -w /tmp/eth0.pcap

Copy to client and open with Wireshark to see what happens.

share|improve this answer
    
Not the easiest way to get simple stats but anything even slightly more complicated and wireshark will shine! –  Silverfire Oct 19 '11 at 5:57
add comment

Install iftop (simple text-based) or ntop (graphical).

share|improve this answer
    
iftop only display bandwidth usage on an interface. –  quanta Sep 29 '11 at 2:41
    
It shows much more than that. By default, it breaks it down by host. –  David Schwartz Sep 29 '11 at 2:42
    
Can it list all processes that are using an interface? If so, could you please show us the command and options? –  quanta Sep 29 '11 at 2:48
1  
Not directly. But once you find the host, you can find the process, for example with netstat -pn. –  David Schwartz Sep 29 '11 at 2:49
add comment

A more manual operation if you are looking for just a process sending/receiving data would be to run the lsof command. This will list all open files for each process which will include network connections as they are file descriptors to the o.s.

Not sure if this is what you are looking for.

share|improve this answer
add comment

netstat -ptu will give you the owning process ids (along with standard netstat info) for all tcp and udp conections. (Normal users will not be able to id all processes.)

If something is sending out a fair amount of constant traffic you should see it on Recv-Q or Send-Q columns 2 and 3 respectively.

Examples:
Recv-Q
sudo watch -n .1 'netstat -tup | grep -E "^[t,u]cp[6]{0,1}" | sort -nr -k2'

Send-Q
sudo watch -n .1 'netstat -tup | grep -E "^[t,u]cp[6]{0,1}" | sort -nr -k3'

If you suspect that that process is being triggered by another process ps axf.

share|improve this answer
    
(Not that the -u flag in necessary if you know that you are looking for TCP connections.) –  andol Sep 29 '11 at 6:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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