Stop service checks if host is down

Hello,
is it possible to stop all service checks from the host, if the host if down?
I’ve played around with some dependencies, but it never worked.

I only want one email notification when the host is down and one email notification when the host is again up.
Has someone a idea?

Hi,

Can you please share your attempts?

The default implicit host-service dependency only disables notifications.

Cheers,
Michael

Now it works… when the host goes down, I only receive the up- and down-email. I don’t receive service-emails. But now is another problem… when the Host is up, and only the service goes down, I don’t receive service-mails! What could be the problem?

apply Dependency “HostDownNoService” to Service {
disable_checks = true
disable_notifications = true
ignore_soft_states = true
assign where host.name == “nas”
states = [ Down ]
}

But this dependency is only for one host… I want it for all hosts. Is the following code possible?

assign where host.name == “*”

I found this topic which is the same problem as mine.

I had the similar challenge and also wanted to disable the service checks during the time a host is down.
The following rule solved my problem - and should also solve yours because without service checks there should be no service notifications…

#
# Disable servicechecks on hosts in state DOWN
#
apply Dependency "disable-host-service-checks" to Service {
  disable_checks = true
  assign where true
}

Cheers,
Manfred

3 Likes

Where do you apply this? Is it in the root of a config file or within a service or host definition? To which configuration file would this be added? (Sorry - I have read this in the docs but cannot figure out how to actually apply it!)

This is basically the same as an service apply rule.
So just treat it as such.
If you are using config files I would recommend creating a new config file, e.g. dependency.conf, and add it there.

I don’t understand this Dependency. Could you please elaborate on how it works?

What I am missing in the dependency is the dependency that the host is down.

I read it as following: “Apply this dependency to all services where true”.
I expect it to be something like: “Apply this dependency to all services where the host is down”

What makes this dependency only act on hosts that are down, instead of simply all services? The ‘assign’ will always test as true.

I also don’t know the exact internal mechanism but when reading the docu it seems that there is an implicit parent-child dependency between host and services on this host - it works as expected.

You can still run into problems with service states because host and service checks are usualy scheduled independent and with individual check and retry settings. So choose them wisely :nerd_face:

Is there a way to check it this has been applied? I’ve added this dependency.conf file to conf.d but see no effect.

I can see this: [2024-02-06 08:55:16 +0000] information/ConfigItem: Committing config item(s).
[2024-02-06 08:55:16 +0000] warning/ApplyRule: Apply rule ‘disable-host-service-checks’ (in /etc/icinga2/conf.d/dependency.conf: 4:1-4:57) for type ‘Dependency’ does not match anywhere!
[2024-02-06 08:55:16 +0000] information/ConfigItem: Instantiated 1 IcingaApplication.