Threshhold definition has problems with trailing whitespace
Christian Hammers <[email protected]>
| Newsgroups | gmane.network.cricket.user |
|---|---|
| Message-ID | <[email protected]> |
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
--
Christian Hammers WESTEND GmbH | Internet-Business-Provider
Technik CISCO Systems Partner - Authorized Reseller
Lütticher Straße 10 Tel 0241/701333-11
[email protected] D-52064 Aachen Fax 0241/911879
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV