Re: [pysnmp-users] Problem observed in new mib loading
Brought to you by:
elie
From: <riv...@wi...> - 2016-12-15 11:17:31
|
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. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com |