snmp中获取某一snmp cpu进程占用率cpu占用时间怎么计算出该snmp cpu进程占用率的cpu使用率

如何计算某个进程cpu的占用率_科普知识_中国百科网
如何计算某个进程cpu的占用率
    我使用的是snmp可以得到所有进程的cup占用时间。host-resources-mib::hrswrunperfcpu.1?=?integer:?248host-resources-mib::hrswrunperfcpu.2?=?integer:?3host-resources-mib::hrswrunperfcpu.3?=?integer:?20host-resources-mib::hrswrunperfcpu.4?=?integer:?13host-resources-mib::hrswrunperfcpu.5?=?integer:?0host-resources-mib::hrswrunperfcpu.21?=?integer:?156host-resources-mib::hrswrunperfcpu.22?=?integer:?0host-resources-mib::hrswrunperfcpu.39?=?integer:?70host-resources-mib::hrswrunperfcpu.40?=?integer:?46host-resources-mib::hrswrunperfcpu.41?=?integer:?55host-resources-mib::hrswrunperfcpu.42?=?integer:?0host-resources-mib::hrswrunperfcpu.188?=?integer:?0host-resources-mib::hrswrunperfcpu.421?=?integer:?0host-resources-mib::hrswrunperfcpu.431?=?integer:?0host-resources-mib::hrswrunperfcpu.432?=?integer:?0host-resources-mib::hrswrunperfcpu.447?=?integer:?9471host-resources-mib::hrswrunperfcpu.1670?=?integer:?33host-resources-mib::hrswrunperfcpu.2427?=?integer:?0host-resources-mib::hrswrunperfcpu.2569?=?integer:?0host-resources-mib::hrswrunperfcpu.2980?=?integer:?2296host-resources-mib::hrswrunperfcpu.2984?=?integer:?11host-resources-mib::hrswrunperfcpu.3008?=?integer:?2host-resources-mib::hrswrunperfcpu.3028?=?integer:?3host-resources-mib::hrswrunperfcpu.3056?=?integer:?128host-resources-mib::hrswrunperfcpu.3142?=?integer:?1host-resources-mib::hrswrunperfcpu.3154?=?integer:?74host-resources-mib::hrswrunperfcpu.3202?=?integer:?24host-resources-mib::hrswrunperfcpu.3217?=?integer:?4host-resources-mib::hrswrunperfcpu.3236?=?integer:?449host-resources-mib::hrswrunperfcpu.3245?=?integer:?10host-resources-mib::hrswrunperfcpu.3256?=?integer:?308host-resources-mib::hrswrunperfcpu.3287?=?integer:?0host-resources-mib::hrswrunperfcpu.3288?=?integer:?14host-resources-mib::hrswrunperfcpu.3298?=?integer:?40host-resources-mib::hrswrunperfcpu.3323?=?integer:?19host-resources-mib::hrswrunperfcpu.3342?=?integer:?21host-resources-mib::hrswrunperfcpu.3361?=?integer:?75host-resources-mib::hrswrunperfcpu.3374?=?integer:?1host-resources-mib::hrswrunperfcpu.3385?=?integer:?10038host-resources-mib::hrswrunperfcpu.3458?=?integer:?10host-resources-mib::hrswrunperfcpu.3501?=?integer:?58176host-resources-mib::hrswrunperfcpu.3532?=?integer:?12902host-resources-mib::hrswrunperfcpu.3605?=?integer:?562host-resources-mib::hrswrunperfcpu.3612?=?integer:?1host-resources-mib::hrswrunperfcpu.3613?=?integer:?1host-resources-mib::hrswrunperfcpu.3616?=?integer:?1host-resources-mib::hrswrunperfcpu.3617?=?integer:?1host-resources-mib::hrswrunperfcpu.3618?=?integer:?1host-resources-mib::hrswrunperfcpu.3710?=?integer:?5host-resources-mib::hrswrunperfcpu.3751?=?integer:?4host-resources-mib::hrswrunperfcpu.3796?=?integer:?2host-resources-mib::hrswrunperfcpu.3971?=?integer:?1host-resources-mib::hrswrunperfcpu.4068?=?integer:?1host-resources-mib::hrswrunperfcpu.4115?=?integer:?1host-resources-mib::hrswrunperfcpu.4116?=?integer:?27host-resources-mib::hrswrunperfcpu.4355?=?integer:?23host-resources-mib::hrswrunperfcpu.4400?=?integer:?175464host-resources-mib::hrswrunperfcpu.4473?=?integer:?157host-resources-mib::hrswrunperfcpu.4499?=?integer:?417host-resources-mib::hrswrunperfcpu.4500?=?integer:?1host-resources-mib::hrswrunperfcpu.4504?=?integer:?4host-resources-mib::hrswrunperfcpu.4506?=?integer:?207host-resources-mib::hrswrunperfcpu.4537?=?integer:?58host-resources-mib::hrswrunperfcpu.4540?=?integer:?1host-resources-mib::hrswrunperfcpu.4541?=?integer:?2host-resources-mib::hrswrunperfcpu.4547?=?integer:?21host-resources-mib::hrswrunperfcpu.4550?=?integer:?1host-resources-mib::hrswrunperfcpu.4552?=?integer:?40host-resources-mib::hrswrunperfcpu.4554?=?integer:?46host-resources-mib::hrswrunperfcpu.4560?=?integer:?2164host-resources-mib::hrswrunperfcpu.4592?=?integer:?40host-resources-mib::hrswrunperfcpu.4596?=?integer:?173host-resources-mib::hrswrunperfcpu.4598?=?integer:?153host-resources-mib::hrswrunperfcpu.4600?=?integer:?19host-resources-mib::hrswrunperfcpu.4602?=?integer:?136host-resources-mib::hrswrunperfcpu.4604?=?integer:?327host-resources-mib::hrswrunperfcpu.4606?=?integer:?121802host-resources-mib::hrswrunperfcpu.4609?=?integer:?357host-resources-mib::hrswrunperfcpu.4612?=?integer:?26host-resources-mib::hrswrunperfcpu.4619?=?integer:?102host-resources-mib::hrswrunperfcpu.4621?=?integer:?1880host-resources-mib::hrswrunperfcpu.4623?=?integer:?331host-resources-mib::hrswrunperfcpu.4625?=?integer:?25host-resources-mib::hrswrunperfcpu.4627?=?integer:?30host-resources-mib::hrswrunperfcpu.4628?=?integer:?3980host-resources-mib::hrswrunperfcpu.4630?=?integer:?92host-resources-mib::hrswrunperfcpu.4907?=?integer:?11139host-resources-mib::hrswrunperfcpu.5236?=?integer:?6host-resources-mib::hrswrunperfcpu.5385?=?integer:?3697但是现在的问题是如何通过这些数据计算某个进程的cpu占用率呢????如果这个方法无法计算,那么如何通过snmp远程得到远程主机上某个进程cpu的占用率呢???请教高手了!!!(前提是不可以自己定义oid,不可以自己在被监控端写脚本,只能在被监控端安装snmp。别的不可以添加。)|stat文件中的数据对应的utime和stime就是进程的用户态和内核态中运行的滴答数读/proc/pid/stat文件,然后把这两个值sscanf出来,这两个值的和除以统计间隔时间(用gettimeofday填充struct???timeval.tv_sec,取两次相差)就是该进程的cpu占有率|你在做什么项目?mas?linux系统是有查看cpu占用率的命令吗?如top,也有其它的。|不会,关注ing
