I put together a workaround that I am not entirely satisfied with. It
leaves a lot to be desired.
I modified my config generation outside icinga to create a file with a
"const" variable "const all_clusters", an array containing all the
cluster names. I have icinga2.conf including this file, so that my
other files can make use of the all_clusters variable.
Then in the file where I define my service objects, I do a for loop like this:
for (i in all_clusters) {
object Service "check cluster location throttled" use(i) {
var dummyhost = get_host(i)
if (i.vars.check_location_throttled == "true") {
<bunch of stuff to set up a real service check referencing
only the hosts that are in this cluster>
} else {
<bunch of stuff to set up a dummy always OK service check>
} // end if
} // end object
} //end for
The end result is that for my clusters that I need to create a
"location throtlled" cluster check, it gets created. For my clusters
that don't need it, a dummy service check gets created.
It works, but obviously a bunch of unnecessary service checks are
getting created. This kludgey workaround is necessary because I cannot
call "get_host()" *outside* of a Service object, only inside. If I
could call it outside, then only those Service objects that I want
would get created.
I'm still looking for a better solution, if anyone has any thoughts.
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users