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?

link|improve this question

67% accept rate
Out of curiosity, why is it that you want it this way (rather than ok messages when state changes from not ok) ? - sounds like extra messages for no gain. – Sirex Aug 12 '11 at 15:21
feedback

migrated from superuser.com Aug 3 '11 at 20:19

This question came from our site for computer enthusiasts and power users.

3 Answers

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.

link|improve this answer
feedback

The solution heavily depends on when you actually want to send out notifications:

  • On each successful run of an active check: Then it might make sense to actually run the notification step as part of your active check. A simple way would be to wrap your check inside a script that first does the check, introspects the result and sends the notification. You could do that using embedded Perl.
  • When things used to be not okay but are now: This is standard behavior.
  • On passive checks: This is actually an interesting problem for which I don't have a solution on top of my head...

Depending on the scenario you should decide for one solution. And always remember: do the simplest thing that could possibly work.

link|improve this answer
The idea was to send a notification once a day, if there were no problems during last 24 hours. – Roman Prikhodchenko Aug 4 '11 at 11:48
feedback

If you configured daily log rotation (log_rotation_method=d), you can write a script to count the number of alerts in nagios.log, something like this:

[ `grep -c ALERT var/nagios.log` -eq 0 ] && echo "Everything is OK!" | mail -s "Nagios daily report" your@email

Put it into a cron job to run at the end of day, before you go to bed.

If you don't, refer to this topic to filter according to the date.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.