[pysnmp-users] SNMP MIB resolution issue
Brought to you by:
elie
From: Brett K. <bre...@gd...> - 2017-02-20 22:39:07
|
I am running the latest version of PySNMP (4.3.3) and am having issues with my OIDs not consistently converting to friendly format. Here is an example of pulling values from the following oids: oids = [ ObjectType(ObjectIdentity('IF-MIB', 'ifInOctets')), ObjectType(ObjectIdentity('IF-MIB', 'ifOutOctets')) ] There are no issues retrieving the values from all my devices using nextCmd. When I go to convert the OIDs received back to friendly text, I am getting intermittent results. For simplicity, here is an example of what I've tried: # results is a list of tuples, [(ip, varbinds),...] for device in results: outfile = open(device[0], 'w+') for varbinds in device[1]: outfile.write(' = '.join([x.prettyPrint() for x in varbinds])) outfile.write('\n') outfile.close() This produces a dump of all the bytes in/out for all the interfaces on a device. Here's where things go wrong - when I execute my code, sometimes devices will display the friendly text properly, and sometimes they will not. If the translation fails, it fails for all the varbinds on the device. If it succeeds, they are all correct. Over multiple executions, devices will either be correct or incorrect, seemingly randomly. Here is a sample of correct vs. incorrect output. right - ('IF-MIB', 'ifInOctets', (InterfaceIndex(16875520),)) - wrong - ('SNMPv2-SMI', 'mib-2', (ObjectName('2.2.1.10.16875520'),)) Here is a sampling of runs against devices, and their failues: Nope 10.128.109.11 10.128.109.11 10.128.109.11 Nope 10.128.109.11 10.128.109.12 Nope 10.128.109.12 Nope 10.128.109.12 10.128.109.12 10.128.11.168 10.128.11.168 10.128.11.168 Nope 10.128.11.168 Nope 10.128.11.2 Nope 10.128.11.2 10.128.11.2 Nope 10.128.11.2 10.128.11.3 10.128.11.3 10.128.11.3 10.128.11.3 In all cases the underlying OID is correct - it's simply the translation that is failing. I have tried to assign MIB sources either with addAsn1MibSource() or just addMibSource() as well as playing around with the getMibSymbol() function. I would accept that I am simply doing something wrong, but the intermittent nature of this working/not working has me thinking there's something else going on. Any advice? Thanks in advance! Brett |