Check period does not work

Hi everyone,

I have a service that I want to check at certain time only once a day .
I created time period like this :

object TimePeriod "AReports_Timeperiod" {
    import "legacy-timeperiod"
    prefer_includes = true
    display_name = "AReports"
    ranges = {
        "friday"	= "07:45-08:00"
        "monday"	= "07:45-08:00"
        "saturday"	= "07:45-08:00"
        "sunday"	= "07:45-08:00"
        "thursday"	= "07:45-08:00"
        "tuesday"	= "07:45-08:00"
        "wednesday"	= "07:45-08:00"
    }
}

My service template is like this :

template Service "A_Reports_Check_Template_Clone" {
    max_check_attempts = "1"
    check_period = "AReports_Timeperiod"
    command_endpoint = null
}

And my service :


object Service "Test3" { 
host_name = "Icinga-Test-Server" 
import "A_Reports_Check_Template_Clone" 
check_command = "A_Report_Check" 
}

Icinga still checks this service every 5 minutes , it ignores timeperiod and check period

Hello :slight_smile:
check_interval (e.g. every 5 min) and check_period are two different settings.

With the config you have posted the check should (at this time of day) show a “next check a 7:45 tomorrow”. And then it will run the check in a defined interval.
Example for setting the intervals:

template Service "generic-service" {
  check_interval = 5m
  retry_interval = 1m
}

My big problem… how to customize for every host?

I tried but with Director 1.11.1 seems impossible.

I have check_period only on the host template

Any ideas?
Thanks a lot

Mario

Hi Mario,

easiest would be to create a host template per check_period and them import the template accordingly.

Do you mean, I have to create n host-template for the n time-periods so in the host I can import the right host-template with the related timeperiod?

It’s great, you are right!
Is it still valid automatically for the apply services as well?
Because my:
template Service “generic-service” {
max_check_attempts = “3”
check_period = “Always”
check_interval = 10m
retry_interval = 30s
enable_perfdata = false
}
if I remove check_period from generic-service, will it use the host template to calculate check_period?

Thanks!

Isn’t there a mix up between host and service templates?

yes.

maybe :smiley:

no, afaik check_periods of the host do not get handed down to it’s services.

you would need to create n service templates for n check_periods as well, like generic-service-24x7 or generic-service-9to5

Default check_period ist always 24x7, if nothing is set.

oh, it it multiplies the number of service apply rules as well….

n service templates for n check_periods as well, like generic-service-24x7 or generic-service-9to5 has to be appplied

So, I have to implement them to the single service, but.. if I want a link between the service and the host I think I could do n service apply rules one to one to the n service templates for n check_periods so servapplrue24x7 with importgeneric-service-24x7 and.. as “Assign where” host.check_period ..

apply Service "Apprule-05:30-21:00 Weekend" {
    import "check_period-05:30-21:00 Weekend"

    check_command = "hostalive"
    assign where host.check_period == "05:30-21:00 Weekend"

    import DirectorOverrideTemplate
}

It feels a bit messy to do it like this…
Am I understanding it correctly?

This wont help you with your problem right now, but Icinga Notifications Scheduling Feature will make these things much easier :slight_smile:

At least as far as i understand it :smiley:

I don’t think the Icinga Notifications will help with scheduling checks only with scheduling how the resulting alerts get handled.

to reduce the number of apply rules you have to create you could use the Service Set feature of the Director.

This way you create a service set for each time period that you “apply” to the hosts via the check_period. Though this mostly makes sense, if you have multiple services that you apply to the same hosts.

Another thought:

If your goal is to limit notifications to specific times, then maybe think about scheduled downtimes or limited notification periods for the checks.

Thanks so, do you mean

  1. Instead of “Service Apply Rules” I have to move to to service Set?
  2. Scheduled downtimes probably is the best solution for me, so I can set ripetitive downtime i.e. every night adding an host fields like “downtime” that I can set

I am trying with scheduled downtime:

apply ScheduledDowntime “Workdays18-8” to Host {
author = “Mario”
comment = “Downtime scheduled during workdays to Downtime during the night and till saturday morning at 8:00”
fixed = true
assign where host.vars.ScheduledDowntime == “Workdays18-8”
ranges = {
“monday” = “9:30-10:30”
“monday,tuesday,wednesday,thursday,friday” = “18:00-24:00”
“monday,tuesday,wednesday,thursday,friday,saturday” = “00:00-8:00”
}

and I set on a host:

object Host “hosttest” {import “windows-host”

address = “172.16.1.114”
vars.ScheduledDowntime = [ “Workdays18-8”, “Weekend0-24” ]
vars.disks = [ “F:”, “H:”, “C:”, “W:”, “E:”, “I:”, “G:” ]

}

where ScheduledDowntime is an array of the Datalist with entries : “Workdays18-8”, “Weekend0-24”

It doesn’t work, I don’t see scheduled downtime on the host

What am I doing wrong?

Thanks a lot

Mario

because ScheduleDowntime is an array, I have to set:
assign where “Workdays18-8” in host.vars.ScheduledDowntime