NetHogs介紹
NetHogs是一款開源、免費的,終端下的網絡流量監控工具,它可監控Linux的進程或應用程序的網絡流量。NetHogs只能實時監控進程的網絡帶寬占用情況。NetHogs支持IPv4和IPv6協議,支持本地網卡以及PPP鏈接。
官方介紹如下:
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下載
NetHogs的開源代碼在sourceforge上提供下載,它只提供源代碼下載。http://sourceforge.net/projects/nethogs/?source=directory。如果你需要下載RPM安裝包,可以去這個網址下載
Ubuntu下NetHogs安裝
sudo apt-get install nethogs
ReadHat下NetHogs安裝
[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]#
源碼安裝由於測試過程安裝失敗,再次不做講述
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
參考資料: