Python – Measuring Python script bandwidth usage

bandwidthmonitoringpython

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?

Best Answer

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.

Related Question