How to send an “Everything is OK” notification from Nagios

monitoringnagios

I need to configure Nagios to send a notification that says everything goes well, if there's no problems.

Does this sort of setting exist or is there a plugin for that?

Best Answer

I use the following setup to send an email once per day. This let's me know that all is well with my Nagios server, the email system and the Nagios config.

  # nagios/objects/localhost.cfg
  ....
  # Send a message once per day to make sure nagios is working ok
  define service{
        use                     local-service
        host_name               localhost
        service_description     Nagios is OK
        check_command           check_all_is_well
        check_period            morning     ; this is a custom period
        normal_check_interval   60          
            ; setting this to an hour and making the check_period 
            ; interval 59 minutes long each day ensures it only 
            ; happens once per day in a specific window
        }

and in you timeperiods config file:

# nagios/objects/timeperiods.cfg
....
define timeperiod{
        timeperiod_name morning
        alias           First thing in the am
        monday          06:00-6:59
        tuesday         06:00-6:59
        wednesday       06:00-6:59
        thursday        06:00-6:59
        friday          06:00-6:59
        saturday        06:00-6:59
        sunday          06:00-6:59
        }

And the check_all_is_ok command is a simple wrapper around sendmail:

# check_all_is_ok
#!/bin/bash

echo "All is well from Nagio on `hostname`" \
       | /etc/nagios/sendmail -s "Nagios on PIP is OK" <your email address>

echo "OK: nagios is ok on `hostname`";
exit 0

It doesn't check that there haven't been problems in the prior 24 hours, but you could add some grep-ping of the logs as guanta suggested if you need that. You could also accomplish the once a day requirement by setting normal_check_interval to 1440 (24 hours), but I want the check to be run in a specific window each day.

Related Topic