Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-05 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls