`
mybwu_com
  • 浏览: 200903 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

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: 总数和当前使用情况模式之间切换

分享到:
评论

相关推荐

    nethogs0.8

    它能够帮助用户实时监控每个进程的网络带宽使用情况,从而有效地管理和优化网络资源。本文将详细介绍如何在CentOS 6.5操作系统中安装和使用nethogs 0.8版本。 首先,我们来理解一下nethogs的核心功能。nethogs不同...

    文化遗产保护:MATLAB点云处理在古建筑形变监测中的实践.pdf

    文档支持目录章节跳转同时还支持阅读器左侧大纲显示和章节快速定位,文档内容完整、条理清晰。文档内所有文字、图表、函数、目录等元素均显示正常,无任何异常情况,敬请您放心查阅与使用。文档仅供学习参考,请勿用作商业用途。 你是否渴望高效解决复杂的数学计算、数据分析难题?MATLAB 就是你的得力助手!作为一款强大的技术计算软件,MATLAB 集数值分析、矩阵运算、信号处理等多功能于一身,广泛应用于工程、科学研究等众多领域。 其简洁直观的编程环境,让代码编写如同行云流水。丰富的函数库和工具箱,为你节省大量时间和精力。无论是新手入门,还是资深专家,都能借助 MATLAB 挖掘数据背后的价值,创新科技成果。别再犹豫,拥抱 MATLAB,开启你的科技探索之旅!

    敏感图片敏感图片敏感图片敏感图片敏感图片敏感图片11

    敏感图片敏感图片敏感图片敏感图片敏感图片敏感图片11敏感图片敏感图片敏感图片敏感图片敏感图片敏感图片1122

    通信管道统建工程施工合同.docx

    通信管道统建工程施工合同.docx

    挂载网盘到本地工具.zip

    挂载网盘到本地工具.zip

    Spatial intelligence and geography 空间智能和地理.doc

    Spatial intelligence and geography 空间智能和地理.doc

    黑板风格毕业答辩模板25个

    黑板风格毕业答辩模板是一系列富有创意和趣味性的答辩文档模板,专为追求独特表达的大学生设计。这25个模板模拟了传统黑板的效果,结合了手绘风格与现代设计理念,使得内容呈现既生动又具学术感。每个模板都强调清晰的结构和易于理解的布局,适用于各类学科和研究领域,帮助学生有效地展示研究成果和核心观点。 黑板风格不仅带来亲切感,还能唤起人们对课堂学习的回忆,为答辩增添了轻松而专业的氛围。这些模板配备了丰富的图标、示意图和配色,既美观又实用,能够帮助学生在答辩中更好地吸引评审的注意力,增强信息的传达效果。无论是科技、艺术还是人文社科,黑板风格毕业答辩模板都能够为你的演示增添一份独特的魅力,提升你的表现,助力你在毕业答辩中取得成功。

    世邦魏理仕:2021年重庆房地产市场回顾与2022年展望.pdf

    世邦魏理仕:2021年重庆房地产市场回顾与2022年展望

    IMG_20250416_154916.jpg

    IMG_20250416_154916.jpg

    智慧农业大数据平台解决方案PPT(65页).pptx

    智慧农业,作为现代农业的新篇章,正引领着农业生产的革命性变革。本解决方案以物联网、云计算、大数据等先进技术为核心,为农业生产打造了一套全面、智能的管理系统。 想象一下,从温室大棚到广袤田野,智能传感器遍布每个角落,它们能实时感知空气温湿度、土壤水分、光照强度等环境参数,仿佛为农作物装上了“眼睛”和“耳朵”。这些数据通过物联网技术传输到云端,经过大数据分析,为农民提供精准的种植建议,如何时灌溉、施肥、防虫,让农业生产变得更加科学、高效。 更有趣的是,通过智慧农业平台,农民可以远程监控作物生长情况,甚至用手机就能控制温室大棚的遮阳板、通风设备等,实现“指尖上的农业”。此外,方案还包含了农产品可追溯系统,从田间到餐桌,每一步都可追溯,让消费者吃得放心。而智慧农业电商平台,则让农产品销售更加便捷,农民直接对接市场,收益倍增。 总之,这套智慧农业解决方案不仅让农业生产变得更加智能、高效,还提升了农产品的质量和安全,为农民带来了实实在在的收益,开启了农业现代化的新篇章。 对于想要投身智慧农业领域的你来说,这不仅仅是一套解决方案,更是一把开启现代农业大门的钥匙,引领你走向更加辉煌的未来。

    自动承保新员工示例-雇主责任险

    自动承保新员工示例-雇主责任险

    Java编程实现Redis集群连接与操作:含密码配置及异常处理机制设计了文档的主要内容

    内容概要:本文档主要介绍了Java代码连接Redis集群的方法,包括早期尝试的代码和修正后的有效代码。早期代码使用了`ShardedJedisPool`来管理多个`JedisShardInfo`对象,并设置了连接池参数和密码认证。然而,这段代码在实际的Redis集群环境中无法正常运行。修正后的代码采用了`JedisCluster`类,并通过配置连接池参数、设置密码以及定义集群节点信息,实现了与Redis集群的成功连接。此外,还提供了获取哈希表数据和集合数据的示例方法。 适合人群:具备一定Java编程经验,尤其是对Redis有一定了解的研发人员。 使用场景及目标:①学习如何正确配置Java代码连接Redis集群,包括设置连接池参数、密码认证和集群节点信息;②掌握通过`JedisCluster`类进行基本的Redis操作,如获取哈希表数据和集合数据。 阅读建议:读者应重点关注修正后的代码部分,理解其相对于早期代码的改进之处,特别是关于`JedisCluster`类的使用方法及其在连接Redis集群中的优势。同时,在实践中可以根据自己的需求调整连接池参数和密码配置。

    通信基站几种供电方案比较.doc

    通信基站几种供电方案比较.doc

    MCP协议从原理到开发保姆级教程.pdf

    内容概要:本文详细介绍了MCP(Model Context Protocol,模型上下文协议)的原理与开发流程。MCP协议起源于2024年11月25日Anthropic发布的文章,旨在解决不同AI模型间工具调用的碎片化问题,提供标准化接入方式,实现多功能应用与创新体验。文章首先解释了MCP的核心概念及其重要性,接着深入探讨了MCP Server和Client的开发步骤,包括项目搭建、工具注册、资源创建、提示符配置以及调试方法。此外,还讲解了MCP的工作原理,特别是C/S架构、JSON-RPC 2.0协议的应用,以及模型如何选择和执行工具。最后,通过一个实际案例展示了如何利用MCP协议构建一个企业微信机器人,实现查询知识库并将结果发送到群聊中。 适合人群:具备一定编程基础,对AI模型集成、标准化开发感兴趣的开发者,尤其是从事大语言模型相关工作的工程师。 使用场景及目标:①解决多模型集成中的工具调用标准化问题;②构建具备多种功能的企业级AI应用,如邮件发送、图像生成等;③学习如何通过MCP协议实现模型决策与工具执行的解耦,提升开发效率和用户体验。 阅读建议:本文适合有一定编程经验的读者,尤其是对AI模型集成有需求的技术人员。建议读者跟随文中提供的示例代码进行实践,理解MCP协议的核心机制,并尝试构建自己的MCP应用。同时,关注官方文档和社区动态,以获取最新的技术支持和开发指南。

    bofangBEEP.zip

    bofangBEEP

    【微电网优化】基于matlab改进的粒子群算法求解含风光柴储的微电网模型问题【含Matlab源码 13169期】.zip

    Matlab领域上传的视频是由对应的完整代码运行得来的,完整代码皆可运行,亲测可用,适合小白; 1、从视频里可见完整代码的内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可私信博主; 4.1 博客或资源的完整代码提供 4.2 期刊或参考文献复现 4.3 Matlab程序定制 4.4 科研合作

    Qt+Opencv 显示多摄像头画面

    Qt+Opencv 显示多摄像头画面

    金融领域中国房地产行业2023年信用展望:政策支持与债务压力下的市场前景分析

    文章基于彭博专业服务提供的数据,对中国房地产行业2023年的信用展望进行了详细分析。首先,中国政府出台了16项措施支持房地产行业发展,旨在打破行业恶性循环并改善地产商的现金流状况。政府的支持措施包括银行贷款、信托展期、债券发行计划等,这些措施有助于缓解地产商的资金压力,但效果取决于贷款规模。其次,文章指出,若政府持续提供支持,房地产销售有望复苏,尤其是投资级地产商的现金覆盖率较高,能更好地应对债务到期压力。然而,高收益地产商的现金覆盖率较低,面临更大的再融资风险。此外,2023年中资地产债到期规模较大,尤其是在第一季度和第二季度,可能导致再融资缺口扩大。最后,文章分析了不同评级地产商的债券表现,指出投资级地产债可能面临与高收益地产债类似的再融资压力,而高收益地产债的价格已接近历史低点,进一步下行空间有限。

    第十一章:链表和共用体的个别例子

    第十一章:链表和共用体的个别例子,第十一章:链表和共用体的个别例子,第十一章:链表和共用体的个别例子

    tranformer.py

    这个实现是基础的 Transformer 层,可以根据需要扩展,例如加入位置编码、掩码机制等。

Global site tag (gtag.js) - Google Analytics