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

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.

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; }


Comment on Re^3: What did I miss in my test condition?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://987005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-07-23 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (154 votes), past polls