0

I've got a clustered service (active/passive pacemaker cluster) that I'd like to monitor with icinga2. According to the documentation (https://www.icinga.com/docs/icinga2/latest/doc/08-advanced-topics/#access-object-attributes-at-runtime-cluster-check) icinga's built-in object accessor functions can be used to derive a 'virtual' service state from dependent objects:

object Service "cluster-service" {
  vars.cluster_service = "awesome-clustered-service"
  host_name = "cluster"
  check_command = "dummy"
  vars.cluster_nodes = [ "cluster-host-01", "cluster-host-02" ]

  vars.dummy_state = {{
    var cluster_service = macro("$cluster_service$")
    var up_count = 0
    var down_count = 0
    var cluster_nodes = macro("$cluster_nodes$")

    for (node in cluster_nodes) {
      if (get_service(node, cluster_service).state > 0) {
        down_count += 1
      } else {
        up_count += 1
      }
    }

    if (up_count >= down_count) {
      return 0 //same up as down -> UP
    } else {
      return 2 //something is broken
    }
  }}
}

However since it's an active/passive cluster, this leaves me with a critical service (in this example 'awesome-clustered-service' on one of the cluster nodes) which isn't ideal. I could disable notification for that particular service object but I'm wondering if there's a more elegant solution that I've missed?

Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.