On Fri, Mar 6, 2009 at 11:37 AM, SpamMePlease PleasePlease <spankthes...@googlemail.com> wrote: > On Fri, Mar 6, 2009 at 9:03 AM, Shantanu Joshi <weemadart...@gmail.com> wrote: >> >> SpamMePlease PleasePlease <spankthes...@googlemail.com> writes: >> >>> On Fri, Mar 6, 2009 at 6:56 AM, Shantanu Joshi <weemadart...@gmail.com> >>> 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 >>>> 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 >>>> () >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >>> 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.38.101.161.119.1.38.101.161.118 (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 iso.org.dod.internet. >> jnxBgpM2PeerIdentifier has OID .1.3.6.1.4.1.2636.5.1.1.2.1.1.1.1 >> (if I've got the right MIB, I searched for jnxBgpM2PeerIdentifier on >> Google and got the BGP4-V2-MIB-JUNIPER MIB file). The .1.3.6.1.4.1 >> corresponds to iso.org.dod.internet.private.enterprises, 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 >> mibs. >> >> 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? >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > Thats a good one, sir! I managed to create jnx-bgpmib2.py out from > /usr/share/snmp/mibs/jnx-bgpmib2.txt that contains the mibs snmpwalk > found for me. Now, in what way can I 'feed' the pysnmp with this new > file and how to ask it kindly to convert these number strings into > nice readable strings? > > -- > -------------------- > Spank The Spam! >
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? -- -------------------- Spank The Spam! -- http://mail.python.org/mailman/listinfo/python-list