Trap handlers can be written in any language you prefer, but for this document we'll use PERL.

At least 3 lines of input will be handed to your trap handler via STDIN, in addition to any arguments you
passed to it in your snmptrapd.conf. The first line of input is the hostname (if it can not
be resolved it will use the IP address). The second line of input is the IP address.
All remaining lines of input will be the data passed by the trap.

Traps will pass in a list of OIDs with their values (elsewhere called a VARBIND or VarList), one per line.
It is best to handle this list by simply pushing the values onto an array for later processing.

Basic trap handlers like this one are a useful starting point for building more complex trap handlers.
By parsing the incoming traps and also using arguments passed to the handler based on the trap OID
in the configuration file you can build complex trap handling routines to report problems, investigate
them, or even respond to them if you have a strong stomach. Because of the large amount of
parsing done when processing traps it is recommended that languages with strong string manipulation
abilities such as PERL, Python or Ruby are used.