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?

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

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

  • 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

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

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.


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.


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.

  • The idea was to send a notification once a day, if there were no problems during last 24 hours. – Roman Prykhodchenko Aug 4 '11 at 11:48

It's a bit late, but for anyone else looking for a solution, there's an easy way using the livestatus broker module.

Set up livestatus to use a unix socket (Shinken, by default, has it only set up with tcp port, you can add the socket like in the config on this page), and you can poll that directly using eg a python script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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