melguin has asked for the wisdom of the Perl Monks concerning the following question:
The code is supposed to see how the current values (from the %CONFIG hash) compare to the min and max values from the log, then make it the min_value or max_value if it is less than or greater than them (respectively). Here's a snippet of the code:#ErrorLevel,Computer,IDO,Description,MinValue,MinTime,MaxValue,MaxTim +e,CurrentValue,CurrentTime 0,localhost,1.3.6.1.4.1.314.50.1.20.3.1.3,CFG persistent MEM,18720,11: +29,18760,12:30,17176,14:26
The problem is that at least sometimes have a current value that is less than the min_value, but doesn't get passed on to it (as in the log file line above).if (! /^\s*(\d),(\w+),([\d\.]+),([^,]+),([^,]+),(\d+:\d+),([^,]+),(\d+ +:\d+),.*$/ ) { exit_error("Cannot parce log file") } $level=$1; $computer=$2; $iod=$3; $comment=$4; $min_value=$5; $min_time=$6; $max_value=$7; $max_time=$8; if ( $CONFIG{$computer}{iod}{$iod}{value} =~ /\w+/ ) {} elsif ( $CONFIG{$computer}{iod}{$iod}{value} < $min_value ) { $min_value = $CONFIG{$computer}{iod}{$iod}{value}; $min_time = "$hour:$min"; } elsif ( $CONFIG{$computer}{iod}{$iod}{value} > $max_value ) { $max_value = $CONFIG{$computer}{iod}{$iod}{value}; $max_time = "$hour:$min"; } print LOG "$level,$computer,$iod,$comment,$min_value,$min_time,$max_va +lue, $max_time,$CONFIG{$computer}{iod}{$iod}{value},$hour:$min\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: When is not necessarily
by Ovid (Cardinal) on Oct 04, 2001 at 02:11 UTC | |
|
Re: When is not necessarily
by tommyw (Hermit) on Oct 04, 2001 at 02:19 UTC | |
by melguin (Pilgrim) on Oct 04, 2001 at 02:27 UTC | |
by tachyon (Chancellor) on Oct 04, 2001 at 02:43 UTC | |
by tommyw (Hermit) on Oct 04, 2001 at 02:50 UTC |