# HG changeset patch # User arnold # Date 1344351846 -7200 # Node ID 56583be399db981f9f3453e4e2a0e66463ade666 # Parent 4a92d15de9dd3e348c34937423f04cb632ae5def optimize compare routine diff -r 4a92d15de9dd -r 56583be399db check_roomtemp.pl --- a/check_roomtemp.pl Tue Aug 07 14:51:16 2012 +0200 +++ b/check_roomtemp.pl Tue Aug 07 17:04:06 2012 +0200 @@ -70,40 +70,20 @@ sub report($$$) { my ( $temp, $warning, $critical ) = @_; - $warning = sprintf( "%.2f", $$warning ); - $critical = sprintf( "%.2f", $$critical ); - - $$temp =~ /^(\d+)\.(\d+)/; - my $ta = $1; - my $tb = $2; + $$warning = sprintf( "%.2f", $$warning ); + $$critical = sprintf( "%.2f", $$critical ); - $warning =~ /^(\d+)\.(\d+)/; - my $wa = $1; - my $wb = $2; - - $critical =~ /^(\d+)\.(\d+)/; - my $ca = $1; - my $cb = $2; - - if ( $ta > $ca ) { + if ( $$temp >= $$critical ) { print - "$NAME CRITICAL: +$$temp C | roomtemp=$$temp;$warning;$critical\n"; + "$NAME CRITICAL: +$$temp C | roomtemp=$$temp;$$warning;$$critical\n"; exit $ERRORS{CRITICAL}; } - if ( ( $ta == $ca ) && ( $tb >= $cb ) ) { + if ( $$temp >= $$warning ) { print - "$NAME CRITICAL: +$$temp C | roomtemp=$$temp;$warning;$critical\n"; - exit $ERRORS{CRITICAL}; - } - if ( $ta > $wa ) { - print "$NAME WARNING: +$$temp C | roomtemp=$$temp;$warning;$critical\n"; + "$NAME WARNING: +$$temp C | roomtemp=$$temp;$$warning;$$critical\n"; exit $ERRORS{WARNING}; } - if ( ( $ta == $wa ) && ( $tb >= $wb ) ) { - print "$NAME WARNING: +$$temp C | roomtemp=$$temp;$warning;$critical\n"; - exit $ERRORS{WARNING}; - } - print "$NAME OK: +$$temp C | roomtemp=$$temp;$warning;$critical\n"; + print "$NAME OK: +$$temp C | roomtemp=$$temp;$$warning;$$critical\n"; exit $ERRORS{OK}; }