I'm looking for a permanently-running monitor which can emit a monthly (or daily, etc) bandwidth report, in a per-program manner.
Example desired output:
Bandwidth consumption: last 30 days
==============
Program Downloaded Uploaded
/usr/bin/ssh 30MB 100MB
/usr/bin/java 9000MB 3000MB
(it also could be per-process instead of per-program, but then I'd have to consolidate entries manually)
After significative research (including many similar questions over Stack Exchange), I still haven't found such a monitor. Maybe this is not possible under Linux. Or maybe this is bit of an unusual need.
Best Answer
Use
nethogs -t
to capture per-process usage and parse the output. From https://boopathi.in/blog/capturing-per-process-bandwidth-usage-using-nethogs/The output fields are:
and parse the output using https://github.com/boopathi/nethogs-parser
Another solution from SO: https://stackoverflow.com/a/20705080/3812704
But I like the first solution better.