Re: [pysnmp-users] Problem observed in new mib loading
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2016-12-15 11:40:22
|
Looking at VM-MIB, I do not see vmNumber object there: http://mibs.snmplabs.com/asn1/VM-MIB Do you have a newer MIB? Also, given you query an existing object, you should query MIB object rather than MIB object instance: ObjectType(ObjectIdentity('VM-MIB', 'vmNumber', 0).addAsn1MibSource('file:///usr/share/snmp', 'http://mibs.snmplabs.com/asn1/@mib@'))) On 12/15/2016 12:17 PM, riv...@wi... wrote: > Hi, > > > > I have tried this below one. > > > > #!/usr/bin/python > > from pysnmp.hlapi import * > > > > errorIndication, errorStatus, errorIndex, varBinds = next( > > getCmd(SnmpEngine(), > > CommunityData('public'), > > UdpTransportTarget(('10.154.19.88', 161)), > > ContextData(), > > ObjectType(ObjectIdentity('VM-MIB', > 'vmNumber').addAsn1MibSource('file:///usr/share/snmp', > > > 'http://mibs.snmplabs.com/asn1/@mib@'))) > > ) > > > > if errorIndication: > > print(errorIndication) > > elif errorStatus: > > print('%s at %s' % (errorStatus.prettyPrint(), > > errorIndex and varBinds[int(errorIndex) - 1][0] > or '?')) > > else: > > for varBind in varBinds: > > print(' = '.join([x.prettyPrint() for x in varBind])) > > > > > > VM-MIB::vmNumber = No Such Object currently exists at this OID > > > > Thanks & Regards, > > Riva. > > > > *From:*Rivarani Roy > *Sent:* Thursday, December 15, 2016 3:48 PM > *To:* 'Ilya Etingof' <il...@gl...> > *Cc:* pys...@li... > *Subject:* RE: [pysnmp-users] Problem observed in new mib loading > > > > Hi, > > > > I followed the below steps but got the same result. > > Currently using the latest pysnmp but didn’t get any success. > > > > Thanks & Regards, > > Riva. > > > > *From:*Ilya Etingof [mailto:il...@gl...] > *Sent:* Thursday, December 15, 2016 2:26 PM > *To:* Rivarani Roy <riv...@wi... <mailto:riv...@wi...>> > *Cc:* pys...@li... > <mailto:pys...@li...> > *Subject:* Re: [pysnmp-users] Problem observed in new mib loading > > > > ** This mail has been sent from an external source ** > > 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 > > > > 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 > > > > > > On 15 Dec 2016, at 07:11, <riv...@wi... > <mailto:riv...@wi...>> <riv...@wi... > <mailto: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. > |