Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python net activity statistics linux

Tags:

python

linux

What is the easiest way to get network statistics (bandwidth used, current down/up rate) via Python.

I realize it'll have to be a system call to /proc, but is there an easier way or some tool that is available on standard *nix distributions for doing so?

Thanks

NOTE: I am going to use /proc/net/dev and parse the output 8-)

like image 817
Ian Livingstone Avatar asked Jul 29 '26 07:07

Ian Livingstone


1 Answers

You could try using http://pypi.python.org/pypi/pynetinfo/ - it would need extending to get the statistics, but that should be fairly trivial. Most of the code is already in place.

Alternatively you can just parse the output of ip -s link show device_name

like image 175
viraptor Avatar answered Jul 31 '26 20:07

viraptor