> On 14 Jul 2016, at 21:08, Michael Martinez <mwt...@gmail.com> wrote: > > On Thu, Jul 14, 2016 at 12:48 AM, Michael Friedrich > <michael.friedr...@netways.de> wrote: >> var hg_name = “myhostgroup" >> var data = [] >> for (h in get_objects(Host)) { >> if (hg_name in h.groups) { >> data.add(h.name) >> } >> } > > Ok, thanks for the tip. > > Now another question: let's say I have an array or dictionary that > contains a list of arbitrary names. I want to create a HostGroup > Object for each name and then assign to hosts. Can Icinga do this at > startup?
const MyHGNames = [ “hg1”, “hg2” ] for (hg in MyHGNames) { object HostGroup hg { assign where ... } } Something like this. This comes in handy if you want to generate hosts as well. Though it makes your config a bit tad more difficult to read :) We’re using such methods to simply generate test config in our test labs (e.g. https://github.com/Icinga/icingaweb2/blob/master/.puppet/profiles/icinga2_dev/files/conf.d/test-config.conf) Kind regards, Michael > _______________________________________________ > icinga-users mailing list > icinga-users@lists.icinga.org > https://lists.icinga.org/mailman/listinfo/icinga-users -- Michael Friedrich, DI (FH) Senior Developer NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg Tel: +49 911 92885-0 | Fax: +49 911 92885-77 CEO: Julian Hein, Bernd Erk | AG Nuernberg HRB18461 http://www.netways.de | michael.friedr...@netways.de ** OSBConf 2016 - September - osbconf.org ** ** OSMC 2016 - November - netways.de/osmc ** _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users