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
安装:
个人补充:
首先,需要g++编译器,因为nethogs是使用c++编写,即.cpp结尾的文件,必须使用g++进行编译,如果是.c,使用gcc编译器即可。
# rpm -ivh libstdc++-devel-4.1.2-51.el5.x86_64.rpm
# rpm -ivh gcc-c++-4.1.2-51.el5.x86_64.rpm
# ls /mnt/Server/ |grep ncur
ncurses-5.5-24.20060715.i386.rpm
ncurses-5.5-24.20060715.x86_64.rpm
ncurses-devel-5.5-24.20060715.i386.rpm
ncurses-devel-5.5-24.20060715.x86_64.rpm
php-ncurses-5.1.6-27.el5_5.3.x86_64.rpm
然后,需要先 yum install ncurses*,如果安装提示需要下载,可以直接使用rpm -ivh 安装即可,具体安装,如上所示。
- [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 注意,此处安装时,如果用rpm -qa|grep libpcap-devel 可以查到,但是到光盘的目录查找不一定有, ls /mnt/Server |grep ncurses-devel,故使用rpm -ivh分别取安装 libpcap-devel ncurses-devel 不一定成功,所以直接使用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: 退出
NetHogs下载和监控的更多相关文章
- 使用Typescript重构axios(二十五)——文件上传下载进度监控
0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...
- centos8平台使用nethogs基于进程监控网络流量
一,nethogs的作用: 按进程或程序实时统计网络带宽使用率 我们查看流量的占用时,知道来源的ip.访问的端口,还不足以帮我们确认到进程, 而nethogs则可以让我们查看每个进程所占用的流量带宽 ...
- linux 下监控进程流量情况命令 NetHogs
摘自: http://www.cnblogs.com/kerrycode/p/4748970.html NetHogs介绍 NetHogs是一款开源.免费的,终端下的网络流量监控工具,它可监控Linu ...
- Linux NetHogs监控工具介绍
NetHogs介绍 NetHogs是一款开源.免费的,终端下的网络流量监控工具,它可监控Linux的进程或应用程序的网络流量.NetHogs只能实时监控进程的网络带宽占用情况.NetHogs支持IPv ...
- Linux NetHogs监控工具介绍(转)
NetHogs介绍 NetHogs是一款开源.免费的,终端下的网络流量监控工具,它可监控Linux的进程或应用程序的网络流量.NetHogs只能实时监控进程的网络带宽占用情况.NetHogs支持IPv ...
- NetHogs 实时检测网络流量 转
有很多适用于Linux系统的开源网络监视工具.比如说,你可以用命令iftop来检查带宽使用情况. netstat用来查看接口统计报告,还有top监控系统当前运行进程.但是如果你想要找一个能够按进程实时 ...
- NetHogs——Linux下按进程实时统计网络带宽利用率
Debian/Ubuntu下安装很简单,执行:apt-get install nethogs 就可以安装. CentOS/RHEL下建议先安装上EPEL,再执行:yum install libpcap ...
- linux 网络数据收发网络流量监控
网卡流量 1.iftop命令 iftop可以用来监控网卡的实时流量(可以指定网段).反向解析IP.显示端口信息.TCP/IP连接等官网:http://www.ex-parrot.com/~pdw/if ...
- Spark的Straggler深入学习(1):如何在本地图形监控远程Spark的GC情况——使用java自带的jvisualvm
一.本文的目的 Straggler是目前研究的热点,Spark中也存在Straggler的问题.GC问题是总所周知的导致Straggler的重要因素之一,为了了解GC导致的Straggle ...
随机推荐
- STM32串口USART1的使用方法
前言: 通用同步异步收发器(USART)提供了一种灵活的方法来与使用工业标准NR 异步串行数据格式的外部设备之间进行全双工数据交换. USART利用分数波特率发生器提供宽范围的 波特率选择,支持同 ...
- 5月18日:top10面试算法-LRUcache的实现
问题描述: LRU算法:优先把那些最长时间没使用的对象置换掉.根据数据的历史访问记录来进行淘汰数据,其核心思想是“如果数据最近被访问过,那么将来被访问的几率也更高”. JAVA实现: 测试: publ ...
- (转)js函数参数设置默认值
原文:http://www.cnblogs.com/RightDear/archive/2013/06/26/3156652.html js函数参数设置默认值 php有个很方便的用法是在定义函数时 ...
- 计算机网络及TCP/IP知识点(全面,慢慢看)
TCP/IP网络知识点总结 一.总述 1.定义:计算机网络是一些互相连接的.自治的计算机的集合.因特网是网络的网络. 2.分类: 根据作用范围分类: 广域网 WAN (Wide Area Networ ...
- android手机连接PC无法正常安装驱动
工作当中我们经常会遇到Android手机连接PC的时候无法正确安装驱动,或者安装失败.当然找到正确的驱动文件时首选的解决方案,如果正确的驱动文件依旧无法安装成功我们可以打开我的电脑-->属性-- ...
- Investment_完全背包
Description John never knew he had a grand-uncle, until he received the notary's letter. He learned ...
- [DP]数位DP总结
数位DP总结 By Wine93 2013.7 1.学习链接 [数位DP] Step by Step http://blog.csdn.net/dslovemz/article/details/ ...
- Selenium Grid原理
转载: http://blog.csdn.net/five3/article/details/9428655 Selenium-Grid版本 selenium-grid分为版本1和版本2,其实它的2个 ...
- Gitlab. Disable user creation on welcome page
Login to your Gitlab > Admin area > settings > Features > remove the check mark "Si ...
- 【题解】【位操作】【Leetcode】Single Number II
Given an array of integers, every element appears three times except for one. Find that single one. ...