Apply Dependency to Service Group?

Hi !

Can we do this in Icinga?
This is what we have in Nagios…

define servicedependency {
*** service_description check-nrpe-daemon***
*** dependent_servicegroup_name nrpe-dependent***
*** execution_failure_criteria w,u,c***
*** notification_failure_criteria w,u,c***
}

Thank you !

Take a look at the documentation of the dependency capability:

https://icinga.com/docs/icinga2/latest/doc/09-object-types/#dependency

Hi,

first look into apply rules and their assign where expressions. You can for example check whether a service is in a specific group.

  assign where "sg1" in service.groups

In order to not use so much service groups, but existing host groups - e.g. for nrpe hosts, you could also just use

object Host "..." {
  ...
  vars.agent_type = "nrpe"
}
object HostGroup "nrpe-agents" {
  assign where host.vars.agent_type == "nrpe"
}

apply Service "nrpe-disk" {
  ...

  assign where "nrpe-agents" in host.groups
}

Such apply rules can be used for Dependency objects as well, rendering the child object automatically. AFAIK that’s what dependent_servicegroup_name is, I always had to bang my head against this description never knowing whether this is now the child or parent in the relation. The naming schema is from one of my designs for Dependencies.

apply Dependency "nrpe-agents" to Service {

  ...
  //Omit the parent_host_name to apply the dependency for services on the same host
  parent_service_name = "nrpe-health"

  assign where "nrpe-agents" in host.groups

  ignore where service.name == "nrpe-health" //don't apply this for the health check itself
}

Such an example also is listed in the docs.

Cheers,
Michael