Send always "OK", other notifications in a certain timeframe

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
sbreit
Posts: 4
Joined: Thu Oct 13, 2011 2:51 am

Send always "OK", other notifications in a certain timeframe

Post by sbreit »

Hi everyone!

I need to send notifications to a certain email address. My problem is that I need to send recovery notifications 24x7 and critical notifications in a certain timeframe (let's say 5pm to 8am only).

It seems that if you configure a contact that will receive recovery messages only you won't get any messages because recovery messages will only be send if a critical message has been sent before.

Is there an other way to achieve this? If not (within nagios) I'll write a script as notification command that will make this decision.

Thanks in advance

Steffen
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Send always "OK", other notifications in a certain timef

Post by slansing »

You should get recovery notifications regardless, that is, if you have your contact configured to receive "r" notifications in it's contact definition, and you have the host/service set up for recovery notifications. You could potentially use two contacts on the host, both for the same address but one with 24x7 critical notifications, and the other for 5PM-8AM recovery notifications. You would need to enable a 24x7 check time period on the host, and both recovery and critical notification options, then on the contacts you would set one to only "r" and the other to "c" or.. "d" for a host being down.

Host notification options:
notification_options: This directive is used to determine when notifications for the host should be sent out. Valid options are a combination of one or more of the following: d = send notifications on a DOWN state, u = send notifications on an UNREACHABLE state, r = send notifications on recoveries (OK state), f = send notifications when the host starts and stops flapping, and s = send notifications when scheduled downtime starts and ends. If you specify n (none) as an option, no host 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 d,r in this field, notifications will only be sent out when the host goes DOWN and when it recovers from a DOWN state.
Service notification options:
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.
sbreit
Posts: 4
Joined: Thu Oct 13, 2011 2:51 am

Re: Send always "OK", other notifications in a certain timef

Post by sbreit »

Hi slansing,

thanks for your reply.
slansing wrote:You should get recovery notifications regardless, that is, if you have your contact configured to receive "r" notifications in it's contact definition, and you have the host/service set up for recovery notifications.
Well, that's what I've thought too, but apparently it doesn't seem to work. I have cross checked it several times and also tested it, with no success. We're running Nagios 3.0.8 if that's relevant for this issue.

Here are excerpts from our Nagios configuration files (shortened):

Code: Select all

define service {
        ...
        notification_period             24x7
        notification_options            w,u,r,c,f
        contact_groups                  crm-sos
        ...
        }

Code: Select all

define contactgroup {
        contactgroup_name                       crm-sos
        members                                 crm-sos-contact,crm-sos-contact-ok,nagios
        }

Code: Select all

define contact {
        contact_name                            crm-sos-contact-ok
        ...
        contactgroups                           crm-sos,crm-sos-we
        service_notifications_enabled           1
        service_notification_period             24x7
        service_notification_options            r
        ...
        }
An Alert has been send to crm-sos-contact, but not to crm-sos-contact-ok because of the service_notification_options. That's OK so far.
However, upon recovery, no mail has been sent (or to be more precise: no Notification has been generated).

Regards
Steffen
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Send always "OK", other notifications in a certain timef

Post by slansing »

I'd recommend forcing a recovery on a host/service that contact is assigned to while you tail your maillog to see if the notifications are being sent.

Code: Select all

tail -f /var/log/maillog
If they are being sent to the correct contact address you should see a ok=sent line.
sbreit
Posts: 4
Joined: Thu Oct 13, 2011 2:51 am

Re: Send always "OK", other notifications in a certain timef

Post by sbreit »

I'd recommend forcing a recovery on a host/service that contact is assigned to while you tail your maillog to see if the notifications are being sent.
I did that, however, there hasn't been an entry in the nagios.log, so I guess looking in the mail log won't help, will it?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Send always "OK", other notifications in a certain timef

Post by lmiltchev »

It seems that if you configure a contact that will receive recovery messages only you won't get any messages because recovery messages will only be send if a critical message has been sent before.
This seems to be the case. It is the default behavior. I am not sure if there is a "workaround".
Note: Notifications about host or service recoveries are only sent out if a notification was sent out for the original problem. It doesn't make sense to get a recovery notification for something you never knew was a problem...
http://nagios.sourceforge.net/docs/3_0/ ... tions.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked