Page 1 of 1

Host timeperiod isnt applied to its services?

Posted: Sun Aug 11, 2019 12:05 am
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

Re: Host timeperiod isnt applied to its services?

Posted: Sun Aug 11, 2019 1:36 am
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

Re: Host timeperiod isnt applied to its services?

Posted: Sun Aug 11, 2019 9:39 am
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.

Re: Host timeperiod isnt applied to its services?

Posted: Sun Aug 11, 2019 10:34 am
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

Re: Host timeperiod isnt applied to its services?

Posted: Mon Aug 12, 2019 8:38 am
by scottwilkerson
Yes you must apply to the objects themselves or an attached template
https://assets.nagios.com/downloads/nag ... tance.html

Re: Host timeperiod isnt applied to its services?

Posted: Tue Aug 13, 2019 3:14 pm
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

Re: Host timeperiod isnt applied to its services?

Posted: Tue Aug 13, 2019 3:20 pm
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/