Applying an Icinga2 service to a host when specified service present on host

Cheers,

I have the situation that I want to apply a service to a host, but only for hosts that a certain service (with certain variables).

So essentially something like:

apply service "foo" {
  foreach service on host {
    assign where service.name = match(bar) and service.vars.baz = true
  }
}

So if I had services bar one with vars.baz=true, bar two with vars.baz=false and bar three with baz=true, I’d get two services, one each for bar one and bar three.

As I just noticed, I’d probably also need some way to get a unique service name derived from the conditional services.

Is it folly to go for it like this or should I just use variables for the host and derive all services from those?

Answer

Attribution
Source : Link , Question Author : towo , Answer Author : Community

Leave a Comment