MIB lookup tool¶
The snmptranslate.py tool can look up MIB object information at MIB by OID or vice versa. This tool does not require a SNMP agent to operate – it just loads up MIB module(s) and performs the requested lookup.
Its usage is tightly aligned with its Net-SNMP prototype.
Command line syntax is as follows:
snmptranslate.py [options] <mib-object [mib-object […]]>
Options always start with dash (-), other parameters are positional.
Options can be categorized by the part they are tackling e.g.
- MIB modules
- input/output formatting
Past these named options, mandatory positional parameters follow:
MIB options¶
Pre-load MIBs¶
You may want to pre-load some of the MIB modules to let the snmptranslate.py tool rendering SNMP responses in a more meaningful way.
The -m option specifies a colon separated list of MIB modules (not files) to load. The snmptranslate.py tool will first try to find pre-compiled pysnmp MIB files (by default in ~/.pysnmp/mibs in UNIX), then try to find required ASN.1 MIB file on local filesystem or on Web (by default it will look it up at http://mibs.snmplabs.com/asn1/). If ASN.1 MIB file is found, it will be compiled into pysnmp form and cached for future use.
The special keyword ALL is used to load all pre-compiled pysnmp MIB modules in the MIB directory search list.
MIB files search path¶
The -M option specifies a colon separated list of local directories and/or URLs pointing to remote HTTP/FTP servers where to search for MIBs.
Note
Default MIB search path is http://mibs.snmplabs.com/asn1/
Input options¶
The following one-letter options following the -I option modify the way how snmptranslate.py tool processes its input.
Interpret DISPLAY-HINT¶
The -Ih option disables snmptranslate.py’s attempt to parse input value or index as a DISPLAY-HINT-rendered value.
Output options¶
The following one-letter options following the -O option modify snmptranslate.py tool’s output.
Equal sign and type information¶
The -Oq option removes the equal sign (=) and SNMP value type information from the variable-binding being reported on stdout.
$ snmpget.py -v2c -c public -Oq snmpsim.try.thola.io sysDescr.0
SNMPv2-MIB::sysDescr.0 Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
$
$ snmpget.py -v2c -c public snmpsim.try.thola.io sysDescr.0
SNMPv2-MIB::sysDescr.0 = DisplayString: Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
Type information¶
The -OQ option removes the SNMP value type information from the variable-binding being reported on stdout.
$ snmpget.py -v2c -c public -OQ snmpsim.try.thola.io sysDescr.0
SNMPv2-MIB::sysDescr.0 = Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
$
$ snmpget.py -v2c -c public snmpsim.try.thola.io sysDescr.0
SNMPv2-MIB::sysDescr.0 = DisplayString: Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
Managed object path¶
The -Of option prints out the full path of the managed object in the MIB tree rather than MIB name and MIB object name (the default).
$ snmpget.py -v2c -c public -Of snmpsim.try.thola.io sysDescr.0
iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0 = DisplayString: Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
Managed object name¶
The -Os option prints out just managed object name (excluding MIB name) rather than MIB name and MIB object name (the default).
$ snmpget.py -v2c -c public -Os snmpsim.try.thola.io sysDescr.0
sysDescr.0 = DisplayString: Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
Raw OID¶
The -On option prints out the raw object identifier (OID) rather than human friendly MIB object name:
$ snmpget.py -v2c -c public -On snmpsim.try.thola.io sysDescr.0
1.3.6.1.2.1.1.1.0 = DisplayString: Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016 i686
Numeric enumerations¶
The -Oe option disables symbolic labels rendering for the enumeration values:
$ snmpget.py -v2c -c public -On snmpsim.try.thola.io IF-MIB::ifAdminStatus.1
1.3.6.1.2.1.2.2.1.7.1 = Integer32: 'up'
$
$ snmpget.py -v2c -c public -Oe snmpsim.try.thola.io IF-MIB::ifAdminStatus.1
IF-MIB::ifAdminStatus."1" = Integer32: 1
Break down table index¶
The -Ob option disables interpreting SNMP table indices and renders just raw OID instead:
$ snmpget.py -v2c -c public -Ob snmpsim.try.thola.io TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389"
TCP-MIB::tcpConnState.195.218.254.105.45632.10.105.41.179.3389 = Integer32: 'established'
$
$ snmpget.py -v2c -c public snmpsim.try.thola.io TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389"
TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389" = Integer32: 'established'
Escape table index quotes¶
The -OE includes extra escaped quotes surrounding SNMP table index parts. This can be useful when UNIX shell is in the processing pipeline.
$ snmpget.py -v2c -c public -OE snmpsim.try.thola.io TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389"
TCP-MIB::tcpConnState.\"195.218.254.105\".\"45632\".\"10.105.41.179\".\"3389\" = Integer32: 'established'
Brackets around table indices¶
The -OX option surrounds SNMP table index parts with square brackets instead of quotes (default):
$ snmpget.py -v2c -c public -OX snmpsim.try.thola.io TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389"
TCP-MIB::tcpConnState.[195.218.254.105].[45632].[10.105.41.179].[3389] = Integer32: 'established'
Hexified values¶
The -OT option ensures that rendered values are always in hex:
$ snmpget.py -v2c -c public -OT snmpsim.try.thola.io sysName.0
SNMPv2-MIB::sysName.0 = DisplayString: 6e 65 77 20 73 79 73 74 65 6d 20 6e 61 6d 65
$
$ snmpget.py -v2c -c public snmpsim.try.thola.io sysName.0
SNMPv2-MIB::sysName.0 = DisplayString: new system name
Rendering just values¶
The -Ov option removes managed object name from the rendered output:
$ snmpget.py -v2c -c public -Ov snmpsim.try.thola.io sysName.0
DisplayString: new system name
Units rendering¶
The -OU option disables units rendering:
$ snmpget.py -v2c -c public snmpsim.try.thola.io TCP-MIB::tcpRtoMin.0
TCP-MIB::tcpRtoMin.0 = Integer32: 200 milliseconds
$
$ snmpget.py -v2c -c public -OU snmpsim.try.thola.io TCP-MIB::tcpRtoMin.0
TCP-MIB::tcpRtoMin.0 = Integer32: 200
Raw timeticks¶
The -Ot option disables TimeTicks values interpretation so that raw values get rendered:
$ snmpget.py -v2c -c public -Ot snmpsim.try.thola.io SNMPv2-MIB::sysORLastChange.0
SNMPv2-MIB::sysORLastChange.0 = TimeStamp: 143145968
$
$ snmpget.py -v2c -c public snmpsim.try.thola.io SNMPv2-MIB::sysORLastChange.0
SNMPv2-MIB::sysORLastChange.0 = TimeStamp: 16 days 13:37:44.82
Debugging options¶
Release information¶
The -V flag reports version information for the snmptranslate.py tool and its underlying libraries.
Debug mode¶
The -d option prints out raw SNMP packets in hex.
The -D option lets you debug one or more specific SNMP sub-systems. The required argument can be one or more (comma-separated) tokens:
- io - report input/output activity and raw data being exchanged
- dsp - report high-level SNMP engine operation
- msgproc - report SNMP message processing subsystem operation
- secmod - report SNMP security subsystem operation
- mibbuild - report MIB files loading and processing
- mibview - report MIB browser initialization and operation (manager role MIB use)
- mibinstrum - report MIB instrumentation operation (agent role MIB use)
- acl - report MIB access control subsystem operation
- proxy - report built-in SNMP proxy operation
- app - report SNMP standard application operation
- all - all of the above (verbose!)
You can also negate the token by prepending it with the ! sign.
MIB objects specification¶
The rest of positional parameters specify SNMP managed objects to work on. Each object can be either:
- [MIB-name::]object-name[.index[.index]…]
- MIB-name
- object-identifier
When MIB name or object-name is referenced, the snmptranslate.py tool will try to locate and load the corresponding MIB module. The OID specification does not require MIB access.
$ snmptranslate.py TCP-MIB::tcpRtoMin.0
TCP-MIB::tcpRtoMin.0
$
$ snmptranslate.py 1.3.6.1.2.1.6.2.0
SNMPv2-SMI::mib-2.6.2.0
$
$ snmptranslate.py -m TCP-MIB 1.3.6.1.2.1.6.2.0
TCP-MIB::tcpRtoMin.0
$
$ snmptranslate.py TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389"
TCP-MIB::tcpConnState."195.218.254.105"."45632"."10.105.41.179"."3389"
If only MIB name is given, the first MIB object in that MIB will be taken as object name:
$ snmptranslate.py TCP-MIB::
TCP-MIB::tcp
You can look up many MIB objects by specifying them all at the command line:
$ snmptranslate.py -On SNMPv2-MIB::sysName.0 SNMPv2-MIB::sysLocation.0
1.3.6.1.2.1.1.5.0
1.3.6.1.2.1.1.6.0