- 浏览: 192598 次
- 性别:
文章分类
最新评论
CentOS6.5下使用NetHogs监控进程网络使用情况
Nethogs 是一个终端下的网络流量监控工具,它的特别之处在于可以显示每个进程的带宽占用情况,这样可以更直观获取网络使用情况。它支持 IPv4 和 IPv6 协议、支持本地网卡及 PPP 链接。
下载:
从SourceForge上下载nethogs-0.8.0.tar.gz
使用wget下载:
wgethttp://sourceforge.net/projects/nethogs/files/nethogs/0.8/nethogs-0.8.0.tar.gz/download
安装:
安装之前需要先yuminstallncurses*
[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 -zxvfnethogs-0.8.0.tar.gz
切换目录:
cd nethogs
编译安装:
make&&makeinstall
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&&makeinstall
[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镜像文件下载与安装详解 #### 一、CentOS 6.5简介 CentOS是Community ENTerprise Operating System的缩写,是一个基于Linux内核的操作系统,它主要提供了企业级的计算环境。CentOS 6.5作为CentOS 6...
CentOs6.5镜像源
CentOS 6.5 的 软件源很多官方已经停止维护,该文件包内配置好的yum源是可以正常使用的。将原/etc/yum.repos.d/目录下原来的 .repo 备份, 然后把本文件包内的repo文件复制过去, yum clean all 后,再 yum ...
在 CentOS 7 系统中部署 Nethogs 监控软件是一个非常实用的过程,Nethogs 是一个轻量级的工具,它可以帮助系统管理员实时跟踪各个进程或应用程序的网络带宽使用情况。以下是对这个过程的详细说明: 首先,我们需要...
下面将详细介绍如何使用 VMware 创建虚拟机并安装 CentOS6.5 操作系统。 步骤一:创建 CentOS6.5 虚拟机 1. 打开 VMware 软件,点击“文件”菜单,然后选择“新建虚拟机”。 2. 在“新建虚拟机向导”中,选择...
centos 6.5 telnet 客户端 安装文件 rpm包 centos 6.5 telnet 服务端 安装文件 rpm包 http://vault.centos.org/6.5/os/x86_64/Packages/ 从官网下载亲测可以用
CentOS6.5的64位镜像文件iso。CentOS是基于linux内核而扩展的操作系统。
centos 6.5下的文件上传下载服务安装和配置 centos 6.5下的文件上传下载服务是指在centos 6.5操作系统中安装和配置文件上传下载服务,以解决上传和下载文件的问题。这个服务可以让用户轻松地上传和下载文件,而不...
CentOS 6.5 是一个稳定、功能强大且广泛应用的 Linux 发行版,本文将详细介绍 CentOS 6.5 的安装步骤,包括虚拟机的安装、CentOS 镜像文件的下载和使用、连接工具的配置等内容。 一、虚拟机安装 虚拟机是安装 ...
本文将详细讲解如何在CentOS 6.5系统上升级OpenSSH。 首先,升级OpenSSH通常涉及升级其依赖的库,特别是openssl。openssl是提供加密功能的核心库,新的版本通常会包含更强的加密算法和修复的安全漏洞。在升级...
在CentOS6.5系统下安装CDH5.8.2,首先需要准备三台虚拟机,分别安装CentOS6.5系统。然后,需要修改主机名分别为hadoop01/hadoop02/hadoop03。修改主机名的方法有两种:一种是使用setup命令,另一种是修改vim /etc/...
在Linux系统中,CentOS 6.5是一个广泛使用的版本,而MySQL 5.6则是一个流行的开源数据库管理系统。本文将详细介绍如何在CentOS 6.5上进行MySQL 5.6的一键安装过程,包括必要的环境准备、安装步骤、配置优化以及安全...
安装完成后,重启虚拟机,使用root用户登录系统,并开始CentOS6.5的初步配置,包括设置日期和时间,配置防火墙和SELinux等。 需要注意的是,由于文档是通过OCR技术扫描生成的,因此在某些文字识别上可能会存在错误...
Centos6.5升级openssh-9.1p1包括32位和9.3版本的63位的全部rpm包,附带telnet客户端的rpm包 32位: openssh-9.1p1-1.el6.i386.rpm openssh-clients-9.1p1-1.el6.i386.rpm openssh-server-9.1p1-1.el6.i386.rpm ...
CentOS 6.5是一款稳定且广泛使用的Linux发行版,尤其适合企业级应用,包括Oracle数据库部署。 #### 二、安装准备 **1. 系统要求** - **操作系统**: CentOS 6.5 64位 - **内存**: 最小628MB,推荐4GB以上(适用于...
使用U盘安装CentOS 6.5可以跳过刻盘的步骤,速度也更快,而且没有硬件限制(新机器USB口都有,光驱不一定有)。 U盘安装CentOS 6.5的优点: 1. 不需要刻盘,速度快 2. 没有硬件限制(新机器USB口都有,光驱不一定...
"centos6.5-ntp安装包.rar"显然包含了在CentOS 6.5上安装和配置NTP服务所需的文件和步骤。 安装NTP服务首先需要解压下载的rar文件,通常这需要使用像unrar这样的工具。在CentOS上,你可以通过以下命令安装unrar: ...
在本教程中,我们将详细讲解如何在WM(可能是指WMware)虚拟机环境下安装CentOS 6.5操作系统。这是一份由个人安装经验整理出的教程,适用于想要在虚拟环境中搭建CentOS 6.5开发或测试环境的用户。 首先,创建虚拟机...
资源名称:CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南内容简介: CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南主要讲述的是CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南;...