I want to know the amount of the network traffic (inbound and outbound) in a time period, generated a specific process and all subprocesses that it spawns.

I have developed a software that contains a "job manager" that runs forever and generates no network traffic on its own. It instead spawns child "workers" that does the main work, including the majority of network traffic. The tricky point is, several "workers" may work simultaneously, and a single worker process is expected to exit after a short period (a few hours). Furthermore, these workers also spawns more subprocesses that generates traffic like git fetch that needs to be monitored as well.

There will be only one instance of "job manager" and it can be started or killed on-demand on my development and testing server, which runs Ubuntu Server 18.04, architecture amd64.

I want to monitor the network traffic of all the workers and the processes that workers spawn, for a prolonged period (one week or more). Is there a solution?

up vote 5 down vote accepted

Probably the easiest way is to put the job manager in a network namespace. All child processes will also be in that namespace. Connect up the namespace via veth or macvlan, measure traffic on that interface.

  • Sounds like a good idea. I'll try this out later. – iBug Oct 21 at 8:31
  • OK, I've set up a namespace following this blog. Now how do I monitor the interface? – iBug Oct 27 at 13:04
  • Look at /sys/class/net/${interface}/statistics/, or use one of the many software packages (google, there's at least several dozen). – dirkt Oct 27 at 13:10

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.