Translating pysnmp oids to human readable strings

Shantanu Joshi weemadarthur at gmail.com
Mon Mar 9 01:03:32 EDT 2009


SpamMePlease PleasePlease <spankthespam at googlemail.com> writes:

> On Fri, Mar 6, 2009 at 2:14 PM, Shantanu Joshi <weemadarthur at gmail.com> wrote:
>>
>> SpamMePlease PleasePlease <spankthespam at googlemail.com> writes:
>>
> .. snip
> 
> The thing is that I have copied the file (as you may see, I did 'ls
> -lA' on it. If the file wasnt there, the error message was different.
> Also, the setMibPath doesent seem to work, as I tried to set up it to
> any value, and right after that I was performing getMibPath which was
> giving me unchanged default paths. Keep in mind, that whole path setu
> up code has executed without any error.
> So, what is correct and working way to supply my code with that
> converted mib file?

Works for me.

> [shantanu at tiamat:~/Documents/snmp]$ ls    
> AV-AES-MIB.mib
> [shantanu at tiamat:~/Documents/snmp]$ smidump AV-AES-MIB.mib -k > AV-AES-MIB.txt    
> smidump: module `AV-AES-MIB.mib' contains errors, expect flawed output
> [shantanu at tiamat:~/Documents/snmp]$ build-pysnmp-mib AV-AES-MIB.txt > AV-AES-MIB.py    
> [shantanu at tiamat:~/Documents/snmp]$ ls    
> AV-AES-MIB.mib  AV-AES-MIB.txt  AV-AES-MIB.py
> [shantanu at tiamat:~/Documents/snmp]$ sudo cp AV-AES.py /usr/lib/python2.5/site-packages/pysnmp/v4/smi/mibs/instances    
> [shantanu at tiamat:~/Documents/snmp]$ ls /usr/lib/python2.5/site-packages/pysnmp/v4/smi/mibs/instances    
> AV-AES-MIB.py         __SNMP-FRAMEWORK-MIB.py   __SNMP-MPD-MIB.pyc     __SNMP-USER-BASED-SM-MIB.py   __SNMP-VIEW-BASED-ACM-MIB.pyc  __init__.py
> __PYSNMP-USM-MIB.py   __SNMP-FRAMEWORK-MIB.pyc  __SNMP-TARGET-MIB.py   __SNMP-USER-BASED-SM-MIB.pyc  __SNMPv2-MIB.py                __init__.pyc
> __PYSNMP-USM-MIB.pyc  __SNMP-MPD-MIB.py         __SNMP-TARGET-MIB.pyc  __SNMP-VIEW-BASED-ACM-MIB.py  __SNMPv2-MIB.pyc
> [shantanu at tiamat:~/Documents/snmp]$ 
> [shantanu at tiamat:~/Documents/snmp]$ ipython    
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38) 
> Type "copyright", "credits" or "license" for more information.
> 
> IPython 0.8.4 -- An enhanced Interactive Python.
> ?         -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help      -> Python's own help system.
> object?   -> Details about 'object'. ?object also works, ?? prints more.
> 
> In [1]: from pysnmp.smi import builder, view
> 
> In [2]: mibBuilder = builder.MibBuilder().loadModules('AV-AES-MIB')
> 
> In [3]: mibViewController = view.MibViewController(mibBuilder)
> 
> In [4]: oid, label, suffix = mibViewController.getNodeName((1,3,6,1,4,1,6889,2,27,2,2,2))
> 
> In [5]: print oid 
> (1, 3, 6, 1, 4, 1, 6889, 2, 27, 2, 2)
> 
> In [6]: print label
> ('iso', 'org', 'dod', 'internet', 'private', 'enterprises', [...])
> 
> In [7]: print suffix
> (2,)
> 
> In [8]: 

I think you should check that the file you are generating is correct,
and can be read properly. If that doesn't help, you should try on the
pysnmp-users mailing list at http://sourceforge.net/mail/?group_id=14735. 



More information about the Python-list mailing list