CentOS下nethogs命令详解
人气:0Nethogs 是一个终端下的网络流量监控工具,它的特别之处在于可以显示每个进程的带宽占用情况,这样可以更直观获取网络使用情况。它支持 IPv4 和 IPv6 协议、支持本地网卡及 PPP 链接。
安装过程
##下载##
[root@ipython ~]# wget http://softlayer-dal.dl.sourceforge.net/project/nethogs/nethogs/0.8/nethogs-0.8.0.tar.gz
##依赖安装##
[root@ipython ~]# yum install libpcap-devel ncurses-devel
##build iftop##
[root@ipython ~]# tar zxf nethogs-0.8.0.tar.gz
[root@ipython ~]# cd nethogs
[root@ipython nethogs]# make && make install
直接运行
[root@ipython ~]# nethogs --help
nethogs: invalid option -- '-'
usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [device [device [device ...]]]
-V : 版本输出
-d : 延迟刷新,默认1秒
-t : 跟踪模式
-b : bughunt mode - implies tracemode.
-p : 指定接口
When nethogs is running, press:
q: quit
m: switch between total and kb/s mode
awk 处理nethogs日志一例:
[root@ipython ~]# nethogs > awk_nethogs.txt
Waiting for first packet to arrive (see sourceforge.net bug 1019381)
[root@ipython ~]# cat -A awk_nethogs.txt |awk -F '[ ^]+' '/\?/&&!/unknown/{sub(/^.*H/,"",$4);sub(/^.*G/,"",$5);print $3"\t"$4"\t"$5}'
[[1;23r [(B [[m
[[0;7m PID USER
[[0;7m PID USER
[[0;7m PID USER
107.170.243.66:80-27.115.124.32:38707 0.119 0.091
107.170.243.66:80-27.115.124.32:38707 0.119 0.091
107.170.243.66:80-27.115.124.32:38707 0.119 0.091
107.170.243.66:80-27.115.124.32:38707 0.119 0.091
107.170.243.66:80-27.115.124.32:38707 0.119 0.091
加载全部内容