=================================================================== RCS file: /cvs/nagios/check_rrd/bin/average_rrd,v retrieving revision 1.1 retrieving revision 1.3 diff -u -r1.1 -r1.3 --- nagios/check_rrd/bin/average_rrd 2006/05/08 20:52:53 1.1 +++ nagios/check_rrd/bin/average_rrd 2006/11/07 19:55:30 1.3 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -# $RedRiver$ +# $RedRiver: average_rrd,v 1.2 2006/05/08 22:22:19 andrew Exp $ use strict; use warnings; @@ -8,8 +8,10 @@ use constant VERBOSE => 0; -my $file = shift || '/var/www/wstationinfo/rrlhcwap3056/rrlhcwap3056-id_6-RSSI.rrd'; +my $file = shift || 'test.rrd'; +die "File '$file' does not exist!" unless -e $file; + my %TIMES = ( FIVE_MINUTES => 5 * 60, ONE_HOUR => 1 * 60 * 60, @@ -56,8 +58,17 @@ next unless defined $line->[$i]; foreach my $key (keys %TIMES) { if ($end - $TIMES{$key} < $start) { + foreach ('max', 'min') { + $totals{ $names->[$i] }{$key}{$_} = $line->[$i] + unless defined $totals{ $names->[$i] }{$key}{$_}; + } + no warnings q/uninitialized/; $totals{ $names->[$i] }{$key}{'count'}++; $totals{ $names->[$i] }{$key}{'total'} += $line->[$i]; + $totals{ $names->[$i] }{$key}{'max'} = $line->[$i] + if $totals{ $names->[$i] }{$key}{'max'} < $line->[$i]; + $totals{ $names->[$i] }{$key}{'min'} = $line->[$i] + if $totals{ $names->[$i] }{$key}{'min'} > $line->[$i]; } } }