Zabbix can be used to capture and log snmp traps. This is done by using a net-snmp-based snmp-trap daemon and a short handler script for received snmp traps.
This documentation is for zabbix >= 1.4.4 (or even >= 1.4). The snmp trap-handling there is different as in former versions. (The options for zabbix_sender have been changed for instance)
Install the package snmpd:
apt-get update && apt-get install snmpd
Configure Debian's default options for snmpd in /etc/default/snmpd and change
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
to
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid'
and
TRAPDRUN=no
to
TRAPDRUN=yes
Now, copy the trap handler perl script here to your zabbix-installation's bin-directory and add it to the list of trap handlers in /etc/snmp/snmptrapd.conf:
traphandle default <your zabbix-installation>/bin/snmptrap.pl
Then restart snmpd:
/etc/init.d/snmpd restart
The trap-daemon should be running and handling snmp traps now.
The perl-script located here will be our traphandler. Download it and put it in your zabbix's bin-directory (<your zabbix-installation>/bin/snmptrap.pl). Then you have to configure it:
Sadly zabbix currently doesn't support specifying a hostname or an ip-address when using zabbix_sender, one can only set the name of the host in zabbix. So there has to be a mapping between the received hostname or ip-address from the trap and the name of the host in zabbix.
There are a few options available here by configuring $mapping_method and (optionally) $mapping_option:
Besides these options you can use a mapping file ($mapping_method = “mapfile”) like this:
duffy.mydomain.com:firstserver tweety.mydomain.com:secondserver
This way, the received hostname “duffy.mydomain.com” will be mapped to the name “firstserver” in zabbix. Put the filename of the mapping file into $mapping_option.
The same can be achieved for the ip addresses by using $mapping_method = “mapfile_ip”.
The traphandler below supports sending snmp trap information to host's items in zabbix or to a so-called wildcard-host. When a host, for which a trap is received doesn't exist in zabbix or any other error should occur, the trap is send to the wildcard-host.
Add a new template for the snmptraps-item, then add the snmptraps-item to it. Use this configuration for the new item:
After that create a wildcard host or use another existent host (I've used the zabbix server itself) and add the new template to it. Then you can add the template to other existent hosts, which could probably send snmptraps.