How to get OIDs from a MIB file?
Asked Answered
L

4

16

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

I developed one tool to get some data from a SNMP enabled agent. I want to enhance that tool by showing all the OIDs form the manager's MIB file.

I am using the NET-SNMP library.

I saw the following:

/usr/local/share/snmp/mibs/ 

folder and it contains many MIB files, but how can I form a list of the OIDs it has?

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

I want to list all the OIDs as follows:

  1. SNMPv2-MIB::sysDescr.0 = .1.3.6.1.2.1.1.1.0
  2. 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 do I do this?

Lenhard answered 20/9, 2012 at 7:10 Comment(0)
O
13

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

-M "directory containing your MIB file"
-m ALL
-Pu
-Tso
Outofdoor answered 22/2, 2013 at 10:24 Comment(0)
U
10

After some problems I managed to generate the OIDs 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
Ugric answered 14/7, 2016 at 13:32 Comment(1)
Thank you. Module name example for Dell iDrac from the DCMIB65 package: DELL-RAC-MIBErnestineernesto
P
5

To pull the OIDs from a running SNMP server you might like to use the tool snmpwalk using the -Ci option . The tool comes with Net-SNMP.

Peddle answered 20/9, 2012 at 13:5 Comment(0)
P
1

The other two SO QAs show how you can do it without walking a running system:

That is only the starting point. There is a lot of coding ahead from there.

Update: The another nice tool is the perl SNMP compiler packaged in SNMP::MIB::Compiler. With a script in perl you get all the MIB elements/components pulled into internal data structures and you can pick any information from there, either by looking into the structure tree or by dumping the tree and do a post-parsing on the dump.

Puttier answered 15/10, 2012 at 23:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.