Linux下进程网络带宽使用查看工具-NetHogs
有时候在定位排查问题的时候需要知道某个程序或进程网络带宽的使用情况,通常iftop、nload不能看到详细额对应关系,google一下找到了如下NetHogs这个工具。
什么是Nethogs
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是一个小型的’net top’工具,不像大多数工具那样拖慢每个协议或者是每个子网的速度而是按照进程进行带宽分组.NetHogs NetHogs不需 要依赖载入某个特殊的内核模块. 如果发生了网络阻塞你可以启动NetHogs立即看到哪个PID造成的这种状况.这样就很容易找出哪个程序跑飞了然后突然占用你的带宽.
Github:https://github.com/raboof/nethogs
安装
[root@LWS-QHK-NODE ~]# yum -y install epel-release
[root@LWS-QHK-NODE ~]# yum install libpcap nethogs
[root@LWS-QHK-NODE ~]# yum -y install nethogs
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Determining fastest mirrors
* elrepo: mirror-hk.koddos.net
* elrepo-kernel: mirror-hk.koddos.net
elrepo | 3.0 kB 00:00:00
elrepo-kernel | 3.0 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/6): elrepo/primary_db | 287 kB 00:00:00
(2/6): epel/7/x86_64/group_gz | 95 kB 00:00:00
(3/6): elrepo-kernel/primary_db | 1.9 MB 00:00:00
(4/6): epel/7/x86_64/updateinfo | 1.0 MB 00:00:00
(5/6): epel/7/x86_64/primary_db | 6.9 MB 00:00:00
(6/6): updates/7/x86_64/primary_db | 4.7 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package nethogs.x86_64 0:0.8.5-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================
Installing:
nethogs x86_64 0.8.5-1.el7 epel 38 k
Transaction Summary
===================================================================================================================================
Install 1 Package
Total download size: 38 k
Installed size: 71 k
Downloading packages:
nethogs-0.8.5-1.el7.x86_64.rpm | 38 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : nethogs-0.8.5-1.el7.x86_64 1/1
Verifying : nethogs-0.8.5-1.el7.x86_64 1/1
Installed:
nethogs.x86_64 0:0.8.5-1.el7
Complete!
使用
常用参数
[root@LWS-QHK-NODE ~]# nethogs -h
usage: nethogs [-V] [-h] [-b] [-d seconds] [-v mode] [-c count] [-t] [-p] [-s] [device [device [device ...]]]
-V : prints version.
-h : prints this help.
-b : bughunt mode - implies tracemode.
-d : delay for update refresh rate in seconds. default is 1. # 刷新频率
-v : view mode (0 = KB/s, 1 = total KB, 2 = total B, 3 = total MB). default is 0.
-c : number of updates. default is 0 (unlimited).
-t : tracemode.
-p : sniff in promiscious mode (not recommended).
-s : sort output by sent column.
-a : monitor all devices, even loopback/stopped ones.
device : device(s) to monitor. default is all interfaces up and running excluding loopback
When nethogs is running, press:
q: quit
s: sort by SENT traffic
r: sort by RECEIVE traffic
m: switch between total (KB, B, MB) and KB/s mode # 切换单位
文章目录