nethogs是一款小巧的"net top"工具,可以显示每个进程所使用的带宽,并对列表排序,将耗用带宽最多的进程排在最上面。万一出现带宽使用突然激增的情况,用户迅速打开nethogs,就可以找到导致带宽使用激增的进程。nethogs可以报告程序的进程编号(PID)、用户和路径。
# ubuntu或debian(默认软件库)
$ sudo apt-get install nethogs
# fedora或centos(来自epel)
$ sudo yum install nethogs -y
NetHogs version 0.8.5
PID USER PROGRAM DEV SENT RECEIVED
13596 www nginx: worker process eth1 139.811 11.555 KB/sec
4542 www php-fpm: pool www eth1 0.944 11.106 KB/sec
? root 114.55.155.9:51412-140.207.137.23:80 0.223 3.551 KB/sec
11769 www php-fpm: pool www eth1 0.242 1.098 KB/sec
30734 www php-fpm: pool www eth1 0.242 1.098 KB/sec
? root 114.55.155.9:53088-140.207.119.12:443 0.401 1.056 KB/sec
? root 114.55.155.9:53120-140.207.119.12:443 0.275 1.054 KB/sec
? root 114.55.155.9:47094-120.27.162.28:3000 0.138 0.080 KB/sec
11507 root sshd: root@pts/0 eth1 0.236 0.025 KB/sec
? root 114.55.155.9:47068-120.27.162.28:3000 0.000 0.000 KB/sec
? root 114.55.155.9:47048-120.27.162.28:3000 0.000 0.000 KB/sec
? root 114.55.155.9:47034-120.27.162.28:3000 0.000 0.000 KB/sec
11764 www php-fpm: pool www eth1 0.000 0.000 KB/sec
? root 114.55.155.9:33790-58.246.220.31:443 0.000 0.000 KB/sec
? root 114.55.155.9:46980-120.27.162.28:3000 0.000 0.000 KB/sec
11561 www php-fpm: pool www eth1 0.000 0.000 KB/sec
? root unknown TCP 0.000 0.000 KB/sec
TOTAL 142.510 30.624 KB/sec
更多网络监控工具:http://os.51cto.com/art/201404/435279.htm