Set Notification Period for Hosts Services

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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Set Notification Period for Hosts Services

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Set Notification Period for Hosts Services

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Set Notification Period for Hosts Services

Post 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.
Former Nagios Employee
Locked