AgentX Tutorial using Net-SNMP – Trap implementation

Third one in this series is implementation of SNMP Traps, the method which is the main strength of SNMP. These Traps provide an event based system where NMS relies heavily on the monitored stations to tell them if something of interest has happened. mib2c again provides an easy way to implement traps. This is actually one of the easiest ones of the three in this series. Again as I said before clone my repository and checkout the code to find what was done and how. Following are three commands of interest.

git clone
git checkout step3_traps_autogenerated
git checkout step3_traps_implement

mib2c provides mib2c.notify.conf to compile the MIB and generate C code. By default it uses SNMPv2 for traps and I leave it as is. Implementation is as simple as copying the data into right variables when time comes and they will be delivered. Outgoing traps also require snmpd configuration to setup proper credentials and trapsinks which are usually the NMS or trap forwarding systems.

I use snmptrapd to capture and display the traps. But one can also use packet capture tools like tcpdump/wireshark/snoop.

So that's it for now. When time permits I will expand this further to provide a real-life application scenario. This code so far is Hello World quality and not exactly production ready.