安裝nethogs:
apt-get -y install ncurses*
apt-get -y install libpcap-dev libncurses5-dev
wget -c https://github.com/raboof/nethogs/archive/v0.8.1.tar.gz
tar xvf v0.8.1.tar.gz
cd nethogs-0.8.1
make && make install
遇到的問題一:之前安裝的0.8.0版本,有如下問題:
creating socket failed while establishing local IP - are you root?
不用找其他方法了,安裝0.8.1吧 wget -c https://github.com/raboof/nethogs/archive/v0.8.1.tar.gz
NetHogs提供交互式控制指令:
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. 退出NetHogs命令工具
NetHogs 命令行參數
常用的參數:
-d delay for refresh rate. 數據刷新時間 如nethogs -d 1 就是每秒刷新一次
-h display available commands usage. 顯示命名幫助、使用信息
-p sniff in promiscious mode (not recommended).
-t tracemode.
-V prints Version info.
演示例子:
#5秒刷新一次數據
nethogs -d 5
#監控網卡eth0數據
nethogs eth0
#同時監視eth0和eth1接口
nethogs eth0 eth1
#將監控日志寫入日志文件
nethogs >>test.log
要查看這台設備上的總體帶寬情況,可以使用nload、iftop、ifstat工具。 要查看這台設備上的每個進程連接的帶寬情況,可以使用nethogs工具。
nload的安裝請參看另一篇博文: http://blog.163.com/ldw21cn@126/blog/static/24295648201351701232699/