true regexp enhancement

Robert Bossecker nagios-d-rb at bossecker.de
Fri Jan 21 04:52:15 CET 2005


Andreas Ericsson wrote:

> 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.).
>
yes i know, but it is very inconvenient for someone who only needs true 
regexps in a few definitions to convert all
other arguments as well. if the parser would have a optional switch to 
embed the patterns by itself one can
turn his config with less work into a true regexp config. This is IMHO 
more failsafe.

>> 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.
>
this is one problem, because on older dists or wrong OSes there is only 
the old style sed which does not support inplace editing. And it will 
not be sufficient only to change the services.cfg you need also to 
convert servicedependencies as
well and all other stuff like contacts which is expanded with regexps.

>> 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.
>
as written above when possible otherwise you need only to take care 
about your "needed" regexps instead
of thousand implied regexps.

i'll figure out how mutch it is to add a configurable behaviour.




-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl




More information about the Developers mailing list