Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capture nethogs output in log file

Tags:

linux

bash

I want to check the network bandwidth used by my process. For this i found that nethogs tool is useful. Using this tool i can see which process is eating up a network bandwidth and process behaviour. But how do I capture data from nethogs for a my process and store it into log file ?

like image 626
vab050 Avatar asked Dec 20 '13 11:12

vab050


2 Answers

I dont know when these options got implemented but you can use nethogs -t or nethogs -b, the pid and user are strangely placed at the end of the pid command string, but easy enough to parse.

I think you need to use the latest cvs version 0.8.1-SNAPSHOT

like image 133
Aquarius Power Avatar answered Sep 21 '22 20:09

Aquarius Power


You can run nethogs in background in tracemode and write output to a file like this:

sudo nethogs -t eth1 &> /var/tmp/nethogs.log & 

Download and build the nethogs-parser as described here.

Then after you have accumulated enough data you can run the parser to see the results:

./hogs -type=pretty /var/tmp/nethogs.log 

Make sure to kill the running nethogs process when you are done collecting data.

More info here on automating the task.

like image 26
kaptan Avatar answered Sep 18 '22 20:09

kaptan