How can I get MIBs list from a remote server by using PHP?

让人想犯罪 __ 提交于 2019-11-26 23:41:22

问题


I am working on a project that involves SNMP. Basically I need to construct MIB and OID tree in PHP.

I know that there are programs that do this already, but I am trying to implement my own version to incorporate with my webapp.

What I know: I am familiar with php SNMP function. I can do SNMPWALk to get OIDs and such. Unfortunately there is no function that I know of that finds all MIBs and parses them.

What I need: Get all MIB docs first from remote server, then based on each docs get their Objects. At the end my tree will have this structure:

+ mib-doc1 |
           - obc1
           - obj2
+ mib-doc2 |
           - obj1
           - obj2
           - obj3

and so on...

I also know:

  1. From the actual server I can get all the MIB directories:

$net-snmp-config --default-mibdirs

  1. I can also get list of all MIB docs:

$snmpwalk -mALL -v1 cpublic ip

I have 2 questions.

  1. How can I get list of all MIB docs from a remote server?
  2. Is there an easier way (with known functions), to parse each MIB to get Objects?

Thanks


回答1:


If you just want a list of modules, see if your manager supports SNMPv2-MIB::sysORTable. This does not help you find the MIB files of course, but tells you what is supposed to be supported.

Quoting specs, sysORTable is:

"The (conceptual) table listing the capabilities of the local SNMP application acting as a command responder with respect to various MIB modules. SNMP entities having dynamically-configurable support of MIB modules will have a dynamically-varying number of conceptual rows."

Here is what I get for a standard Linux host :

snmptable -M +.  -m +ALL -v 2c -c public -Pu -Ci  <some ipaddr>  SNMPv2-MIB::sysORTable
SNMP table: SNMPv2-MIB::sysORTable

 index                                        sysORID                                              sysORDescr  sysORUpTime
     1          SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1         The MIB for Message Processing and Dispatching. 0:0:00:00.30
     2       SNMP-USER-BASED-SM-MIB::usmMIBCompliance         The MIB for Message Processing and Dispatching. 0:0:00:00.30
     3 SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance                   The SNMP Management Architecture MIB. 0:0:00:00.30
     4                            SNMPv2-MIB::snmpMIB                      The MIB module for SNMPv2 entities 0:0:00:00.30
     5                                TCP-MIB::tcpMIB         The MIB module for managing TCP implementations 0:0:00:00.30
     6                                     IP-MIB::ip The MIB module for managing IP and ICMP implementations 0:0:00:00.30
     7                                UDP-MIB::udpMIB         The MIB module for managing UDP implementations 0:0:00:00.30
     8        SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup               View-based Access Control Model for SNMP. 0:0:00:00.30


来源:https://stackoverflow.com/questions/25814634/how-can-i-get-mibs-list-from-a-remote-server-by-using-php

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