Grep values from nethog and netperf

0

0

I need to monitor the network activities of a process and the bandwidth of the connection. So I decided to use nethog and netperf combine with grep and awk to write the values to a file.

nethog command: nethogs -t eth0 | grep firefox | awk '{ print $3 }' (I want to take the upload/download speed). The 1st problem is that command doesn't print anything.

More detail: command: nethogs -t eth0 | grep firefox output:

usr/lib/firefox/firefox-bi�)/4956/1000  0.338867    0.239063
/usr/lib/firefox/firefox-bi�)/4956/1000 0.543555    0.274219
/usr/lib/firefox/firefox-bi�)/4956/1000 0.794531    0.489844
/usr/lib/firefox/firefox-bi�)/4956/1000 0.794531    0.489844
/usr/lib/firefox/firefox-bi�)/4956/1000 0.749023    0.589844
/usr/lib/firefox/firefox-bi�)/4956/1000 1.30098 3.47617
/usr/lib/firefox/firefox-bi�)/4956/1000 1.90449 8.0127
/usr/lib/firefox/firefox-bi�)/4956/1000 5.31641 25.0033
/usr/lib/firefox/firefox-bi�)/4956/1000 8.60762 42.0176

I want the two values at the bottom right. But as you can see the output ain't consistent (the space), add | awk '{print $3}' most of the time return nothing. And I can't fix this.

netperf command: netperf -H 192.168.1.10 and the output is:

Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

524288 524288 262144    10.00    **718.62**

I want to print the value on the bottom right but have no idea how to. That's the 2nd problem

Can you guys help me out? Any ideas will be appreciated!

Tiana987642

Posted 2014-03-07T15:37:52.567

Reputation: 263

Question was closed 2014-03-26T05:22:25.753

No answers