I am trying to change the check_interval time for a single domain to 5 minutes but icinga2 doesn’t override it. The checks are done every 1 minute. Here is my conf. The main domain examplemanager.com Icinga checks for 5 minutes but I want test.examplemanager.com to be checked every 7 minutes and examplemanager.com/test/admin to check every 5 minutes. how can I do that?
Hi @hrai
Welcome to the community!
Assuming that your service definition looks something like this:
apply Service "http-" for (vhost => config in host.vars.http_vhosts) {
// ...
}
You could add the following snippet to your definition:
if (!config.check_interval) {
check_interval = "60"
} else {
check_interval = config.check_interval
}
Kind regards
HI,
Did as you told me,
getting such syntax error,
@ritzgu we are applying these configurations in different files i.e. in location: /etc/icinga2/zones.d/master/hosts/hostname/hostname.conf
if we made changes according to your suggestion the custom service file will be too large. Can you suggest to me any other workaround?
Sorry for the late reply. Have you added the snippet to the service definition (not into the host)?
You just have to add the 4 extra lines.
Working example:
object Host "testhost1" {
check_command = "dummy"
address = "127.0.0.1"
vars.test["1"] = {
check_interval = "120"
}
vars.test["2"] = {
check_interval = "180"
}
vars.test["3"] = {}
}
apply Service "testcheck" for (test => config in host.vars.test) {
check_command = "dummy"
vars += config
if(!config.check_interval){
check_interval = "60"
} else {
check_interval = config.check_interval
}
}