Translating pysnmp oids to human readable strings

Shantanu Joshi weemadarthur at gmail.com
Fri Mar 6 00:56:48 EST 2009


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 
http://pysnmp.sourceforge.net/docs/4.1.x/index.html#MIB-SERVICES.


>>> 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
()



More information about the Python-list mailing list