[icinga-users] Using check_multi with Icinga2

Michael Martinez mwtzzz at gmail.com
Wed Aug 17 03:58:59 CEST 2016

Ok, the code given below works (for now I'm going with the
check_cluster plugin, although eventually I will play around with
Gunnar's script).

I've got a question. I don't know why "h.groups" is null. I've
verified that the hosts are getting assigned into HostGroups using the
web api to query objects. But my log statement keeps showing that
h.groups is empty. Any thoughts?

for (elbname => members in elb) {
/* the "use" is necessary to pass the variable into the scope of the object */
  object Service "check_cluster elbname" use(elbname) {
    import "generic-service"
    check_command = "check_cluster"
    host_name = elbname

  /* using braces makes it a function which means
     it is calculated dynamically. otherwise without braces
     it is calculated once at compile time

     hostgroup membership is designated in the hosts.groups array,
     not in the HostGroup object. So it is necessary to iterate
     over all hosts to find which ones belong to a particular HostGroup.

    vars.ec2_instances = []
    for (h in get_objects(Host)) {

     if (!h.groups) { log("h.groups empty") }

     if (elbname in h.vars._elbs) {
//     if (elbname in h.groups) {

    log("MM2: elbname: " + elbname + ", ec2_instances: " +
vars.ec2_instances.join(",") )

    vars.cluster_data = {{
      var states = []
      for (instance in macro("$ec2_instances$") ) {
      return states.join(",")

    vars.cluster_label = elbname



More information about the icinga-users mailing list