[clug] pysnmp and decoding SNMP Traps
jeffm at ghostgun.com
Fri Jul 16 00:28:43 MDT 2010
On 16/07/10 1:14 PM, Carlo Hamalainen wrote:
> It's not immediately obvious to me which bit of output is what... can
> you show the output with this for loop?
Sorry about that. I've been staring at this for so long my eyes just
automatically pick it out. See the end of this email for dump with labels.
> for oid, val in varBinds:
> print 'oid:', oid.prettyPrint()
> print 'val:' val.prettyPrint()
> Is this of any use?
Yes, though it has left me with as many questions as I started with. I
think I've nutted abit of it out by running
% python -m pdb snmp2zabbix.py
listing until I found a suitable place to break. Inserting a break, via
the break command and then continuing to that point. I then import
objdump (the script you pointed to above) and did
I was using the getComponentByPosition() method as most of the examples
I'd seen used setComponentByPosition() and this was the logical inverse
operator. The dump how ever highlight the existence of a getComponent()
method. I can then work my way done the chain by calling this method and
end up with
this seems to work with all the values. Just need to find a way to
identify val with ObjectIdentifier as oppose to the timeticks, eg
I suppose using the oid would accomplish this. I'll wrap it all up in a
try..except so that if this fails it will then generate a different
alert message telling me I need to debug my code.
For anyone else suffering this problem,
SNMPTRAPOID = "22.214.171.124.126.96.36.199.4.1.0"
def process_trap(transportDispatcher, transportDomain, transportAddress,
for oid, val in varBinds:
oidstr = oid.prettyPrint()
if oid.prettyPrint() == SNMPTRAPOID:
trapoid = valstr
print "trap: ", trapoid, "text: ", " ".join(condenced)
trap: 188.8.131.52.184.108.40.206.220.127.116.11.1 text: 3371926499
21db5a35-49b3-41ee-e137-ef7f6528b4ff alert.ak.test A test alert has been
posted. AK-8000-LM alert Minor None.
More information about the linux