5

I have a python script that uses urllibs to parse some web pages, and uses selenium to scrape pages with javascript, and I would like to know its cumulative bandwidth usage. I've looked at nethogs, but its tells me the usage per second, but won't tell me how much data the script has received or sent on eth0, for example.

Ideally, I would want it to track all new processes after I start monitoring, and then keep a table of what each process has used as a total.

Does such a tool exist? If not, is there a library in Python that I can implement in the script to track this?

  • what did you change? – user779420 Jun 9 '11 at 10:30
  • Trickle is a tool to limit the bandwidth of a process or a bunch of processes. It has everything in hand to compute what you want, but doesn't seem to have a way to print it out. – Gilles Jun 9 '11 at 22:58
  • Hey @user779420, did u resolve this problem? (7 years later I have the same requeriment) – Wonka Sep 6 '18 at 11:40
3

If you are looking for a network monitor that runs as an external process and can provide per-connection statistics on the number of transferred bytes, then IPTraf can do that.

Take a look at the example screenshots, especially the TCP/UDP statistical breakdown.

1

nethogs now allows to show cumulative bandwidth usage. Just press "m".

usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [-a] [-l] [-f filter][device [device [device ...]]]
                -V : prints version.
                -h : prints this help.
                -b : bughunt mode - implies tracemode.
                -d : delay for update refresh rate in seconds. default is 1.
                -v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
                -c : number of updates. default is 0 (unlimited).
                -t : tracemode.
                -p : sniff in promiscious mode (not recommended).
                -s : sort output by sent column.
                -l : display command line.
                -a : monitor all devices, even loopback/stopped ones.
                -f : EXPERIMENTAL: specify string pcap filter (like tcpdump). This may be removed orchanged in a future version.
                device : device(s) to monitor. default is all interfaces up and running excluding loopback

When nethogs is running, press:
 q: quit
 s: sort by SENT traffic
 r: sort by RECEIVE traffic
 l: display command line
 m: switch between total (KB, B, MB) and KB/s mode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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