Page 2 of 2

Re: Set Notification Period for Hosts Services

Posted: Sun Mar 13, 2016 6:28 pm
by Box293
mastermindg wrote:I ended up creating custom services for the host. However, this seems like a counter-intuitive way to go about doing what needs to be done here. Is there no way to override the default behavior and have services inherit a hosts notification settings?
Once you get into object tricks, some things won't work for specific reasons (like inheritance).

OK so I did some testing to make sure I understand what is going on in core.

It appears as though a service will inherit the notification_period from the host object, as long as no notification_period has been defined in the service or any templates the service is using. Your notification_period in the host object would need to exclude the timeperiod you don't want checked.

So they key here is that because you are using a common service, you need to make sure that common service does not define the notification_period in the service or any templates the service is using, meaning ALL of your host objects must have that correctly defined.

https://support.nagios.com/kb/article.php?id=487
Box293 wrote:A service cannot inherit the time period from a host because the documentation states that the "check_period" directive is required.
It looks like I was confusing check_period with timeperiod. For clarity, the service does not inherit the check_period from the host object.

Re: Set Notification Period for Hosts Services

Posted: Mon Mar 14, 2016 8:02 am
by eloyd
For better or for worse, nagios treats hosts and services as separate entities. Therefore, there is no cross-configuration between the two. Personally, I'd like to see this updated and a new object model created where a host is just a different class of object than a service, which would allow all sorts of much easier configurations, but that won't happen anytime soon.

So you're left with automation via cron or an event handler. Personally, I'd go event handler so you only have one place to change things. A service event handler could fire off when the service is checked, check the host's notification period, and if it's in the exclusion zone, then activate scheduled downtime via the nagios cmd file (as @box293 mentioned) if it's not already active. This way, if you change the host's notification period, then you don't have to also change cron settings.

In fact, I like this idea so much, I may just whip it up myself and post it to the exchange.

Re: Set Notification Period for Hosts Services

Posted: Mon Mar 14, 2016 11:16 am
by rkennedy
Thanks @eloyd! Feel free to let us know the link once you post it! :)

@mastermindg - let us know if you have any further questions after the previous responses.