Translating pysnmp oids to human readable strings

Shantanu Joshi weemadarthur at
Fri Mar 6 09:03:24 CET 2009

SpamMePlease PleasePlease <spankthespam at> writes:

> On Fri, Mar 6, 2009 at 6:56 AM, Shantanu Joshi <weemadarthur at> wrote:
>> You need to parse the MIB file to get the human-readable names
>> corresponding to the OIDs. The pysnmp library already provides this
>> functionality. I haven't used this feature myself (I mainly use pysnmp
>> to automate SNMP walk requests, like the one in your code), but the
>> documentation at found the below example at
>>>>> from pysnmp.smi import builder, view
>>>>> mibBuilder = builder.MibBuilder().loadModules('SNMPv2-MIB')
>>>>> mibViewController = view.MibViewController(mibBuilder)
>>>>> oid,label,suffix = mibViewController.getNodeName((1,3,6,1,2,'mib-2',1,'sysDescr'))
>>>>> print oid
>> (1, 3, 6, 1, 2, 1, 1, 1)
>>>>> print label
>> ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'system', 'sysDescr')
>>>>> print suffix
>> ()
>> --
> Yes, I have seen that, but I cant get it working as expected (or it
> doesent to what expected at all). I cant make it return values like:
> jnxBgpM2PeerIdentifier.0.ipv4. (the one
> of many I got from snmpwalk) but instead I am getting bunch of words
> like iso, internet, mgmt, which is no way close to desired effect.
> Still no luck - anybody with a clue?

Every node in a MIB file is rooted at 
jnxBgpM2PeerIdentifier has OID . 
(if I've got the right MIB, I searched for jnxBgpM2PeerIdentifier on 
Google and got the BGP4-V2-MIB-JUNIPER MIB file). The .
corresponds to, so you can
safely skip that part. The next value 2636, is uniquely assigned to 
Juniper, and the rest is up to whatever scheme Juniper uses to prepare 

The pysnmp library doesn't know anything about BGP4-V2-MIB-JUNIPER MIB,
since it is not one of the standard MIBS, so it will parse everything up
to what is defined in the standard mibs and return the rest in numeric
form. There was a paragraph on the page I linked which described how to
prepare MIB files for consumption by pysnmp. Did you try that? 

More information about the Python-list mailing list