How do you measure the bandwidth used by a given process after it has completed, on Linux?

5

2

Is there a way to get a summary of how much bandwidth a given process used on Linux after the process completes? I do not want a monitor, I want something I can look at after the task has completed..

Ideally something like the "time" command or a profiler, but for network usage.

Paul

Posted 2010-02-09T18:46:40.127

Reputation: 151

Answers

1

Dominik

Posted 2010-02-09T18:46:40.127

Reputation: 767

0

tcptrace is quite powerful and is probably able to do the things you want. Maybe it's a bit too low-level though...

foraidt

Posted 2010-02-09T18:46:40.127

Reputation: 4 398

0

It is possible to count packets in and out using iptables based on a PID, I understand that knowing the PID before a process is starting is next to impossible. Depending on your situation this maybe reliant.

iptables -A OUTPUT -p TCP -m owner --pid-owner $PID -j ACCEPT

You can check if the rule is being hit and how many packets have hit it, with the following command.

iptables-save -c

Ash Palmer

Posted 2010-02-09T18:46:40.127

Reputation: 209