Re: [pysnmp-users] Problem observed in new mib loading
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2016-12-15 08:56:23
|
Try adding `lookupNames=True`, `lookupValues=True` as shown here: http://pysnmp.sourceforge.net/examples/current/v3arch/oneliner/manager/cmdgen/getnext-v2c-with-mib-resolution.html <http://pysnmp.sourceforge.net/examples/current/v3arch/oneliner/manager/cmdgen/getnext-v2c-with-mib-resolution.html> But even better upgrade to the latest pysnmp and you could skip the explicit mibdump-based conversion step. http://pysnmp.sourceforge.net/examples/hlapi/asyncore/sync/manager/cmdgen/walking-operations.html <http://pysnmp.sourceforge.net/examples/hlapi/asyncore/sync/manager/cmdgen/walking-operations.html> > On 15 Dec 2016, at 07:11, <riv...@wi...> <riv...@wi...> wrote: > > Hi, > > I am trying to automate VM-MIB by using pysnmp. > > 1. Generated VM-MIB.py file from VM-MIB.txt by mibdump.py --debug=all --mib-borrower=/usr/share/snmp/mibs/ VM-MIB.txt > 2. Tried loadmib and addmibsource modules to load VM-MIB. > > Its loading the Object from VM-MIB as I am able to see the output but the MIB name is showing as SNMPv2-SMI. > Is it the right procedure to do or do we have any other process. > > #!/usr/bin/python > from pysnmp.entity.rfc3413.oneliner import cmdgen > > cmdGen = cmdgen.CommandGenerator() > > errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd( > cmdgen.CommunityData('public'), > cmdgen.UdpTransportTarget(('10.154.19.88', 161)), > #cmdgen.MibVariable('VM-MIB', 'vmEntry').loadmibs(), > lexicographicMode=True, maxRows=100, > ignoreNonIncreasingOid=True > ) > #print varBindTable > > # Check for errors and print out results > if errorIndication: > print(errorIndication) > else: > if errorStatus: > print('%s at %s' % ( > errorStatus.prettyPrint(), > errorIndex and varBindTable[int(errorIndex)-1] or '?' > ) > ) > else: > #for name, val in varBindTable: > #print('%s = %s' % (name.prettyPrint(), val.prettyPrint())) > #print (varBindTable[0][0].prettyPrint() +' = '+ varBindTable[0][1].prettyPrint()) > len_value= len(varBindTable) > output = open('template.txt','a') > for i in range(0,len_value): > output.write(varBindTable[i][0].prettyPrint()) > output.write("\n") > output.close() > > > > Getting this below output. > > > SNMPv2-SMI::mib-2.23456.1.4.1.2.2 = VM6 ----------- it should represent as VM-MIB instead of SNMPV2-SMI > SNMPv2-SMI::mib-2.23456.1.4.1.2.3 = VM1 > SNMPv2-SMI::mib-2.23456.1.4.1.2.4 = VM2 > SNMPv2-SMI::mib-2.23456.1.4.1.2.5 = VM3 > SNMPv2-SMI::mib-2.23456.1.4.1.2.6 = VM4 > > > > Thanks & Regards, > Riva. |