I stumbled on the answer myself:
servicenames = [ "1", "2" ]
for (item in servicenames) {
object Service "prefix" + item use(item) {
get_service(xxxx, item).state
}
}
On Wed, Oct 19, 2016 at 12:17 PM, Michael Martinez <[email protected]> wrote:
> var names = [ "name1", "name2" ]
>
> i would like to create service objects with the above names, and
> inside each object definition, reference the name in a get_service
> function call. I would like to do this in a for loop because my array
> of names is large.
>
> I have tried:
> for (name in names) do {
> object Service "check-" name use(name) {
> get_service(instance, name)
> }
> }
> this complains about duplicate Service names.
>
> i have tried:
> for (name in names) do {
> object Service "check-" $name$ use(name) {
> get_service(instance, name)
> }
> }
> this complains about an unknown script variable.
>
> I have tried:
> apply Service "check-" for (name in names) use(name) {
> ...
> }
> this does not complain. But it doesn't create any Service objects.
>
> None of these are working. What I am doing wrong?
> --
> ---
> Michael Martinez
> http://www.michael--martinez.com
--
---
Michael Martinez
http://www.michael--martinez.com
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users