[Nagiosplug-checkins] SF.net SVN: nagiosplug:[2206] Nagios-Plugin/trunk

tonvoon at users.sourceforge.net tonvoon at users.sourceforge.net
Fri Jun 5 19:01:22 CEST 2009


Revision: 2206
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2206&view=rev
Author:   tonvoon
Date:     2009-06-05 17:01:21 +0000 (Fri, 05 Jun 2009)

Log Message:
-----------
Fixed parsing when two = signs within the performance data portion

Modified Paths:
--------------
    Nagios-Plugin/trunk/Changes
    Nagios-Plugin/trunk/lib/Nagios/Plugin/Functions.pm
    Nagios-Plugin/trunk/lib/Nagios/Plugin/Performance.pm
    Nagios-Plugin/trunk/lib/Nagios/Plugin.pm
    Nagios-Plugin/trunk/t/Nagios-Plugin-Performance.t

Modified: Nagios-Plugin/trunk/Changes
===================================================================
--- Nagios-Plugin/trunk/Changes	2009-06-01 20:12:16 UTC (rev 2205)
+++ Nagios-Plugin/trunk/Changes	2009-06-05 17:01:21 UTC (rev 2206)
@@ -1,5 +1,8 @@
 Revision history for Perl module Nagios::Plugin.
 
+0.33 5th June 2009
+  - Fixed infinite loop when invalid performance data with multiple = were present
+
 0.32 3rd March 2009
   - Handle performance data with quotes in the label (thanks to Kang)
   - Die if default config file is not available and --extra-opts is set

Modified: Nagios-Plugin/trunk/lib/Nagios/Plugin/Functions.pm
===================================================================
--- Nagios-Plugin/trunk/lib/Nagios/Plugin/Functions.pm	2009-06-01 20:12:16 UTC (rev 2205)
+++ Nagios-Plugin/trunk/lib/Nagios/Plugin/Functions.pm	2009-06-05 17:01:21 UTC (rev 2206)
@@ -12,7 +12,7 @@
 use Math::Calc::Units;
 
 # Remember to update Nagios::Plugins as well
-our $VERSION = "0.32";
+our $VERSION = "0.33";
 
 our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT);
 

Modified: Nagios-Plugin/trunk/lib/Nagios/Plugin/Performance.pm
===================================================================
--- Nagios-Plugin/trunk/lib/Nagios/Plugin/Performance.pm	2009-06-01 20:12:16 UTC (rev 2205)
+++ Nagios-Plugin/trunk/lib/Nagios/Plugin/Performance.pm	2009-06-05 17:01:21 UTC (rev 2206)
@@ -87,7 +87,14 @@
 		# If there is more than 1 equals sign, split it out and parse individually
 		if (@{[$perfstring =~ /=/g]} > 1) {
 			$perfstring =~ s/^(.*?=.*?)\s//;
-			$obj = $class->_parse($1);
+			if (defined $1) {
+				$obj = $class->_parse($1);
+			} else {
+				# This could occur if perfdata was soemthing=value=
+				# Since this is invalid, we reset the string and continue
+				$perfstring = "";
+				$obj = $class->_parse($perfstring);
+			}
 		} else {
 			$obj = $class->_parse($perfstring);
 			$perfstring = "";

Modified: Nagios-Plugin/trunk/lib/Nagios/Plugin.pm
===================================================================
--- Nagios-Plugin/trunk/lib/Nagios/Plugin.pm	2009-06-01 20:12:16 UTC (rev 2205)
+++ Nagios-Plugin/trunk/lib/Nagios/Plugin.pm	2009-06-05 17:01:21 UTC (rev 2206)
@@ -25,7 +25,7 @@
 # CPAN stupidly won't index this module without a literal $VERSION here,
 #   so we're forced to duplicate it explicitly
 # Make sure you update $Nagios::Plugin::Functions::VERSION too
-our $VERSION = "0.32";
+our $VERSION = "0.33";
 
 sub new {
 	my $class = shift;

Modified: Nagios-Plugin/trunk/t/Nagios-Plugin-Performance.t
===================================================================
--- Nagios-Plugin/trunk/t/Nagios-Plugin-Performance.t	2009-06-01 20:12:16 UTC (rev 2205)
+++ Nagios-Plugin/trunk/t/Nagios-Plugin-Performance.t	2009-06-05 17:01:21 UTC (rev 2206)
@@ -1,4 +1,5 @@
 
+use warnings;
 use strict;
 use Test::More;
 use Nagios::Plugin::Functions;
@@ -40,7 +41,7 @@
   },
 );
 
-plan tests => (11 * scalar @test) + 175;
+plan tests => (11 * scalar @test) + 176;
 
 use_ok('Nagios::Plugin::Performance');
 diag "\nusing Nagios::Plugin::Performance revision ". $Nagios::Plugin::Performance::VERSION . "\n" if $ENV{TEST_VERBOSE};
@@ -349,4 +350,7 @@
 is( $p[2]->max, undef, "max ok");
 
 
+ at p = Nagios::Plugin::Performance->parse_perfstring("processes=9;WKFLSV32.exe;9=");
+is_deeply( \@p, [], "Fails parsing correctly");
+
 # add_perfdata tests in t/Nagios-Plugin-01.t


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list