How to get OID from a MIB file?

I want to read all the objects from the MIB file that the manager has.

I developed one tool to get some data from an agent that supports SNMP. I want to improve this tool by showing all OIDs from the manager MIB file.

I am using the NET-SNMP library.

I saw the following:

/usr/local/share/snmp/mibs/ 

and contains a lot of MIB files, but how can I make an OID list that it has?

I went through the MIB and saw the structures, but how to get the OIDs of each object mentioned in the MIB files?

I want to list all OID as follows:

  • SNMPv2-MIB::sysDescr.0 = .1.3.6.1.2.1.1.1.0
  • SNMPv2-MIB::sysObjectID.0 = .1.3.6.1.2.1.1.2.0 ... etc.

I want to scan all the MIB files and find all the OIDs from the files.

How to do it?

+8
snmp mib net-snmp
source share
4 answers

Use the snmptranslate command from the net-snmp library. Try it with the following parasites:

 -M "directory containing your MIB file" -m ALL -Pu -Tso 
+9
source share

To pull the OID from a running SNMP server, you can use the snmpwalk tool with the -Ci . The tool comes with Net-SNMP .

+5
source share

After some problems, I was able to generate the OID using the following command.

 snmptranslate -Pu -Tz -M ~/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp:`pwd` -m module_name_NOT_file_name > module_name.oid 
+4
source share

The other two SO QAs show how you can do this without skipping a running system:

  • " sample net-snmp code for parsing a MIB file and extracting information about binding to it ": answer shows the top-level structure of the C analyzer, which is based on the top of the Net-SNMP library.

  • " Get the OID type (syntax) from the MIB using the Net-SNMP API : This is a specific function for handling OID.

This is just a starting point. There is a lot of coding ahead.

Update. Another good tool is the Perl SNMP compiler, packaged in SNMP :: MIB :: Compiler. Using the script in perl, you get all the MIB elements / components inserted into the internal data structures, and you can select any information from there either by searching in the structure tree, or by dumping the tree, or after parsing on the dump,

+1
source share

All Articles