Page 1 of 2
notification_period not honoured on host config?
Posted: Tue Mar 12, 2013 12:49 pm
by mikej
I'm having troubles getting Nagios to honor a notification_period setting for a predefined timeperiod.
My timeperiod definition is called 'sleep' as in, do not notify me between midnight and 7am. it looks like this:
Code: Select all
define timeperiod{
timeperiod_name sleep
alias Not Middle of Night
sunday 07:00-23:59
monday 07:00-23:59
tuesday 07:00-23:59
wednesday 07:00-23:59
thursday 07:00-23:59
friday 07:00-23:59
saturday 07:00-23:59
}
I've entered the directive for the hosts as follows:
Code: Select all
define host{
use linux-server,host-pnp
host_name server.domain.com
alias server.domain.com
address xxx.33.xxx.243
notification_period sleep
}
This morning I was expecting to see WARNING notifications but only after 7am. Instead, I saw them throughout the night between 23:59 last night and 7am this morning.
My understanding from the configuration is that I should NOT have received any emails during this time.
Have I overlooked something? I was hoping it would be this simple but it didn't work as expected.
Re: notification_period not honoured on host config?
Posted: Tue Mar 12, 2013 1:36 pm
by abrist
Is the clock right on the nagios server?
Do you have time periods setup on the service checks?
Re: notification_period not honoured on host config?
Posted: Tue Mar 12, 2013 4:41 pm
by mikej
Thanks for the quick response.
Yes, the time is correct. I double-checked it against an NTP server and it matches other servers to.
Regarding the service checks, do I need to specify the notification_period directive for each service check within the host.cfg file? I might be mistaken but I thought I could simply apply the directive once in the host.cfg file. For example, what if a host has up to 20 service checks?
Thanks again!
Mike
Re: notification_period not honoured on host config?
Posted: Tue Mar 12, 2013 4:58 pm
by abrist
Do the service checks have the same notification time period as the host check?
Re: notification_period not honoured on host config?
Posted: Wed Mar 13, 2013 7:38 am
by mikej
Thanks again for your help.
Below are two service checks for the host in question (there are no notification time periods defined for each of them specifically).
Code: Select all
define service{
use generic-service,srv-pnp
host_name server.domain.com
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service,srv-pnp
host_name server.domain.com
service_description Load
check_command check_nrpe!check_load -a 15,10,5 30,25,20
}
Re: notification_period not honoured on host config?
Posted: Wed Mar 13, 2013 8:21 am
by mikej
After rereading the documentation, the linux-server template in templates.cfg has a value that is inherited from the generic-host template:
Code: Select all
define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
The line from the linux-server template is this:
Code: Select all
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
So, it looks like the object inheritance to the generic-host template is overriding the the custom value for my host server.domain.com. As in, it's not honouring my custom config for that particular host, but still retrieving the notify 24x7 value from the template.
Any ideas?
Re: notification_period not honoured on host config?
Posted: Wed Mar 13, 2013 9:31 am
by abrist
You could create a different host template without the notification time periods. Does your generic-service template have any notification time periods set?
Re: notification_period not honoured on host config?
Posted: Wed Mar 13, 2013 10:20 am
by mikej
Yes, it's set in the generic-service template.
But... I would have thought that if we have a notification_period directive on the child (in this case the host config) it would override the service checks on each?
I guess what I'm asking is if the child (server.domain.com.cfg) has a custom directive, shouldn't that override the notifications for service checks on that host? It seems odd that I would need to create custom templates for one-off situations where I only want a couple of hosts to have custom directives (in this case notifications).
Perhaps this is the way the inheritance works. Is that the case?
Re: notification_period not honoured on host config?
Posted: Wed Mar 13, 2013 10:24 am
by mikej
Sorry, a clearer question is:
Does the child override the parent? Or the parent override the child?
IE:
server.domain.com.cfg custom directive is overridden by whats in templates.cfg
or
templates.cfg custom directive is overridden by whats in server.domain.com.cfg
Thanks for your help.
Re: notification_period not honoured on host config?
Posted: Wed Mar 13, 2013 10:31 am
by abrist
From:
http://nagios.sourceforge.net/docs/3_0/ ... tance.html
Normally you have to either explicitly specify the value of a required variable in an object definition or inherit it from a template. There are a few exceptions to this rule, where Nagios will assume that you want to use a value that instead comes from a related object. For example, the values of some service variables will be copied from the host the service is associated with if you don't otherwise specify them.
Essentially, the service checks will only inherit the host settings if they are not defined on the service.