Required package SNMPTT
1. Install the snmptt program on the nagios master server.
2. Enable snmptrapd. The snmptrapd.conf contains this line:
traphandle default /usr/sbin/snmptt
It makes all trap go to snmptt for processing.
3. config snmptt by editing the /etc/snmp/snmptt.ini file.
4. Define what actions to take (what program to run) in /etc/snmp/snmptt.conf. For details, please look at sample config and documentation. In short the snmptt.conf file is created by using the snmpttconvertmib program. After the conf is created, we edit it to make it suitable for nagios; only the EVENT and EXEC is important for our config method.
Because the hostname in nagios config is not FQDN, so we need to hardcode the hostname to ip address mapping in /etc/hosts, like this:
1.2.3.4 host1 5.6.7.8 host2
To make Windows to send snmp trap: go to services in control panel, open the snmp service, open the traps tab, enter the community and trap destinations. The community can be anything, eg. 'public', the trap destinations should be the nagios master server.
To make linux to send snmp trap, add these lines to /etc/snmp/snmpd.conf:
# where to send v2 traps: trap2sink nagios.example.com public # send traps on authentication failures authtrapenable 1