Is it possible to chain services?

Scenario:

haproxy, check for zero session rate (there is a -z flag for this), returns critical if so

Definition is:

apply Service for (backend in host.vars.lb_backends) {
import “satellite-service”
import “endpoint-service”

name = "haproxy backend " + backend

check_command = “haproxy-stats”

vars.haproxy_stats_socket = “/run/haproxy/admin.sock”
vars.haproxy_stats_proxies = backend
vars.haproxy_stats_zero_sessions = true
}

This is fine if the haproxy is the active one, but not in an inactive ones.

There is a “haproxy active?” check, returns OK if active, warning is not.

Two questions:

  1. Can use the result of “active?” in the definition of zero_sessions?

  2. Is there a way to check there is one and only one active? service returning OK?

Thanks,
Gerardo

I needed to rad more.
Found an (the?) answer to 1:

vars.haproxy_stats_zero_sessions = {{ get_service(host.name, “local haproxy active?”).state) == 0 }}

For 2:
Need to attach the check to a host, but is there any way to get a list of hosts matching a condition (name regex, variable, service, etc)?
Tried a hostgroup, but the object does not provide a list of hosts.
Thanks,
Gerardo

Try to use apply rules, should help