Page 1 of 1

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

Posted: Thu Dec 05, 2013 11:16 am
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

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

Posted: Thu Dec 05, 2013 5:43 pm
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.

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

Posted: Wed Dec 11, 2013 3:52 am
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

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

Posted: Wed Dec 11, 2013 4:33 pm
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.

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

Posted: Thu Dec 12, 2013 3:29 am
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?

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

Posted: Thu Dec 12, 2013 3:30 pm
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