Programatically retrieve total number of bytes sent & received for (current) process
by vpseg from LinuxQuestions.org on (#54P87)
I need to retrieve the total number of bytes sent and received by a Python process/program. I prefer to do so within the Python program, but any working solution would be helpful.
What I've tried:
Nethogs: Not preferred as I cannot get information from it programatically
Wireshark: has a GUI
tshark: writing filters for all IPs used by the process is not ideal
Netfilter rules: see tshark
/proc/PID/net/dev: reading file while using ping shows all zeros; reading repeatedly until process terminates is not ideal
Please let me know.


What I've tried:
Nethogs: Not preferred as I cannot get information from it programatically
Wireshark: has a GUI
tshark: writing filters for all IPs used by the process is not ideal
Netfilter rules: see tshark
/proc/PID/net/dev: reading file while using ping shows all zeros; reading repeatedly until process terminates is not ideal
Please let me know.