From dbad749293f31ccb3af226d30b664c1c5f9b1458 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Tue, 28 Jan 2003 07:17:24 +0000 Subject: split and validate input more robustly git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@257 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/contrib/checkciscotemp.pl b/contrib/checkciscotemp.pl index a702a89..c999e19 100644 --- a/contrib/checkciscotemp.pl +++ b/contrib/checkciscotemp.pl @@ -30,7 +30,7 @@ # (in accordance with the plugin coding guidelines) #################################### -use Net::SNMP; +#use Net::SNMP; use Getopt::Long; &Getopt::Long::config('auto_abbrev'); @@ -81,16 +81,19 @@ unless (defined($hostname)) { } if (defined($critical_vals)) { - die "Cannot Parse Critical Thresholds\n" - unless (split(/:/,$critical_vals)>=2); - ($inlet_thresh,$outlet_thresh) = @_ + if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { + ($inlet_thresh,$outlet_thresh) = ($1, $2); + } else { + die "Cannot Parse Critical Thresholds\n"; + } } -die unless(defined($inlet_thresh) && defined($outlet_thresh)); if (defined($warning_vals)) { - die "Cannot Parse Critical Thresholds\n" - unless (split(/:/,$warning_vals)>=2); - ($inlet_warn,$outlet_warn) = @_; + if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { + ($inlet_warn,$outlet_warn) = ($1, $2); + } else { + die "Cannot Parse Warning Thresholds\n"; + } }else{ $inlet_warn=$inlet_thresh; $outlet_warn=$outlet_thresh; -- cgit v0.10-9-g596f