监控进程网络使用情况--NetHogs
Nethogs 是一个终端下的网络流量监控工具,它的特别之处在于可以显示每个进程的带宽占用情况,这样可以更直观获取网络使用情况。它支持 IPv4 和 IPv6 协议、支持本地网卡及 PPP 链接。
下载:
从SourceForge上下载nethogs-0.8.0.tar.gz
使用wget下载:
wget http://sourceforge.NET/projects/nethogs/files/nethogs/0.8/nethogs-0.8.0.tar.gz/download
安装:
安装之前需要先 yum install ncurses*
- [root@localhost Desktop]# yum install ncurses*
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.skyshe.cn
- * extras: mirrors.skyshe.cn
- * updates: mirrors.skyshe.cn
- Setting up Install Process
- Package ncurses-5.7-3.20090208.el6.x86_64 already installed and latest version
- Package ncurses-libs-5.7-3.20090208.el6.x86_64 already installed and latest version
- Package ncurses-base-5.7-3.20090208.el6.x86_64 already installed and latest version
- Resolving Dependencies
- --> Running transaction check
- ---> Package ncurses-devel.x86_64 0:5.7-3.20090208.el6 will be installed
- ---> Package ncurses-static.x86_64 0:5.7-3.20090208.el6 will be installed
- ---> Package ncurses-term.x86_64 0:5.7-3.20090208.el6 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- ========================================================================================================================================================================
- Package Arch Version Repository Size
- ========================================================================================================================================================================
- Installing:
- ncurses-devel x86_64 5.7-3.20090208.el6 base 642 k
- ncurses-static x86_64 5.7-3.20090208.el6 base 546 k
- ncurses-term x86_64 5.7-3.20090208.el6 base 547 k
- Transaction Summary
- ========================================================================================================================================================================
- Install 3 Package(s)
- Total download size: 1.7 M
- Installed size: 6.8 M
- Is this ok [y/N]: y
- Downloading Packages:
- (1/3): ncurses-devel-5.7-3.20090208.el6.x86_64.rpm | 642 kB 00:01
- (2/3): ncurses-static-5.7-3.20090208.el6.x86_64.rpm | 546 kB 00:00
- (3/3): ncurses-term-5.7-3.20090208.el6.x86_64.rpm | 547 kB 00:02
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Total 284 kB/s | 1.7 MB 00:06
- Running rpm_check_debug
- Running Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : ncurses-devel-5.7-3.20090208.el6.x86_64 1/3
- Installing : ncurses-static-5.7-3.20090208.el6.x86_64 2/3
- Installing : ncurses-term-5.7-3.20090208.el6.x86_64 3/3
- Verifying : ncurses-term-5.7-3.20090208.el6.x86_64 1/3
- Verifying : ncurses-static-5.7-3.20090208.el6.x86_64 2/3
- Verifying : ncurses-devel-5.7-3.20090208.el6.x86_64 3/3
- Installed:
- ncurses-devel.x86_64 0:5.7-3.20090208.el6 ncurses-static.x86_64 0:5.7-3.20090208.el6 ncurses-term.x86_64 0:5.7-3.20090208.el6
- Complete!
解压文件:
tar -zxvf nethogs-0.8.0.tar.gz
切换目录:
cd nethogs
编译安装:
make && make install
make出错了:
- [root@localhost nethogs]# make && make install
- cc -g -Wall -Wextra -c decpcap.c
- decpcap.c:7:18: error: pcap.h: No such file or directory
- In file included from decpcap.c:8:
- decpcap.h:34: error: expected specifier-qualifier-list before ‘pcap_t’
- decpcap.c:14: error: expected ‘)’ before ‘*’ token
- decpcap.c: In function ‘dp_open_offline’:
- decpcap.c:48: error: ‘pcap_t’ undeclared (first use in this function)
- decpcap.c:48: error: (Each undeclared identifier is reported only once
- decpcap.c:48: error: for each function it appears in.)
- decpcap.c:48: error: ‘temp’ undeclared (first use in this function)
- decpcap.c:48: warning: implicit declaration of function ‘pcap_open_offline’
- decpcap.c:55: warning: implicit declaration of function ‘dp_fillhandle’
- decpcap.c: In function ‘dp_open_live’:
- decpcap.c:60: error: ‘pcap_t’ undeclared (first use in this function)
- decpcap.c:60: error: ‘temp’ undeclared (first use in this function)
- decpcap.c:60: warning: implicit declaration of function ‘pcap_open_live’
- decpcap.c: In function ‘dp_addcb’:
- decpcap.c:74: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c: In function ‘dp_parse_tcp’:
- decpcap.c:84: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:86: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:87: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c: In function ‘dp_parse_ip’:
- decpcap.c:99: error: dereferencing pointer to incomplete type
- decpcap.c:103: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:105: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:106: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c: In function ‘dp_parse_ip6’:
- decpcap.c:126: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:128: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:129: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c: In function ‘dp_parse_ethernet’:
- decpcap.c:150: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:152: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:153: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c: In function ‘dp_parse_ppp’:
- decpcap.c:196: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:198: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:199: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c: In function ‘dp_parse_linux_cooked’:
- decpcap.c:238: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:240: error: ‘struct dp_handle’ has no member named ‘callback’
- decpcap.c:241: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c: In function ‘dp_pcap_callback’:
- decpcap.c:270: error: ‘struct dp_handle’ has no member named ‘userdata_size’
- decpcap.c:271: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c:271: error: ‘struct dp_handle’ has no member named ‘userdata_size’
- decpcap.c:273: error: ‘struct dp_handle’ has no member named ‘linktype’
- decpcap.c:274: error: ‘DLT_EN10MB’ undeclared (first use in this function)
- decpcap.c:277: error: ‘DLT_PPP’ undeclared (first use in this function)
- decpcap.c:280: error: ‘DLT_LINUX_SLL’ undeclared (first use in this function)
- decpcap.c:283: error: ‘DLT_RAW’ undeclared (first use in this function)
- decpcap.c:284: error: ‘DLT_NULL’ undeclared (first use in this function)
- decpcap.c:289: error: ‘struct dp_handle’ has no member named ‘linktype’
- decpcap.c: In function ‘dp_dispatch’:
- decpcap.c:296: error: ‘struct dp_handle’ has no member named ‘userdata’
- decpcap.c:297: error: ‘struct dp_handle’ has no member named ‘userdata_size’
- decpcap.c:298: warning: implicit declaration of function ‘pcap_dispatch’
- decpcap.c:298: error: ‘struct dp_handle’ has no member named ‘pcap_handle’
- decpcap.c: In function ‘dp_setnonblock’:
- decpcap.c:302: warning: implicit declaration of function ‘pcap_setnonblock’
- decpcap.c:302: error: ‘struct dp_handle’ has no member named ‘pcap_handle’
- decpcap.c: In function ‘dp_geterr’:
- decpcap.c:307: warning: implicit declaration of function ‘pcap_geterr’
- decpcap.c:307: error: ‘struct dp_handle’ has no member named ‘pcap_handle’
- make: *** [decpcap.o] Error 1
还是缺少依赖的东西,执行以下命令安装:
yum install libpcap-dev libncurses5-dev
- [root@localhost nethogs]# yum install libpcap-dev libncurses5-dev
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.skyshe.cn
- * extras: mirrors.skyshe.cn
- * updates: mirrors.skyshe.cn
- Setting up Install Process
- No package libpcap-dev available.
- No package libncurses5-dev available.
- Error: Nothing to do
- [root@localhost nethogs]# yum -y install libpcap-devel ncurses-devel
- Loaded plugins: fastestmirror, refresh-packagekit, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.skyshe.cn
- * extras: mirrors.skyshe.cn
- * updates: mirrors.skyshe.cn
- Setting up Install Process
- Package ncurses-devel-5.7-3.20090208.el6.x86_64 already installed and latest version
- Resolving Dependencies
- --> Running transaction check
- ---> Package libpcap-devel.x86_64 14:1.4.0-1.20130826git2dbcaa1.el6 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- ===============================================================================================================================================================================================
- Package Arch Version Repository Size
- ===============================================================================================================================================================================================
- Installing:
- libpcap-devel x86_64 14:1.4.0-1.20130826git2dbcaa1.el6 base 114 k
- Transaction Summary
- ===============================================================================================================================================================================================
- Install 1 Package(s)
- Total download size: 114 k
- Installed size: 160 k
- Downloading Packages:
- libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6.x86_64.rpm | 114 kB 00:00
- Running rpm_check_debug
- Running Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : 14:libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6.x86_64 1/1
- Verifying : 14:libpcap-devel-1.4.0-1.20130826git2dbcaa1.el6.x86_64 1/1
- Installed:
- libpcap-devel.x86_64 14:1.4.0-1.20130826git2dbcaa1.el6
- Complete!
再执行: make && make install
- [root@localhost nethogs]# make && make install
- cc -g -Wall -Wextra -c decpcap.c
- decpcap.c: In function ‘dp_open_live’:
- decpcap.c:60: warning: passing argument 5 of ‘pcap_open_live’ discards qualifiers from pointer target type
- /usr/include/pcap/pcap.h:349: note: expected ‘char *’ but argument is of type ‘const char *’
- g++ -g -Wall -Wextra -c cui.cpp -DVERSION=\"0\" -DSUBVERSION=\"8\" -DMINORVERSION=\"0\"
- g++ -g -Wall -Wextra -c inode2prog.cpp
- g++ -g -Wall -Wextra -c conninode.cpp
- g++ -c -o devices.o devices.cpp
- g++ -g -Wall -Wextra nethogs.cpp packet.o connection.o process.o refresh.o decpcap.o cui.o inode2prog.o conninode.o devices.o -o nethogs -lpcap -lm -lncurses -DVERSION=\"0\" -DSUBVERSION=\"8\" -DMINORVERSION=\"0\"
- g++ -g -Wall -Wextra decpcap_test.cpp decpcap.o -o decpcap_test -lpcap -lm
- install -d -m 755 /usr/local/sbin
- install -m 755 nethogs /usr/local/sbin
- install -d -m 755 /usr/local/share/man/man8/
- install -m 644 nethogs.8 /usr/local/share/man/man8/
安装成功了!
执行:nethogs
- [root@localhost nethogs]# nethogs
- Waiting for first packet to arrive (see sourceforge.net bug 1019381)
- NetHogs version 0.8.0
- PID USER PROGRAM DEV SENT RECEIVED
- 3227 root sshd: root@pts/2 eth0 0.666 0.059 KB/sec
- ? root unknown TCP 0.000 0.000 KB/sec
- TOTAL 0.666 0.059 KB/sec
下图显示各进程当前网络使用情况:
按“m”键可以切换到统计视图,显示各进程总的网络使用情况
按“Ctrl+C”或“q”退出监控
使用帮助:
- [root@localhost ~]# nethogs --help
- nethogs: invalid option -- '-'
- usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [device [device [device ...]]]
- -V : 显示版本信息,注意是大写字母V.
- -d : 延迟更新刷新速率,以秒为单位。默认值为 1.
- -t : 跟踪模式.
- -b : bug 狩猎模式 — — 意味着跟踪模式.
- -p : 混合模式(不推荐).
- 设备 : 要监视的设备名称. 默认为 eth0
- 当 nethogs 运行时, 按:
- q: 退出
- m: 总数和当前使用情况模式之间切换
监控进程网络使用情况--NetHogs相关推荐
- CentOS6.5下使用NetHogs监控进程网络使用情况
Nethogs 是一个终端下的网络流量监控工具,它的特别之处在于可以显示每个进程的带宽占用情况,这样可以更直观获取网络使用情况.它支持 IPv4 和 IPv6 协议.支持本地网卡及 PPP 链接. 下 ...
- Ubuntu 下监控进程网络流量
. . . . . 在网上找了一个监控网络流量的程序,具体使用方法还在测试中,先把安装的方式记录下来备查. 1 sudo apt-get install iptraf2 sudo iptraf 如果报 ...
- python流量监控,python监控历程网络流量
python监控进程网络流量 rt,各位大哥,python2.7+有没有高效监控进程级网络IO的方法?不用pcap 我只需要知道固定时间间隔中,客户端软件与服务器有没有交互就可以了: 或者给我讲解一下 ...
- 配置服务器监控专线网络
配置服务器监控专线网络 A goal is a dream with a deadline. Much effort, much prosperity. 配置服务器监控专线网络 项目介绍: 配置一台服 ...
- Linux实操-网络配置、进程管理、服务管理、动态监控进程、监控网络状态
网络配置 网络配置原理图 查看网络IP和网关 查看虚拟网络编辑器 修改虚拟网卡ip地址 查看网关 linux网络环境配置 第一种方法(自动获取) 第二种方法(指定固定的 ip) 进程管理(重点) 显示 ...
- Linux:动态监控进程+监控网络状态
1.动态监控进程: 当前时间 系统运行时间 用户数量 负载值(三个值的和/3如果大于0.7,则负载过大:否则负载还行) Tasks:任务数. running是正在运行的任务数 zombie是僵死进程( ...
- Linux命令(13)——实时监控进程、监控网络
1.实时监控进程: top指令:和ps相比 它是动态的 top -d top -i top -p 可以按照秒数去刷新: top -d 10 2. 查看网络状况: netstat 是用于网络服务 而 ...
- linux进程网络监控,linux下的进程、网络、性能监控命令
Linux下的java虚拟机性能监控与故障处理命令 java包中提供了很多监控JVM的工具类,作为java程序员必须得掌握常用的几个工具,下面是几个常用的JVM性能监控与故障处理工具的介绍与使用. 1 ...
- 使用JConsole监控进程、线程、内存、cpu、类情况
Jconsole简介: Jconsole是一个JMX兼容的监视工具.它使用Java虚拟机的JMX机制来提供运行在Java平台的应用程序的性能与资源耗费信息. 监控进程使用方法如下: 由于JConsol ...
最新文章
- Python之字符编码(Day10)
- 哇哦!恍然大悟般的“share”功能的实现!
- 用JAVA制作微型操作系统4月23日情况
- 日志处理两大生态Splunk和ELK深度对比
- 聊飞行 | 飞机到底是如何起飞的?
- testflight进行用户的beta测试
- Visio中如何画正弦波
- C# 每天温习一点(IEnumerableTSource)
- Python-精准提取行政区省市区
- 中国科学院全国名词委组合数学和计算机科学研究开发中心 顾同新,有关组合数学家陆家羲的几点史实澄清.doc...
- 百度地图设置显示定位服务器,百度地图API示例之设置地图显示范围
- java sdk qq登录授权,springboot开发qq第三方授权登录(示例代码)
- 计算机操作系统的主要功能
- PythonSPSS完成空气质量状况的指数(AQI)分析
- TI Sitara AM57x DSP+ARM + Xilinx Artix-7 FPGA核心板 规格书资料
- 360安全卫士造成Sharepoint文档库”使用资源管理器打开“异常
- 对文本文件的加密解密
- kaggle 泰坦尼克 高分 预测
- 毕业论文为什么要查重复率?
- Python自动化:模拟人类在百度搜索页输入关键词进行搜索并打开搜索结果
热门文章
- uniapp 子组件 props拿不到数据_谈一谈使用 webpack 开发时,Vue 组件之间的数据传递...
- 分布式一致性算法2PC和3PC
- 2018-2019-1 20165214 《信息安全系统设计基础》第八周学习总结
- linux中启动 java -jar 后台运行程序
- Python进阶_mysql(1)
- webpack 编译完成执行代码
- javaweb学习总结五(内省、beanUtils工具包)
- pl/sql developer中建立job
- 使用RMAN传输表空间复制数据
- 创新数字音频处理技术带来消费电子产品差异化用户体验(转)