Hi. I'm trying to use get_object as documented in section 20.2.11 of http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/library- reference
Specifically, I want to start from a Host object, find the Zone it's a member of, look up the parent of that Zone (which will be another Zone), find the Endpoints of that parent Zone, and get the Address of the first Endpoint. Complicated, I know, but I've reduced the problem to the following (I think if I can get this working, I can get the rest): - start from the required Host object - find the Zone it's a member of - find the Endpoints of that Zone Here's what I've done to test this: ----- testhosts.conf ----- object Host "TestHost1" { import "generic-host" check_command = "dummy" zone = "Strato" } object Host "TestHost2" { import "generic-host" check_command = "dummy" vars.other = "TestHost1" vars.objzone = get_object("Host",vars.other).zone vars.objcheck = get_object("Host",vars.other).check_command vars.otherzone = get_object("Zone",vars.objzone) vars.otherends = get_object("Zone",vars.objzone).endpoints } ----- Yes, there is a Zone called "Strato" defined in /etc/icinga2/zones.conf Also, before somebody asks, yes I know I could have used "get_host" instead of "get_object" with a "Host" parameter, but I just wanted to check that I was using "get_object" correctly. Here's part of what I get from the output of "icinga2 object list -n TestHost2": ----- * vars * objcheck = "dummy" % = modified in '/etc/icinga2/conf.d/test.conf', lines 14:2-14:60 * objzone = "Strato" % = modified in '/etc/icinga2/conf.d/test.conf', lines 13:2-13:50 * other = "TestHost1" % = modified in '/etc/icinga2/conf.d/test.conf', lines 11:2-11:25 * otherends = null % = modified in '/etc/icinga2/conf.d/test.conf', lines 17:2-17:59 * otherzone = null % = modified in '/etc/icinga2/conf.d/test.conf', lines 16:2-16:49 ----- So, "vars.objzone" get the correct Zone name. "vars.otherzone" (which should be the complete Zone object) is null, and so is "vars.otherends" (which should be the array of Endpoints in the Zone). Just to check that I really do have a Zone called "Strato": ----- icinga2 object list -n Strato ----- Object 'Strato' of type 'Zone': % declared in '/etc/icinga2/zones.conf', lines 17:1-17:20 * __name = "Strato" * endpoints = [ "ob.fus.ca.ted" ] % = modified in '/etc/icinga2/zones.conf', lines 18:2-18:34 * global = false * name = "Strato" * package = "_etc" * parent = "" * templates = [ "Strato" ] % = modified in '/etc/icinga2/zones.conf', lines 17:1-17:20 * type = "Zone" * zone = "" ----- So, can anyone see what I'm doing wrong? Thanks, Antony. -- You can tell that the day just isn't going right when you find yourself using the telephone before the toilet. Please reply to the list; please *don't* CC me. _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users