ich verwende ein Script, welches mehrere IP's im Multithread-Verfahren nach dem Ping- und einer SNMP-OID abfragt. Anscheinend eher willkürlicher erhalte ich oftmals auf einzelne Threads kein gültiges Ergebnis und wird mir folgender Fehlercode ausgespuckt:
Meine Methode für die SNMP-Abfrage sieht wie folgt aus:Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "python/scan.py", line 64, in run
self.snmp = self.check_snmp(self.ip)
File "python/scan.py", line 82, in check_snmp
'1.3.6.1.2.1.1.1.0'
File "build/bdist.linux-x86_64/egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 370, in getCmd
kwargs.get('contextName', null)
File "build/bdist.linux-x86_64/egg/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 210, in getCmd
contextEngineId, contextName
File "build/bdist.linux-x86_64/egg/pysnmp/entity/rfc3413/cmdgen.py", line 329, in sendReq
(self.processResponsePdu, (cbFun, cbCtx))
File "build/bdist.linux-x86_64/egg/pysnmp/entity/rfc3413/cmdgen.py", line 231, in _sendPdu
cbCtx
File "build/bdist.linux-x86_64/egg/pysnmp/proto/rfc3412.py", line 155, in sendPdu
sendPduHandle
File "build/bdist.linux-x86_64/egg/pysnmp/proto/mpmod/rfc2576.py", line 64, in prepareOutgoingMessage
pdu.tagSet, pdu, verifyConstraints=False
File "build/bdist.linux-x86_64/egg/pyasn1/type/univ.py", line 874, in setComponentByType
idx = self._componentType.getPositionByType(tagSet)
File "build/bdist.linux-x86_64/egg/pyasn1/type/namedtype.py", line 68, in getPositionByType
raise error.PyAsn1Error('Type %s not found' % (tagSet,))
PyAsn1Error: Type TagSet(Tag(tagClass=128, tagFormat=32, tagId=0)) not found
Code: Alles auswählen
def check_snmp(self, ip):
command_generator = cmdgen.CommandGenerator()
error_indication, error_status, _, var_binding = command_generator.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget((ip, 161), timeout=1, retries=0),
'1.3.6.1.2.1.1.1.0'
)
if error_indication or error_status:
return 'no snmp'
else:
return var_binding[0][1]
Hat vielleicht jemand eine Ahnung, woran das liegen könnte?