Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For example, we'd like to see:

PROCESS       IF       TX       RX       FILE(regular) R/W
prog1         eth0     200kB/s  12kB/s   --            --
              wlan0    12kB/s   100kB/s  --            --
              --       --       --       file1         R
              --       --       --       file2         R
              --       --       --       file3         W
prog2         eth0     0kB/s    200kB/s  --            --
              --       --       --       file4         W
              --       --       --       file5         W

Is this possible? nethogs only shows the TX/RX, while lsof only shows the file accesses.

I'm currently doing a 2-step process like so:

sudo nethogs
sudo lsof -a -d 1-999 -c hogging_program /

Is there a better way?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

I believe what you're trying to accomplish is probably best (and AFAIK only) possible combining multiple commands as you're currently doing. With some clever shell scripting and piped data, you could get the output you're looking for.

You seem to be up against some tenants of 'The UNIX Philosophy:'

  • Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features.
  • Expect the output of every program to become the input to another, as yet unknown, program. Don't clutter output with extraneous information.

This is particularly evident in programs that output text, like lsof. Doug McIlroy summarized his earlier statement years later:

Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

While it may not help you get the formatted output you're looking for, The Art of UNIX Programming is a good read, and where I found sources for those quotes.

share|improve this answer

atop goes some way to giving you what you want, although it wouldn't be as specific as breaking down I/O by filehandle. To get full networking statistics you have to apply a kernel patch.

share|improve this answer

Try iftop for network and pidstat from sysstat.

Both are probably an easy install (apt-get, etc) for the distribution of your choice.

share|improve this answer

iptraf can be very usefull and finding bandwidth hogs.

share|improve this answer
4  
Adding more info/explanation will make your answer better. –  mtk Mar 18 '13 at 13:07

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.