Add support for traps #45
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Inspired by #22 but done completely differently. It is not using pdu so it is not affected by incompatibility introduced in Net-SNMP v5.8.
Function parameters are different and simplified. You can just send numeric trap for SNMPv1 or OID trap for SNMPv2c and SNMPv3.
Actual version of the trap is configured via snmpd.conf.
Variables are not send by raw values but must be encapsulated in variable type. This help serializing with already defined code.
To send trap, you can reuse already registred variables
Or send completely unrelated new value
Function
read_objid
is extracted, because it is used many times. This function can handle correctly numeric OID representations like".1.3.6.1.2.1.1.3.0"
so there is no need to reimplement this in python. This is the reason, why this part is heavily simplified.