Host timeperiod isnt applied to its 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.
Locked
riahc3
Posts: 53
Joined: Thu Apr 05, 2018 9:36 am

Host timeperiod isnt applied to its services?

Post by riahc3 »

Hello

I just added a timeperiod to the notification and check and while it does work for the host (eg. it does not alert nor check out of that time period), it still alerts me of the services out of that time period.

Doesnt it get inherited?

Thanks
Guyver1
Posts: 27
Joined: Tue Apr 16, 2019 4:43 am

Re: Host timeperiod isnt applied to its services?

Post by Guyver1 »

I believe you have to set time periods on your services

use a template service for say in business hours only services 6am-6pm and then apply that template to all the services you only want to alert in business hours

https://assets.nagios.com/downloads/nag ... ml#service
riahc3
Posts: 53
Joined: Thu Apr 05, 2018 9:36 am

Re: Host timeperiod isnt applied to its services?

Post by riahc3 »

Guyver1 wrote:I believe you have to set time periods on your services

use a template service for say in business hours only services 6am-6pm and then apply that template to all the services you only want to alert in business hours

https://assets.nagios.com/downloads/nag ... ml#service

That fucking sucks....Any other way?

I have a service assigned to host groups so I cant do it like that.
Guyver1
Posts: 27
Joined: Tue Apr 16, 2019 4:43 am

Re: Host timeperiod isnt applied to its services?

Post by Guyver1 »

Hi,

Boomark this page as it has all the definitions of all the object types:
https://assets.nagios.com/downloads/nag ... tions.html

Looking at the notification options for a host:
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
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.

So the notifications for a host are not the same as the notifications for a service.
Notifications for a host simply tell whether the host is up, down, flapping or has recovered.

Service notifications only tell you about the state of the service, not the host.

You may need to re-think your service configuration and you may possibly need two separate services, one for your 24x7 alerting hosts and a separate one for your business hours only hosts:

24x7 disk check
define service {
host_name host1,host2,host3,host4
service_description check-disk-sda1
check_command check-disk!/dev/sda1
max_check_attempts 5
check_interval 5
retry_interval 3
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,c,r
contact_groups linux-admins
}

business hours only disk check
define service {
host_name host5,host6,host7,host8
service_description check-disk-sda1
check_command check-disk!/dev/sda1
max_check_attempts 5
check_interval 5
retry_interval 3
check_period workhours
notification_interval 30
notification_period workhours
notification_options w,c,r
contact_groups linux-admins
}


You could do this fairly quickly by creating two hostgroups:
24x7_hosts
buisiness_hours_hosts

and add in your hosts to each host group and then assign the relevant hostgroup to the correct services as I created above instead of specifying hosts.

If a customer has 24x7 support then it would be assumed that their servers would require 24x7 monitoring on all services on all their servers and a business hours only support customer would only need business hour alerting on all the services on their servers.

Its all about how you want to configure your config files and how you write your hosts/services
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Host timeperiod isnt applied to its services?

Post by scottwilkerson »

Yes you must apply to the objects themselves or an attached template
https://assets.nagios.com/downloads/nag ... tance.html
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
riahc3
Posts: 53
Joined: Thu Apr 05, 2018 9:36 am

Re: Host timeperiod isnt applied to its services?

Post by riahc3 »

We are talking about 28 services......28 services that need to be duplicated at least twice.....

I still dont get why Nagios cant use some intelligence and if the host doesnt check, the services shouldnt get checked either.

It would be almost easier to set a scheduled downtime period on the host....Those DO get replicated to the service.

But, AFAIK, you cant do a "scheduled_downtime_period" i think
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Host timeperiod isnt applied to its services?

Post by scottwilkerson »

Unfortunately what you are looking for doesn't exist in the current code base for Nagios Core, however, it is an open source project so you can feel free to modify it to meet your custom needs, the project is located here
https://github.com/NagiosEnterprises/nagioscore

I will point out that if you use templates when setting up your services, changes would only need to be made in the affected template file, that would be just one change.

Nagios XI is another option with built-in configuration management and a bulk modification wizard, you can do steps like the above in about 3 clicks
https://www.nagios.com/products/nagios-xi/
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked