NetHogs介紹php
NetHogs是一款開源、免費的,終端下的網絡流量監控工具,它可監控Linux的進程或應用程序的網絡流量。NetHogs只能實時監控進程的網絡帶寬佔用狀況。NetHogs支持IPv4和IPv6協議,支持本地網卡以及PPP連接。html
官方介紹以下:shell
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 indentify programs that have gone wild and are suddenly taking up your bandwidth.網絡
NetHogs下載app
NetHogs的開源代碼在sourceforge上提供下載,它只提供源代碼下載。http://sourceforge.net/projects/nethogs/?source=directory。若是你須要下載RPM安裝包,能夠去這個網址下載工具
Ubuntu下NetHogs安裝測試
sudo apt-get install nethogsui
ReadHat下NetHogs安裝this
[root@localhost tmp]# rpm -ivh nethogs-0.8.0-1.el6.x86_64.rpm
warning: nethogs-0.8.0-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:nethogs ########################################### [100%]
[root@localhost tmp]#
源碼安裝因爲測試過程安裝失敗,再次不作講述spa
NetHogs使用
[root@localhost tmp]# nethogs
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
參考資料:
http://sourceforge.net/projects/nethogs/?source=directory
http://www.cnblogs.com/kerrycode/p/4748970.html