Enable check only if another check returns running?

  • Director version (System - About): not installed
  • Icinga Web 2 version and modules (System - About): Icinga Web 2.12.1, incubator 0.22.0, ipl 0.5.0, reactbundle 0.9.0
  • Icinga 2 version (icinga2 --version): r2.14.2-1
  • Operating System and version: Red Hat 7
  • Webserver, PHP versions: Apache 2.4, PHP 7.3.33

I would like to run a service only if another service check returns “running”.

For example:

apply Service "illumio_noncritical" {
  import "unix-remote-service"
  check_command = "check_illumio_ven_ctl_connectivity"
  assign where intersection(host.groups, [ "critical", "notcritical" ])
  ignore where intersection(host.groups, [ "" ])
  assign where intersection([host.name], [ "" ])
  ignore where intersection([host.name], [ "" ])
  vars.notification_interval = ""
  vars.notification_period = "critical"
  vars.contacts = [ "" ]
  vars.contactgroups = [ "myusergroup" ]
  vars.notification.mail.groups = [ "myusergroup" ]
  groups      = [ "mygroup" ]
}

And I have another service:

apply Service "pe-puppet_ci" {
  import "unix-remote-service"

  check_command = "check_base_puppet"

  vars.notification_interval = ""
  vars.notification_period = "critical"
  vars.contacts = [ "me" ]
  vars.contactgroups = [ "team-mailer" ]
  vars.notification.mail.groups = [ "team-mailer" ]

  groups      = []

  assign where intersection(host.groups, [ "ssnp_cimonitored" ])
  ignore where intersection(host.groups, [ "ssnp_legacy_in_ci","ssnp_ci_no_puppet" ])
}

Is there a variable or method I could use to run illumio_noncritical only when pe-puppet_ci is returning “0”?

Sure, you could attach an “Event Handler” on service1 to trigger enable/disable “Active Checks” of service2 via REST API.

I got it to work like this:

apply Dependency "disable-illumio-noncritical" to Service {
  parent_service_name = "puppet"
  disable_checks = true
  states = [ Critical, Warning, Unknown ]
  assign where host.vars.agent_endpoint && service.name == "illumio_noncritical"
}

The problem is, I also need this check to only run on certain operating systems. Is there any way to make a dependency that works on certain OS types?

I’m not sure I understand, what you try to accomplish here.

Can you write in simple words, what needs to be checked where, when and why?

Do you need to change the behavior at config or runtime?