一,nethogs的作用:
按進程或程序實時統計網絡帶寬使用率
我們查看流量的占用時,知道來源的ip、訪問的端口,還不足以幫我們確認到進程,
而nethogs則可以讓我們查看每個進程所占用的流量帶寬
說明:劉宏締的架構森林是一個專注架構的博客,地址:https://www.cnblogs.com/architectforest
對應的源碼可以訪問這里獲取: https://github.com/liuhongdi/
說明:作者:劉宏締 郵箱: 371125307@qq.com
二,安裝nethogs:
[root@yjweb ~]# yum install nethogs
說明:如果yum報錯沒有任何匹配,則先安裝epel源
[root@localhost liuhongdi]# yum install epel-release
三,查看nethogs的版本
[root@yjweb ~]# nethogs -V version 0.8.5
四,查看幫助
[root@yjweb ~]# nethogs -help 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
五,nethogs 的常用命令
1,每隔5秒刷新一次輸出結果
[root@yjweb ~]# nethogs -d 5
說明:默認間隔是1秒
2,按發送的數據量倒排
[root@yjweb ~]# nethogs -s
說明:默認是按RECEIVE的數據量倒排
3,監控所有的網卡
[root@yjweb ~]# nethogs -a
4,監控指定的一個或多個網卡
[root@yjweb ~]# nethogs eth0 eth1
5,監測指定的次數
[root@yjweb ~]# nethogs eth0 -c 3
說明:次數更新完即退出
六,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命令工具
七,查看當前的centos版本
[root@yjweb ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
