Total network data sent/received of a non-daemon Linux process?

Posted by leden on Server Fault See other posts from Server Fault or by leden
Published on 2013-11-08T20:13:56Z Indexed on 2013/11/08 21:58 UTC
Read the original article Hit count: 145

I'm looking for a simple and effective way of measuring total bytes received/sent from a single process upon its termination.

Basically, I am looking for a tool which has the interface similar to "time" and "/usr/bin/time", e.g.

measure-net-data <prog_to_run> <prog_args>
Received (b): XYZ
Sent (b): ABC

I know that there are many tools for bandwidth/network monitoring, but as far I can tell all of them are performing the measurements it real-time, which is inappropriate not only because of overhead but also because of the inconvenience - I would need to stop the program, capture the output of the tool and then kill it.

I have seen that newer versions of Linux 2.6.20+ provide /proc/<pid>/io/ which contain the information I'm looking for; however, everything under /proc/<pid> when the process terminates, so I'm again back to the same problem as with any network monitoring tool.

© Server Fault or respective owner

Related posts about linux

Related posts about process