I am trying to get IPSLA data out of a Cisco router. While trying to use the most basic examples that I have come across online including the official documents from PySnmp. The error seems to be related to receiving negative or zero value objects from a query. I haven't been able to find ANY help on this, using their suggested fix hasn't helped.
When trying to execute a snmp query via PySnmp I am getting this error:
[billiam@nunya]$ python snmptests.py
Traceback (most recent call last):
File "snmptests.py", line 33, in <module>
cmdgen.MibVariable('CISCO-RTTMON-MIB', '1.3.6.1.4.1.9.9.42.1.2.10.1.1')
File "/usr/lib/python2.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 424, in getCmd
kwargs.get('contextName', null)
File "/usr/lib/python2.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 277, in getCmd
self.makeReadVarBinds(varNames),
File "/usr/lib/python2.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 201, in makeReadVarBinds
[ (x, self._null) for x in varNames ], oidOnly=True
File "/usr/lib/python2.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 209, in makeVarBinds
varName.resolveWithMib(self.mibViewController, oidOnly=True)
File "/usr/lib/python2.6/site-packages/pysnmp/entity/rfc3413/oneliner/mibvar.py", line 159, in resolveWithMib
self.__modName, self.__symName
File "/usr/lib/python2.6/site-packages/pysnmp/smi/builder.py", line 299, in importSymbols
self.loadModules(modName, **userCtx)
File "/usr/lib/python2.6/site-packages/pysnmp/smi/builder.py", line 259, in loadModules
'MIB module \"%s\" load error: %s' % (modPath, traceback.format_exception(*sys.exc_info()))
pysnmp.smi.error.SmiError: MIB module "/usr/lib/python2.6/site-packages/pysnmp/smi/mibs/CISCO-RTTMON-MIB.py" load error: ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.6/site-packages/pysnmp/smi/builder.py", line 255, in loadModules\n exec(modData, g)\n', ' File "<string>", line 246, in <module>\n', ' File "/usr/lib/python2.6/site-packages/pyasn1/type/univ.py", line 107, in clone\n return self.__class__(value, tagSet, subtypeSpec, namedValues)\n', ' File "/usr/lib/python2.6/site-packages/pyasn1/type/univ.py", line 22, in __init__\n self, value, tagSet, subtypeSpec\n', ' File "/usr/lib/python2.6/site-packages/pyasn1/type/base.py", line 69, in __init__\n self._verifySubtypeSpec(value)\n', ' File "/usr/lib/python2.6/site-packages/pyasn1/type/base.py", line 33, in _verifySubtypeSpec\n raise c(\'%s at %s\' % (i, self.__class__.__name__))\n', 'ValueConstraintError: ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(-2147483648, 2147483647)), ValueRangeConstraint(0, 2147483647)) failed at: "ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(-2147483648, 2147483647)) failed at: "ValueRangeConstraint(-2147483648, 2147483647) failed at: "140504945132592""" at InterfaceIndexOrZero\n']
snmptests.py
I have tried to use their listed "fix" for this error.
from pysnmp.proto import rfc1155, rfc1902, api
from pyasn1.codec.ber import encoder, decoder
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.smi import builder
# --- hack Counter type
def counterCloneHack(self, *args):
if args and args[0] < 0:
args = (0xffffffff+args[0]-1,) + args[1:]
return self.__class__(*args)
rfc1155.Counter.clone = counterCloneHack
rfc1902.Counter32.clone = counterCloneHack
cmdGen = cmdgen.CommandGenerator()
mibBuilder = cmdGen.snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder
mibSources = mibBuilder.getMibSources() + (
builder.DirMibSource('/usr/lib/python2.6/site-packages/pysnmp/smi/mibs'),
)
mibBuilder.setMibSources(*mibSources)
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('10.8.25.65', 161)),
cmdgen.MibVariable('CISCO-RTTMON-MIB', '1.3.6.1.4.1.9.9.42.1.2.10.1.1')
)
# Check for errors and print out results
if errorIndication:
print(errorIndication)
else:
if errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex)-1] or '?'
)
)
else:
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))