收录时间:日 13:09:20 来源:互联网 作者:匿名
上一篇: &(&&)
创建分享人
喜欢此文章的还喜欢
Copyright by ;All rights reserved. 联系:QQ:IP 简单网络管理协议 (SNMP) 导致高 CPU 使用率
[an error occurred while processing this directive]
新闻与刊物
商业解决方案
网络解决方案
服务与支持
思科网络技术学院
培训、活动与会议
合作伙伴与代理商
中国:简体中文
TAC中文文档
原文件的链接(英语)
此文档是由人工智能自动翻译系统翻译的,请随时参考。
IP 简单网络管理协议 (SNMP) 导致高 CPU 使用率
     
     
     
     
     
本文如何在路由器解释排除高CPU利用率故障由于运行在路由器的SNMP引擎进程,特别是在低端路由器。
本文的读者应该有这些题目知识:
本文的信息根据运行Cisco IOS软件的路由器。
本文档中的信息都是在特定的实验室环境中的设备中创建的。 本文所引用的所有设备均采用原始 (缺省)配置。 如果您的网络处于活动状态,确保您了解所有命令的潜在影响。
有关文件规则的更多信息请参见“ Cisco技术提示规则”。
有时,象这样的消息也许出现于路由器控制台:
%SNMP-3-CPUHOG: Processing [chars] of [chars]
他们意味着SNMP代理程序在设备花些许多时间处理请求。
您在路由器能通过使用show process CPU命令的输出确定高CPU使用的原因。
以下示例显示show process CPU命令的输出。
cacuk#show process cpu
CPU utilization for five seconds: 0%/0%;
one minute: 0%;
five minutes: 0%
Runtime(ms)
OSPF Hello
Chunk Manager
Object ID (OID)或管理信息库的debug ip snmp命令检查(MIB)当时被查询。
注意: ?运行在生产网络的调试可能淹没路由器。
有二个可能原因为发生关于简单网络管理协议(SNMP)的高CPU利用率:
NMS工作站和ARP表轮询的大路由
轮询的某些MIB
网络管理站查询路由器为了他们的整个路由表能得知其他网络。 它使用此信息查找其他路由器和对网络他们的知识查询他们在他们附近。 以这种方式,管理站能了解整个网络的结构。
路由器在一种被切细的格式储存路由表,有助于快速路由搜索。 然而,要求路由的SNMP回应按字典顺序返回每RFC1213。 所以,为了路由器收到的每个SNMP请求,必须词典地排序散列表,在SNMP回应PDU可以被构件之前。 越大路由表,更多CPU intesive排序。
SNMP是低优先级进程,只要CPU调度程序,因此要求CPU资源的另一个进程采取优先级。 所以,而CPU峰值在此方案发生,他们不应该影响性能。
要避免性能问题,请强制路由器过早地结束查询为路由表从网络管理系统服务器。 请配置路由器回应与全部的消息,当接受一个要求的开始路由表,如下:
snmp-server view cutdown iso included
!--- ISO is used as a starting point as it is the snmp 'root'.
snmp-server view cutdown 1.3.6.1.2.1.4.21 excluded
snmp-server view cutdown 1.3.6.1.2.1.4.22 excluded
snmp-server view cutdown 1.3.6.1.2.1.3 excluded
snmp-server view cutdown 1.3.6.1.6.3.15 excluded
!--- The additional object snmpUsmMIB is excluded.
snmp-server view cutdown 1.3.6.1.6.3.16 excluded
!--- The additional object snmpVacmMIB is excluded.
snmp-server view cutdown 1.3.6.1.6.3.18 excluded
!--- The additional object snmpCommunityMIB is excluded.
snmp-server community public view cutdown RO
snmp-server community private view cutdown RW
注意: ?在上述示例中, 被排除, 被排除,并且被排除。 同时这些对象可以被用于获得关于被配置的用户和属性字段的信息获取管理访问到设备。 我们建议这些对象是从视图exlcluded在可以由公共用户获取的所有设备。
此配置拒绝请求检索路由表(ipRouteTable)和地址解析协议(ARP)表(ipNetToMediaTable),但是通过允许其他请求。 如果有Cisco IOS的更旧的版本? 软件,它不会认可MIB对象ipRouteTable,因此请使用以下配置:
snmp-server view cutdown iso included
!--- ISO is used as a starting point as it is the snmp 'root'.
snmp-server view cutdown 1.3.6.1.2.1.4.21 excluded
snmp-server view cutdown 1.3.6.1.2.1.4.22 excluded
snmp-server view cutdown at excluded
snmp-server view cutdown 1.3.6.1.6.3.15 excluded
!--- The additional object snmpUsmMIB is excluded.
snmp-server view cutdown 1.3.6.1.6.3.16 excluded
!--- The additional object snmpVacmMIB is excluded.
snmp-server view cutdown 1.3.6.1.6.3.18 excluded
!--- The additional object snmpCommunityMIB is excluded.
snmp-server community public view cutdown RO
snmp-server community private view cutdown RW
注意: ?在上述示例中, 被排除, 被排除,并且被排除。 同时这些对象可以被用于获得关于被配置的用户和属性字段的信息获取管理访问到设备。 我们建议这些对象是从视图exlcluded在可以由公共用户获取的所有设备。
在这两个示例中,您能替代您自己的属性字段。
这些配置结果是路由器不再返回ARP表或IP路由表,当查询。 这在路由器防止SNMP网络发现创建CPU峰值正在考虑中,但是从路由器也去除程度可管理性。
以前没有陈列CPU峰值的路由器可能开始如此执行,如果有在他们的路由表上的一个变化。 要求的相当数量循环回复IP路由表请求是路由的数量的功能在路由表里。 如果路由的数量增加, CPU利用率增加。
如果使用,一个变化做在Cisco IOS编码上允许SNMP查询Cisco express forwarding (CEF)表为路由项CEF交换。 这极大改进情况。 有CEF功能, SNMP代理程序回应一次得到next/get容量操作为路由或ARP表带有信息从转发信息库(FIB)。 FIB按字典顺序存储,并且排序不是需要的。 没有被启用的CEF, SNMP代理程序回应带有信息从路由信息库(RIB),必须排序到导致高CPU的字典命令。
跟随下面的Bug ID连接并且请参阅详细Bug信息。
(注册的用户) - CPU HOG通过SNMP被生成,当轮询路由表从网络管理站。
网络管理应用程序从设备频繁地检索信息使用SNMP。 一个示例是资源管理器基础(RME),应用程序在产品之内CiscoWorks 2000套件。 RME能检索在定义的闪存信息。 如果设备有一个ATA闪存盘,能造成CPU利用率跳。
跟随下面的Bug ID连接并且请参阅详细Bug信息。
(注册的用户)
要验证和应用解决方法,请遵从这些步骤:
验证设备是否有一张ATA闪存卡在其插槽之一中:
Router#show disk1:
******** ATA Flash Card Geometry/Format Info ********
ATA CARD GEOMETRY
Number of Heads:
Number of Cylinders
Sectors per Cylinder
Sector Size
Total Sectors
ATA CARD FORMAT
Number of FAT Sectors
Sectors Per Cluster
Number of Clusters
Number of Data Sectors 684117
Base Root Sector
Base FAT Sector
Base Data Sector
如果不是肯定的或,如果不得到输出为show diskx命令,请运行show tech命令并且执行搜索磁盘。
一旦知道您有一个ATA闪存盘,您在FLASH-MIB能应用以下解决方法防止SNMP查询:
Router(config)#snmp-server view &any_word& iso included
!--- ISO is used as a starting point as it is the snmp 'root'.
Router(config)#snmp-server view &any_word& ciscoFlashMIB excluded
!--- The additional object snmpUsmMIB is excluded.
Router(config)#snmp-server view &any_word& 1.3.6.1.6.3.15 excluded
!--- The additional object snmpVacmMIB is excluded.
Router(config)#snmp-server view &any_word& 1.3.6.1.6.3.16 excluded
!--- The additional object snmpCommunityMIB is excluded.
Router(config)#snmp-server view &any_word& 1.3.6.1.6.3.18 excluded
Router(config)#snmp-server community &read_community_string& view &any_word& ro
Router(config)#snmp-server community &write_community_string& view &any_word& rw
Router(config)#exit
注意: ?选择同一个词在每条线路为&any_word>在上述配置。
注意: ?在上述示例中, 被排除, 被排除,并且被排除。 同时这些对象可以被用于获得关于被配置的用户和属性字段的信息获取管理访问到设备。 我们建议这些对象是从视图exlcluded在可以由公共用户获取的所有设备。
验证它正确地实现:
Router#show run
snmp-server view &any_word& iso included
!--- ISO is used as a starting point as it is the snmp 'root'.
snmp-server view &any_word& ciscoFlashMIB excluded
snmp-server view &any_word& internet.6.3.15 excluded
!--- The additional object snmpUsmMIB is excluded.
snmp-server view &any_word& internet.6.3.16 excluded
!--- The additional object snmpVacmMIB is excluded.
snmp-server view &any_word& internet.6.3.18 excluded
!--- The additional object snmpCommunityMIB is excluded.
snmp-server community &write_community_string& view &any_word& RW
snmp-server community &read_community_string& view &any_word& RO
注意: ?&any_word>、&write_community_string>和&read_community_string>是在配置的那些。
注意: ?在上述示例中, 被排除, 被排除,并且被排除。 同时这些对象可以被用于获得关于被配置的用户和属性字段的信息获取管理访问到设备。 我们建议这些对象是从视图exlcluded在可以由公共用户获取的所有设备。
发出show proc cpu命令验证CPU设备为SNMP是否断开并且寻找IP_SNMP进程。
注意: ?Bug CSCdt97325在一些最新Cisco IOS版本也被修复了,因此请检查Bug有关所有详细资料。
其他Bug与轮询MIB有关:
跟随下面的Cisco Bug ID链路并且请参阅详细Bug信息。
(注册的用户) -轮询ATM子接口从设备返回CPU HOG消息。
(注册的用户) -闪存MIB做许多呼叫对ifs。
(注册的用户) -闪存MIB查询在7200暂停语音呼叫。
(注册的用户) - ciscoFlashPartitionEntry对象的问题在CISCO-FLASH-MIB。
(注册的用户) - 2500 snmpgetnext为某些SNMP对象原因跟踪。
(注册的用户) - SNMP轮询在闪存MIB在交换机导致高CPU利用率。
网络专业人士连接是网络专业人士的一个论坛,它共享网络解决方案、产品和技术的相关问题、建议和信息。 功能链路是此技术可用的一些最近的会话。
Net Pro论坛-专题对话为网络管理
网络结构: 网络管理
虚拟专用网络: 网络和策略管理
声明:此文档是由为思科 TAC 网页内容翻译所开发的英汉机器自动翻译系统翻译的。在有疑问或作出重要的技术支持决策时,请随时参考英文原文。Updated:
Aug 13, 2004Document ID: 7270
[an error occurred while processing this directive]
[an error occurred while processing this directive]如何获取当前进程的CPU使用率、内存使用率? - CNode技术社区
这家伙很懒,什么个性签名都没有留下。
初学使用nodejs开发web后台,需要频繁提供指定业务的CPU使用率、内存使用率,查看了NODE API和相关资料,虽有些眉目但感觉计算不准确。
CPU使用率:nodejs提供os.loadavg()可以获取系统的CPU使用率,和进程CPU使用率不一回事,搞不定;
内存使用率:目前想到的计算方式是用 process.memoryUsage().rss / os.totalmem() 来获取,这个不太准确rss没有包含交换区和fs中的内存使用;
请问下这块有没有其它靠谱的方式(比如开源库)来获取? 多谢
@所有关注者: 该问题后来采用定时子进程执行ps命令,并从输出中解析出内存、CPU使用率,效果不错,多谢各位。
process.memoryUsage()
:这个看api说明是只能取到进程的rss、hea内存信息
你可以用这个库:
这个有价值,谢谢
查看process的API。。。
来自炫酷的
通过执行外部命令总觉得不靠谱
实在不行用 C++ 撸个包吧
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
服务器赞助商为
,存储赞助商为
,由提供应用性能服务。
新手搭建 Node.js 服务器,推荐使用无需备案的}

我要回帖

更多关于 linux snmp cpu使用率 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信