nagios Red hat linux

Send SNMP Traps from Nagios to Remote Management Host

1. Add ‘send snmp trap’ command to nagios

vim /usr/local/nagios/etc/objects/commands.cfg
define command{
   command_name send_snmptrap
   command_line /usr/bin/snmptrap -v 2c -c public 10.50.24.34 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$HOSTNAME$" nSvcDesc s "$SERVICEDESC$" nSvcStateID i $SERVICESTATEID$ nSvcOutput s "$SERVICEOUTPUT$"
        }

2. Add this event and enable the event to services which needed to send traps

vim /usr/local/nagios/etc/objects/localhost.cfg
define service{
        use                             local-service         ; Name of service template to use
        host_name                       DB2
        service_description             Current Users
        event_handler                   send_snmptrap
        event_handler_enabled           1
        check_command                   check_local_users!20!50
        }

3. Untar the Nagios MIB file and copy the MIBs to snmp directory on Nagios Host

tar -zxvf /opt/nagiosmib-1.0.0.tar.gz
cp MIB/NAGIOS* /usr/share/snmp/mibs/

4. Also management host must have the Nagios MIBs (We are going to test using another linux machine which having SNMP installed)

tar -zxvf /opt/nagiosmib-1.0.0.tar.gz
cp MIB/NAGIOS* /usr/share/snmp/mibs/

5. Configure snmptrapd for listen incoming traps

vim /etc/snmp/snmptrapd.conf
authCommunity   log,execute,net    
-------------------------------------------------------
EX:
authCommunity   log,execute,net    public

6. Start Snmptrapd for listen incoming traps

/usr/sbin/snmptrapd -m ALL -M /usr/share/snmp/mibs -Lf /var/log/snmptrapd.log

7. Restart Nagios

/etc/init.d/nagios restart

8. Check traps using below command
Management Host – tails -f /var/log/snmptrapd.log
Management Host – tcpdump port 162
Nagios Host – tcpdump dst and port 162

Resources :
Sample Commands.cfg > Download
Sample Hostfile > Download
Nagios MIB > Download

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *