Page 1 of 2
How to check a service once a day, without an "OK" message
Posted: Thu Sep 18, 2014 6:42 pm
by avonnieda
Hi folks,
I thought is_volatile might be what I was looking for, but it's not working like I thought it would. What I want to do is check a service once a day, if it matches a criteria, send a notification, and then put it back to OK (regardless of if it's actually OK or not). I don't want to send a follow up "OK" notification. Is there any way to do this? I know how to check a service just once a day, the part I don't know how to do is set the state back to "OK" after the notification.
In other words, I want to check something once a day, but not have the service in a status of "CRITICAL" for the next 24 hours, even if it still fits the criteria for that.
Hopefully this made at least a little sense .. Thanks,
-Adam
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 9:44 am
by eloyd
It would help if you told us what you were checking. "is_volatile" may be what you're looking for after all.
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 9:56 am
by avonnieda
I'm checking a service that may or may not return a 0, 1, or 2, just like any other service. It's just that I want to check it only once a day (which is no problem), send a notification if it's a 1 or 2 RC, and then set the status back to OK, regardless of the return code from the check. I want to check this once a day, but not have to look at the service in a non-OK state for the next 24 hours if it sent out a Not-OK notification.
I realize this is not the way Nagios wants to work, but I feel like someone has probably been in a similar situation before. What I'm looking to do is essentially the same as having a shell script execute once a day via cron, do a check, and send an email. Which is what I'll end up doing if I can't make this work.
Dunno if that helped or not, but thanks for the reply.
-Adam
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:02 am
by eloyd
I was hoping more for "I want to check the web site using check_http" or something like that.
Regardless, if you're just looking to always take action once per day at the same time based on the result of a single Nagios check, I would turn to cron.
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:06 am
by avonnieda
I'm checking for the existence of rows in an Oracle table via a plugin that I wrote. Does that help?
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:09 am
by eloyd
Perfect. Yes, it helps. I ask because if it's a custom plugin that you wrote, one option is to have the plugin take action and always return an OK back to Nagios.
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:11 am
by avonnieda
If it takes action and always returns OK though, then a notification will never go out, right? Or am I missing something? For clarification, I don't want the plugin to correct the situation, all I'm looking for is a notification that something is awry.
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:20 am
by eloyd
Let me see if I have this timeline correct:
Code: Select all
Monday - 8:00 am - Check is performed
result is OK
do nothing for 24 hours
Tuesday - 8:00 am - Check is performed
result is CRITICAL
send email
do nothing for 24 hours
Wednesday - 8:00 am - Check is performed
result is CRITICAL
send email????
do nothing for 24 hours
Thursday - 8:00 am - Check is performed
result is OK
do nothing for 24 hours
Depending on what happens on Wednesday, you could just have Nagios do what Nagios normally does, set max_check_attempts to 1, set the check_interval to 24 hours and the retry_interval becomes irrelevant. If you want Wednesday to send email as well, then you're good. If you don't want Wednesday to send email, change the notification_interval to also be 24 hours.
This way, you just have a really long period (1 day) between checks, but Nagios does what Nagios is supposed to do without you doing anything weird.
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:26 am
by avonnieda
Thanks, that's part of the solution, but two more things need to happen
1) The service needs to be set to OK regardless of return code the initial check - I'm thinking that the plugin could submit a passive check to accomplish this.
2) There should never be a "Service is OK" notification sent. The only notifications I want are one time per day, if the condition exists.
Re: How to check a service once a day, without an "OK" messa
Posted: Fri Sep 19, 2014 10:36 am
by eloyd
Simple: Set notification_options to be just "c" and you'll only be notified about criticals.
From
http://nagios.sourceforge.net/docs/nagi ... ml#service, regarding notification_options:
This directive is used to determine when notifications for the service should be sent out. Valid options are a combination of one or more of the following: w = send notifications on a WARNING state, u = send notifications on an UNKNOWN state, c = send notifications on a CRITICAL state, r = send notifications on recoveries (OK state), f = send notifications when the service starts and stops flapping, and s = send notifications when scheduled downtime starts and ends. If you specify n (none) as an option, no service notifications will be sent out. If you do not specify any notification options, Nagios will assume that you want notifications to be sent out for all possible states. Example: If you specify w,r in this field, notifications will only be sent out when the service goes into a WARNING state and when it recovers from a WARNING state.