CentOS6.5下使用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: 总数和当前使用情况模式之间切换
CentOS6.5下使用NetHogs监控进程网络使用情况的更多相关文章
- 使用NetHogs监控进程网络使用情况
Nethogs 是一个终端下的网络流量监控工具,它的特别之处在于可以显示每个进程的带宽占用情况,这样可以更直观获取网络使用情况.它支持 IPv4 和 IPv6 协议.支持本地网卡及 PPP 链接. 使 ...
- ubuntu下使用nethogs监控网络流量
NetHogs是一款小巧免费的开源命令行工具,用来按进程或程序实时统计网络带宽使用率. 对于使用类似于“repo tool”.“depot_tools”等工具checkout源码时非常有用,可以查看当 ...
- CentOS7 监控进程网络流量工具安装
服务器在做测试的时候,需要监控网络流量,用来了解在不同人数的时候服务器的网络使用量. 我们使用服务器环境是centos7,centos下通常使用iftop,或者nethogs来进行网络流量监控.这2个 ...
- redhat 7.6 流量监控命令、软件(3)nethogs 监控进程实时流量
1.解压nethogs tar -zxvpf nethogs_0.8.5.orig.tar.gz 2.直接make,这里报错,提示pcap.h,安装libpcap就可以了 3.如果已经安装,还是报错, ...
- CENTOS6.6下nmon的监控
本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn Installing Nmon By default nmon is ...
- linux 下监控进程流量情况命令 NetHogs
摘自: http://www.cnblogs.com/kerrycode/p/4748970.html NetHogs介绍 NetHogs是一款开源.免费的,终端下的网络流量监控工具,它可监控Linu ...
- Linux下,如何监控某个进程到底向哪个地址发起了网络调用
Linux下,如何监控某个进程到底向哪个地址发起了网络调用 有时候,有些应用,比如idea,你发起某个操作时,其底层会去请求网络,获取一些数据. 但是不知道,请求了什么地址.举个例子,在idea中,m ...
- linux下实现监控进程网络带宽
嗯,近期都在网易游戏实习,所以貌似有段时间没有上来写点东西了... 来网易游戏实习最基本的目的事实上就是想知道在游戏公司里面工作都是些什么内容,毕竟自己曾经也没有接触过游戏公司.. 还比較的好奇.. ...
- Ubuntu 16.04安装基于nethogs衍生的网络监控软件(应用实时网速监控)
基于nethogs衍生的网络监控软件有如下所列举的: nettop显示数据包类型,按数据包的大小或数量排序. ettercap是以太网的网络嗅探器/拦截器/记录器 darkstat通过主机,协议等方式 ...
随机推荐
- PC--CSS命名
头:header内 容:container尾:footer导航:nav侧栏:sidebar栏目:column页 面外围控制整体布局宽度:wrapper左右中:left right center登录条: ...
- Binarized Neural Networks_ Training Neural Networks with Weights and Activations Constrained to +1 or −1
转载请注明出处: http://www.cnblogs.com/sysuzyq/p/6248953.html by 少侠阿朱
- [转]Laravel 4之URL生成
Laravel 4之URL生成 http://dingjiannan.com/2013/laravel-url/ 获取当前URL 获取当前URL有两种方式,URL::current()或URL::fu ...
- 显示器 RUIGE瑞鸽高清显示器TL-S1700HD
版权声明:本文博客琅邪工作室原创文章,博客,未经同意不得转载.
- java获取当前系统毫秒,纳秒
//获取当前系统毫秒 System.out.println(System.currentTimeMillis()); //获取当前系统纳秒 System.out.println(System.nano ...
- CSS彻底研究(2)
Github pages 博文 一 . CSS盒模型 1.盒子的结构 margin-border-padding结构 + 内容content 组成盒模型 注意 width,height 取的是cont ...
- asp.net 发送邮件函数两则
using System.Net.Mail; using System.Text; using System.Net; #region 邮件发送 /// <summary> /// 邮件发 ...
- [Python]打开文件的模式
Python中以sys.open()方法打开文件 import sys file = open("D:\\file.txt") 其中可在第二个参数的位置指定打开文件的模式 impo ...
- 关于降低android手机摄像头预览分辨率
假设现在有这样一个需求需要一直开着手机摄像头 但是不做任何拍照动作 但是每个手机的相机分辨率都不同 而默认预览的时候参数是最大分辨率 这样有时候就回导致电量损耗的加快 所以我们可以采取降低相机分辨率的 ...
- java中的IO流读取文件
1 InputStream类和OutputStream类 InputStream.read()方法从文件中读取一个字节(0-255),然后将此字节转换成对应的整数返回.假设一个文件的编码为utf-8编 ...