Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^3: What did I miss in my test condition?

by hbm (Hermit)
on Aug 13, 2012 at 00:53 UTC ( #987005=note: print w/replies, xml ) Need Help??

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.


use strict; my $radio = $ARGV[0]; my $warnrate = $ARGV[1]; my $critrate = $ARGV[2]; chomp(my $line = `/usr/bin/snmpwalk -v1 -c PTsnmp $radio . +5454.`; 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; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://987005]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2017-07-27 21:44 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (422 votes). Check out past polls.