Sent from my iphone w/ free typos.

> Am 14.07.2015 um 23:42 schrieb Seth Galitzer <[email protected]>:
>
> I want to be able to assign a service to a host that may be in one of several 
> groups among its list of groups. So if host "A" is in groups "foo" and "bar" 
> and service "check_foo" is assigned to hosts that are members of the groups 
> "foo" and "baz", then host "A" should run service "check_foo". What would be 
> the correct syntax for this case?
>
> I have the following and it obviously is incorrect:
>
> object Host "A" {
>  groups += [ "foo", "bar" ]
> }
>
> apply Service "check_foo" {
>  assign where host.groups in [ "foo", "baz" ]
> }

How about apply for? (Untested)

apply Service "bla" for (hg in host.groups) {

  assign where hg in [ "a", "b" ]
}

A different approach would be intersection checking the array length.

http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/library-reference#global-functions

apply Service"bla" {

  var match = [ "a", "b" ]
  var arr = intersection(host.groups, match)

  assign where arr.len() > 0

}

Kind regards,
Michael

>
> I need the correct way to say "assign where <any list member of host.groups 
> that matches any member of this list>".
>
> I hope that makes sense. Anybody have any suggestions? Do I need to do this 
> in the apply statement somehow to loop through members of host.groups? Or is 
> there a better way?
>
> Thanks.
> Seth
>
> --
> Seth Galitzer
> Systems Coordinator
> Computing and Information Sciences
> Kansas State University
> http://www.cis.ksu.edu/~sgsax
> [email protected]
> 785-532-7790
> _______________________________________________
> icinga-users mailing list
> [email protected]
> https://lists.icinga.org/mailman/listinfo/icinga-users

-- 
Michael Friedrich, DI (FH)
Application Developer

NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg
Tel: +49 911 92885-0 | Fax: +49 911 92885-77
GF: Julian Hein, Bernd Erk | AG Nuernberg HRB18461
http://www.netways.de | [email protected]

** OSBConf 2015 - September - osbconf.org **
** OSMC 2015 - November - netways.de/osmc **
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to