-->

How can I get MIBs list from a remote server by us

2019-01-15 23: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