Vars.oids["if01"] = "1.1.1.1.1"

Hi,

In the documentation, the following construct (sort of a hashkey for variable “oids”) is proposed in section 3.6.8 Using Apply For Rules. How can achieve this using Director?

I have seen this: Service Apply for Example - Icinga Director
but it falls short of what I want to achieve, i.e. associate a name to each value in the array. In my check, I will need both the key and the value. Actually, the key will be the check’s name and the value will be the polled OID. Just like in the textbook example.

Thanks,

JM

object Host “router-v6” {
check_command = “hostalive”
address6 = “2001:db8:1234::42”
vars.oids[“if01”] = “1.1.1.1.1”
vars.oids[“temp”] = “1.1.1.1.2”
vars.oids[“bgp”] = “1.1.1.1.5”
}

Hi,

I am still looking for a solution on this one. Perhaps I should have included the link to the Icinga2 manual where the sample config I want to replicate using Director is documented - here it is: 3.6.8 Using Apply For Rules

Thank you in advance for your help,

JM

did you figure it out?

The director supports arrays but only as list not as key value pairs.

you need a datafield type array:

you add this field to your host template:

your array can cointain the oids

your service apply rule can apply for this array and access each oid as $config$:

Thanks a lot for your explanation of what is possible, @moreamazingnick !
However, as I was saying, I would have loved to associate a name with each OID, so that the name could be used as part of the service name created as a result of the “Apply for” statement.
The example shown in https://icinga.com/docs/icinga-2/latest/doc/03-monitoring-basics/#using-apply-for-rules results in the following services being defined (listing below the display name):

  • if01
  • temp

And the check status result would of course be based on the result of SNMP polling of 1.1.1.1.1 and 1.1.1.1.2, respectively.

NB: In the meantime, our SNMP device has been replaced with another device, on which the checks are much easier to implement. So this has become a non-issue for us.