in reply to Re^2: What did I miss in my test condition?
in thread What did I miss in my test condition?
I don't think $line will every be empty - you probably ought to chomp it, or test for non-whitespace.
And you still have unnecessary tests in your if-elsif. For example, if $score is NOT greater-than $warnrate, it IS NECESSARILY less-than-or-equal-to $warnrate.
Consider:
use strict; my $radio = $ARGV[0]; my $warnrate = $ARGV[1]; my $critrate = $ARGV[2]; chomp(my $line = `/usr/bin/snmpwalk -v1 -c PTsnmp $radio .1.3.6.1.4.1. +5454.1.40.2.4.0`; if ($line !~ /\S/) { print "snmpwalk returned nothing, timeout likely occurred.\n"; exit 3; } elsif ($critrate > $warnrate) { print "Make sure your critical value is less than or equal to your +warning value.\n"; exit 5; } else { my $score = (split(' ', $line))[3]; my ($msg,$status) = $score > $warnrate ? ('OK',0) : ( $score > $critrate ? ('WARNING',1) : ('CRITICAL',2)); print "$msg, rf is $score. |Mbps=$score\n"; exit $status; }
|
|---|