diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-01-28 07:17:24 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-01-28 07:17:24 +0000 |
commit | dbad749293f31ccb3af226d30b664c1c5f9b1458 (patch) | |
tree | 93511f6bd40dab27bc722d584ff368e01467afbf /contrib/checkciscotemp.pl | |
parent | 9452b46d955a3e99837214c77ad48dae4a7bf7cd (diff) | |
download | monitoring-plugins-dbad749293f31ccb3af226d30b664c1c5f9b1458.tar.gz |
split and validate input more robustly
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@257 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/checkciscotemp.pl')
-rw-r--r-- | contrib/checkciscotemp.pl | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/contrib/checkciscotemp.pl b/contrib/checkciscotemp.pl index a702a89e..c999e193 100644 --- a/contrib/checkciscotemp.pl +++ b/contrib/checkciscotemp.pl | |||
@@ -30,7 +30,7 @@ | |||
30 | # (in accordance with the plugin coding guidelines) | 30 | # (in accordance with the plugin coding guidelines) |
31 | #################################### | 31 | #################################### |
32 | 32 | ||
33 | use Net::SNMP; | 33 | #use Net::SNMP; |
34 | use Getopt::Long; | 34 | use Getopt::Long; |
35 | &Getopt::Long::config('auto_abbrev'); | 35 | &Getopt::Long::config('auto_abbrev'); |
36 | 36 | ||
@@ -81,16 +81,19 @@ unless (defined($hostname)) { | |||
81 | } | 81 | } |
82 | 82 | ||
83 | if (defined($critical_vals)) { | 83 | if (defined($critical_vals)) { |
84 | die "Cannot Parse Critical Thresholds\n" | 84 | if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { |
85 | unless (split(/:/,$critical_vals)>=2); | 85 | ($inlet_thresh,$outlet_thresh) = ($1, $2); |
86 | ($inlet_thresh,$outlet_thresh) = @_ | 86 | } else { |
87 | die "Cannot Parse Critical Thresholds\n"; | ||
88 | } | ||
87 | } | 89 | } |
88 | die unless(defined($inlet_thresh) && defined($outlet_thresh)); | ||
89 | 90 | ||
90 | if (defined($warning_vals)) { | 91 | if (defined($warning_vals)) { |
91 | die "Cannot Parse Critical Thresholds\n" | 92 | if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { |
92 | unless (split(/:/,$warning_vals)>=2); | 93 | ($inlet_warn,$outlet_warn) = ($1, $2); |
93 | ($inlet_warn,$outlet_warn) = @_; | 94 | } else { |
95 | die "Cannot Parse Warning Thresholds\n"; | ||
96 | } | ||
94 | }else{ | 97 | }else{ |
95 | $inlet_warn=$inlet_thresh; | 98 | $inlet_warn=$inlet_thresh; |
96 | $outlet_warn=$outlet_thresh; | 99 | $outlet_warn=$outlet_thresh; |