Translating pysnmp oids to human readable strings

rdmurray at bitdance.com rdmurray at bitdance.com
Sat Mar 7 14:33:37 EST 2009


SpamMePlease PleasePlease <spankthespam at googlemail.com> wrote:
> On Fri, Mar 6, 2009 at 2:14 PM, Shantanu Joshi <weemadarthur at gmail.com> wrote:
> >
> > SpamMePlease PleasePlease <spankthespam at googlemail.com> writes:
> >
> >> I actually tried to load the new file with following code:
> >>
> >> print builder.MibBuilder().getMibPath()
> >> mibBuilder = builder.MibBuilder().loadModules('jnx-bgpmib2')
> >>
> >> but I am experiencing the error:
> >>
> >> rivendell # python snmp.py
> >> ('/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances',
> >> '/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs')
> >> Traceback (most recent call last):
> >>   File "snmp.py", line 7, in ?
> >>     mibBuilder = builder.MibBuilder().loadModules('jnx-bgpmib2')
> >>   File "//usr/lib/python2.4/site-packages/pysnmp/v4/smi/builder.py",
> >> line 82, in loadModules
> >>     raise error.SmiError(
> >> pysnmp.smi.error.SmiError: MIB module
> >> "/usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances/jnx-bgpmib2.py"
> >> load error: MIB file ".py" not found in search path
> >> rivendell# ls -lA
> >> /usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances/jnx-bgpmib2.py
> >> -rw-r--r-- 1 root root 2687 Mar  6 06:50
> >> /usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances/jnx-bgpmib2.py
> >>
> >> Any clue what about is done wrong?
> >
> > The pysnmp library is not able to find your generated file. Either copy
> > your generated file to /usr/lib/python2.4/site-packages/pysnmp/v4/smi/mibs/instances
> > or call setMibPath on the mibBuilder instance before calling loadModules
> > to add the current directory (or whatever directory holds your generated
> > file).
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> 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?

I have absolutely no knowledge of pysnmp, but from reading the error
message I'd guess that you have a '.py' somewhere where you shouldn't.
Either the filename shouldn't have a .py, or you are referring to
the thing to be loaded with a '.py' on the end of the name when you
should be omitting it.

But like I said, I'm speaking out of my hat here, since I've never
worked with pysnmp.

--RDM




More information about the Python-list mailing list