Re: bandwidth measurement by process
On Sun, May 9, 2010 at 11:38, Celejar <email@example.com>
I'm looking for a tool that will measure bandwidth used by a specific
process. I'd like some sort of utility or wrapper that will answer
questions like "How much data did my network backup job push over the
There are many tools that measure by interface / TCP port, etc, but the
only thing I've been able to find that isolates traffic on a per
process basis is nethogs. I assume that this is tricky, because TCP /
IP traffic doesn't really have the concept of associated processes, and
one needs some method of correlating traffic with processes (nethogs
apparently does this by analyzing various files under /proc).
Are there any other tools out there? Nethogs is a TUI (ncurses) app
that prints a realtime tally of traffic for every process on the system,
and I'd really like a simple CLI utility that will focus on one specific
process and let me know how much traffic it's generating. I've searched
quite a bit, but found nothing besides nethogs.
foffl.sourceforge.net - Feeds OFFLine, an offline RSS/Atom aggregator
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact firstname.lastname@example.org
Archive: email@example.com" target="_blank">http://firstname.lastname@example.org
nethogs is unique in that manner, as per their website itself.
see section "Links" in their website
Most of the other tools give rate per tcp/udp sessions based on port numbers and remote address information.
So you may not find any other program to take care of this. I think it is doable with a few hundred lines of code.
This is what is required to be done.
* /proc/<pid>/fd look for the socket inode numbers
* correlate those inode numbers in /proc/net/tcp and /proc/net/udp to find the
source and destination ip and port details
* use libpcap to open the interface and capture the packet, from this you could get the packet length, rate etc of each tcp, udp session
Combining the above, it is possible to get what you need.