next up previous contents
Next: The Net-SNMP C API Up: Trap Handlers Previous: A Simple Trap Handler   Contents

Starting the Trap Daemon

The trap daemon needs to be started explicitly in order to listen for traps. It can be started in whichever method your OS prefers (/etc/rc.local or an initscript). You can pass a variety of arguments to the daemon, such as a list of MIBs to be used (-m) or tell it to run in the foreground for debugging purposes (-f).

Here is an example init script:


case "$1" in
        [ -f /usr/local/share/snmp/mibs/extreme620.mib ] || exit 0

        /usr/local/sbin/snmptrapd -m /usr/local/share/snmp/mibs/extreme620.mib -n
        pkill snmptrapd
        echo "Usage: $0 { start | stop }"
        exit 1
exit 0

In this case the script ensures that the required MIB is present before starting the trap daemon. -m specifies the MIB (or list of MIBs) for the trap daemon to use and -n specifies that source addresses should not be translated into hostnames.