I need to get current bandwidth usage on given interface in my Python code. How can I achieve this?
I tried to extract the value from /proc/net/dev
twice with short sleep interval (e.g. 0.3s) between two consecutive calls and compute the difference in bytes divided by time. It works but I do not know if I can trust this results. I'm looking for some more elegant solutions. Any tools, libraries, or simple algorithms?
I will appreciate all suggestions!