Re: Threshhold definition has problems with trailing whitespace

Francois Mikus <[email protected]>
Newsgroups gmane.network.cricket.user
Organization Acktomic Net Architects Inc.
Message-ID <[email protected]>
Hello Christian,

Good eye.

You are correct in your patch and statement below that the (.*) variable 
assignments from the regex search were being "greedy" by eating up the 
white space that was in scope. I think the solution in this case is 
trying not to make the regex even more complex as opposed to figuring 
out how to make the white space processing a little more global.

In that vein, I have modified the HandleTarget.pm module to strip out 
all white space that could be lurking about  colons. This way the 
pattern matches do not need to look for whitespace (\s*) at every second 
line. This will cover all possible possible white space sneaking in with 
delimiters, except for trailing tabs or spaces on the threshold end of 
line. Which for some reason screw up processing if I try and remove them 
at the pattern match $Threshold =~ s/[\n\r]+$//g; by using s/\s*$//g; If 
anyone can come up with an answer they get a brownie point, I just do 
not see it at this time.

The white space processing may also fix odd behavior with the :SPAN: 
pattern match which assumed there would be no white space. This is a 
case of having the monitor threshold modified to break the match while 
having meta targets already set. Slim chance, but possible.

Once again, good job in tracking this down.

Francois Mikus

Christian Hammers wrote:
> Hello
>
> The threshold definition given in the documentation did not work for me
> with Cricket 1.0.5. The final whitespace after the comparison datasource
> was not cut and the datasource could thus not be looked up:
>
> monitor-thresholds = ifOutOctets : quotient : > 0.075 pct : : ifSpeed : SNMP"
>
> [29-Jan-2007 14:02:02*] Monitor: Couldn't fetch value for 0 seconds ago from .
> [29-Jan-2007 14:02:02 ] /Server/localhost - netzwerk - ifOutOctets : quotient : > 0.075 pct : : ifSpeed : SNMP passed.
>
> (note that this example only works after adding ifSpeed to the "Linux Boxen" 
> template)
>
> The problem in the code was that the split(/\s*:\s*) does only cut the
> spaces around the delimiter colons but not the prepending or trailing ones.
> To cut at least the latter, I've made the below patch.
>
> bye,
>
> -christian-
>
>
> --- /usr/share/cricket/lib/Common/HandleTarget.pm	2004-05-12 18:58:45.000000000 +0200
> +++ /home/ch/HandleTarget.pm	2007-01-29 14:49:00.000000000 +0100
> @@ -169,7 +169,7 @@
>          my($actionType) = 'SNMP' ;
>          my(@actionArgs);
>          # search for an action tag
> -        if ( $args =~ /^(.*)\s*:\s*(FUNC|EXEC|FILE|MAIL|META)\s*:\s*(.*)$/ ) {
> +        if ( $args =~ /^(.*)\s*:\s*(FUNC|EXEC|FILE|MAIL|META)\s*:\s*(.*?)\s*$/ ) {
>              $args = $1 ;
>              $actionType = $2 ;
>              # restore escaped colons in the monitor args field
> @@ -179,7 +179,7 @@
>              @actionArgs = split(/\s*:\s*/, $action_args);
>              # restore escaped colons in the action args field
>              map { $_ =~ s/\0/:/g } @actionArgs;
> -        } elsif ( $args =~ /^(.*)\s*:\s*(SNMP|META)\s*$/ ) {
> +        } elsif ( $args =~ /^(.*?)\s*:\s*(SNMP|META)\s*$/ ) {
>              $args = $1 ;
>              $actionType = $2 ;
>              # restore escaped colons
>
>   


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.