2

I need to collect information about the network usage of each process.

Nethogs presents the data I need in real time, I am trying to save the output to a file in order parse it and plot the data.

nethogs output

The white bar is messing the output, so I used:

sudo nethogs wlan0 | perl -pe 's/\x1b.*?[mGKH]//g'

enter image description here

Now it is better, but the DEV and SENT column are merged. One more thing, I need to add a timestamp per flush.

2 Answers 2

1

After hitting with my head against the walls during three days, I decided to change the source code of nethogs in order to print the way I need.

If someone needs: https://github.com/hdlopesrocha/nethogs

The result is something like this:

NetHogs version 0.8.2-SNAPSHOT
TIME PID USER PROGRAM DEV SENT RECEIVED
Ethernet link detected
Waiting for first packet to arrive (see sourceforge.net bug 1019381)
2016-02-11.00:38:29    3218 hdlopesrocha    /usr/lib/firefox/firefox    wlan0        0.026       0.026KB/sec
2016-02-11.00:38:30    3218 hdlopesrocha    /usr/lib/firefox/firefox    wlan0        0.026       0.026KB/sec
2016-02-11.00:38:31    3218 hdlopesrocha    /usr/lib/firefox/firefox    wlan0        0.026       0.026KB/sec
2016-02-11.00:38:32    3218 hdlopesrocha    /usr/lib/firefox/firefox    wlan0        0.026       0.026KB/sec
2016-02-11.00:38:33    3218 hdlopesrocha    /usr/lib/firefox/firefox    wlan0        0.026       0.026KB/sec
2016-02-11.00:38:34    3218 hdlopesrocha    /usr/lib/firefox/firefox    wlan0        0.036       0.038KB/sec

Be aware that this will override the original nethogs

Feel free to contact me if you need a different format.

0

To monitor wlan0

sudo nethogs wlan0

You can monitor network bandwidth of both eth0 and eth1 interfaces

nethogs [option] eth0 eth1

options :

-d delay for refresh rate.

For example, to set 5 seconds as your refresh rate, then type the command as.

 sudo nethogs -d 5

-h display available commands usage.

-p sniff in promiscious mode (not recommended).

-t tracemode.

-V prints Version info.

Keyboard shortcuts

Use the following interactive controls:

m : Cycle between display modes (kb/s, kb, b, mb)

r : Sort by received.

s : Sort by sent.

q : Quit and return to the shell prompt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .