On Thursday 20 October 2016 at 00:28:21, Michael Martinez wrote:

> I stumbled on the answer myself:
> 
> servicenames = [ "1", "2" ]
> for (item in servicenames) {
>   object Service "prefix" + item use(item) {
>     get_service(xxxx, item).state
>   }
> }

This, for me, begs the questions:

1. Where is "prefix" defined?

2. Does this mean the array can only contain numeric values, and not arbitrary 
strings (which might easily be possible for hostname sequences)?

3. What does "xxxx" refer to in your script snippet above?  It doesn't appear 
to correspond to any of your sample attempts below.

Antony.

> On Wed, Oct 19, 2016 at 12:17 PM, Michael Martinez <mwt...@gmail.com> 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

-- 
"Black holes are where God divided by zero."

 - Steven Wright

                                                   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

Reply via email to