Reputation: 85
Is there any python modules for working with received NET-SNMP traps? I am not looking for the whole process of capturing SNMP trap with something like pysnmp, but just processing. Formatting values and maybe creating a json from received notification.
Upvotes: 0
Views: 2178
Reputation: 5555
Your original question was about pysnmp so I'm answering that. ;-)
A lot depends on what you mean by processing. With pysnmp you can build an app from two independent parts -- the capturing part and the formatting part.
For capturing you can take this script which gives you SNMP variable-bindings that come in the TRAP message. Once you get the var-bindings you can run them through the MIB lookup part which would produce human-friendly names for OIDs and prettily formatted values.
This should work out of the box except that for the MIB lookup to succeed you need to know and explicitly pre-load MIBs your agents implement (e.g. .loadModules()
call).
Transforming prettified OID-values into JSON seems trivial with Python's built-in json.dumps()
.
Upvotes: 1