Réf. : Nagios-devel digest, Vol 1 #832 - 5 msgs

Andreas Ericsson ae at op5.se
Thu Jun 9 14:23:28 CEST 2005


Yann DIRSON wrote:
> (about multiple occurences of a property)
> 

(about multiple occurrences of 'use', actually).

>>It is intended behaviour (an easter egg, more like it, but it's nifty). 
> 
> 
> OK, I do not see any pratical use for it at first glance, do you have an 
> example of use ?
> 

Several objects might want to inherit some variables that are common to 
all objects. Several of those other objects may have many other settings 
in common. It is then practical for the object in question to inherit 
some variables and have others overwritten by subsequent 'use' statements.

> 
> 
>>Feel free to submit a patch for the documentation.
> 
> 
> OK, but I'll have to get a better understanding of those features first :)
> 

So read the code.

> 
> 
>>You can do contact_groups *
>>in the "master" template, and exclude them in the others(contact_groups 
>>!notwanted). That way it will get complemented rather than overwritten.
> 
> 
> Hm, looks like this is not documented either :)
> Trying on my own on another example (use_regexp_matching=0) where I missed 
> an exclusion mechanism already, the following does not work:
> 
> define service{
>         name            everything
>         use             infra-service
>         host_name       *
>         register        0
> }
> define service{
>         service_description             PING
>         use                             everything
>         host_name                       !croiseur
>         max_check_attempts              3
>         notification_interval           240
>         contact_groups                  unix-admins
>         servicegroups                   net-resources
>         check_command                   check_ping!100.0,20%!500.0,60%
>         }
> 
> => "Error: Could not expand hostgroups and/or hosts specified in service", 
> pointing to the PING service
> 

My bad. This was a patch I wrote and subsequently dropped. You can, 
however, do *,!croiseur in the service description.

> 
>>You can also turn on regular expression matching and name your 
>>hostgroups so that you can use it easily. It will triple the load-time 
>>of nagios but you will get what you want (with fewer lines of config 
>>than earlier).
> 
> 
> What do you mean ?  Even the following is rejected:
> 
> define hostgroup{
>         hostgroup_name  g1,g2
>         alias           whatever
> }
> 
> => "Error: The name of hostgroup 'g1,g2' contains one or more illegal 
> characters."
> 


Naturally. hostgroup_name is the object identifier of the hostgroup 
object. It follows all the rules for such object. When *referencing* 
such objects you can use regular expressions.

define service {
	service_description PING
	hostgroup_name      ^g[12]$
	check_command       check_ping!200.0,60%!500.0,80%
}

would set a service PING for all hosts in hostgroups g1 and g2.


> Regexps are also quite under-documented - eg. there are so many flavours 
> of them, which one was selected ?  Plain POSIX ones ?
> 

Basic posix regexes, I believe. As for flavours, all regexes have the 
same base features (and there aren't "so many". There are three; POSIX, 
Extended POSIX and Perl. Perl regexes are pretty much only used in perl 
and POSIX and extended POSIX are very similar).

> I also tried, with use_regexp_matching=1, "hostgroup_name  g[12]"  (which 
> is accepted but counts for a single hostgroup !), and "hostgroup_name 
> g(1|2)" which is refused as "contains one or more illegal characters".
> 

See above on naming and referencing.

> And even if that would work, I would need back-references on groups in the 
> regexps, so the alias can be something meaningful.  Can we do that, and if 
> yes, using which syntax ?
> 

This I don't understand at all, but most likely it ties in with 
referencing and naming. The _name_ of an object isn't supposed to be a 
regex; The reference to it is.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20




More information about the Developers mailing list