3

I have some processes in my unix system that sends data to a remote machine. It is possible to fetch the total bytes sent per pid ?

In general, how i can monitor that pid in terms of network?

Thank you

OhGodWhy
  • 115
  • 3
  • 12

1 Answers1

1

I suggest looking into nethogs.

From their Page:

NetHogs is a small 'net top' tool. Instead of breaking the traffic down per protocol or per subnet, like most tools do, it groups bandwidth by process. NetHogs does not rely on a special kernel module to be loaded. If there's suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this. This makes it easy to identify programs that have gone wild and are suddenly taking up your bandwidth.

Try

sudo nethogs -av 3
  • -a
    Monitor all devices.
  • -v 3
    View total MB sent/received.

See nethogs -h for usage.

Bora M. Alper
  • 320
  • 2
  • 10
devnull
  • 5,431
  • i want to take the data using my own program in PHP without the help of NetHogs. Isn't possible just run php get.php 5012 and get the total bytes sent from PID 5012? – OhGodWhy Jan 29 '15 at 16:40
  • As far as I am aware, no, because you will need something actively monitoring that PID's network traffic that has a return method PHP could call with GET to return the traffic data. PHP itself has nothing to call on the system to get a PID's traffic and the system isn't actively logging every PID's traffic without a reason to do so. – devnull Jan 29 '15 at 18:09