Re: [Nagios-devel] true regexp enhancement
Posted: Wed Jan 19, 2005 12:08 am
Robert Bossecker wrote:
> Hello,
>
> after turning thousands of lines when trying the
> use_true_regexp_matching i thought if this
> feature may be enhanced by surrounding the pattern string automatically
> with "^" and "$"
> so there is no need to cover each string to prevent double matches. This
> may be
> configurable.
>
> If i have a host named "linux1" and i have also hosts named "linux10"
> and "linux11"
> there will be a complain about, that a service for linux10 oder linux11
> is already defined,
> caused by the service definition for this service when writing
>
> define service{
> host_name linux1
> service_description PING
> check_command check_ping...
> }
>
> this will unfortunately math all hosts beginning oder containing "linux1"
>
That is the expected behaviour and the general idea, letting you use a
namestandard to define identical services for all of your linux-servers
(f.e.).
> If the patterns will be surrounded by begin and end patterns there is no
> need to change thousands of
> definitions.
sed -i 's/\(.*host_name\)\([ \t]*\)\([^ \t]*\)/\1\2^\3$/' services.cfg
You need sed version 4.0.9 or later for the -i switch to work. Prior to
4.1.1 will clobber your file permissions/owner when you're done.
> Then a match for all hostnames beginning with "linux1" must be written
> as "linux1.*" which expicitly says i want
> additional characters.
>
The documentation on use_true_regexp matching states that you need to
take care. If you enable it, you should circumscribe all your non-regexp
statements with ^$ yourself.
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
> Hello,
>
> after turning thousands of lines when trying the
> use_true_regexp_matching i thought if this
> feature may be enhanced by surrounding the pattern string automatically
> with "^" and "$"
> so there is no need to cover each string to prevent double matches. This
> may be
> configurable.
>
> If i have a host named "linux1" and i have also hosts named "linux10"
> and "linux11"
> there will be a complain about, that a service for linux10 oder linux11
> is already defined,
> caused by the service definition for this service when writing
>
> define service{
> host_name linux1
> service_description PING
> check_command check_ping...
> }
>
> this will unfortunately math all hosts beginning oder containing "linux1"
>
That is the expected behaviour and the general idea, letting you use a
namestandard to define identical services for all of your linux-servers
(f.e.).
> If the patterns will be surrounded by begin and end patterns there is no
> need to change thousands of
> definitions.
sed -i 's/\(.*host_name\)\([ \t]*\)\([^ \t]*\)/\1\2^\3$/' services.cfg
You need sed version 4.0.9 or later for the -i switch to work. Prior to
4.1.1 will clobber your file permissions/owner when you're done.
> Then a match for all hostnames beginning with "linux1" must be written
> as "linux1.*" which expicitly says i want
> additional characters.
>
The documentation on use_true_regexp matching states that you need to
take care. If you enable it, you should circumscribe all your non-regexp
statements with ^$ yourself.
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]