SNMP - Getting information from a process

我与影子孤独终老i 提交于 2019-12-05 23:17:12

What you need is to query the hrSWRunTable in order to gather the information you need. This MIB gives you a lot of information such as process name, path, type, status, parameters, CPU and RAM usage even though those two informations are stored on another MIB (hrSWRunPerfEntry). However how you do that "query" depends on the environment you're using, I am almost sure that vbs includes an SNMP library.

I was just working on the same thing

snmpwalk -v2c -c public xxx.xxx.xxx.xxx .1.3.6.1.2.1.25.4.2.1.2

HOST-RESOURCES-MIB::hrSWRunName

Here is a example retrieval via NetSnmp from a Linux host. (I would have added this as a comment on the accepted answer from @raz3r, but I wanted ability to format the text!)

 snmptable -v2c -Ci -c public myserver  HOST-RESOURCES-MIB::hrSWRunTable
SNMP table: HOST-RESOURCES-MIB::hrSWRunTable

 index hrSWRunIndex       hrSWRunName               hrSWRunID                        hrSWRunPath                                                                                                                  hrSWRunParameters hrSWRunType hrSWRunStatus
     1            1            "init" SNMPv2-SMI::zeroDotZero                       "/sbin/init"                                                                                                                                 "" application      runnable
     2            2        "kthreadd" SNMPv2-SMI::zeroDotZero                         "kthreadd"                                                                                                                                 "" application      runnable
     3            3     "ksoftirqd/0" SNMPv2-SMI::zeroDotZero                      "ksoftirqd/0"                                                                                                                                 "" application      runnable
 // other rows snipped for brevity 

Unfortunately, I wasn't able to find out exactly how to do this. I ended up going with a vbs script on each machine to find the misbehaving process and kill it automatically.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!