From 9d5427f392b4b03b7fd558b4be628653d140f6c0 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Mon, 17 Mar 2008 20:32:11 +0000 Subject: Fixed parsing of negative values and support full range definitions git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/Nagios-Plugin/trunk@1952 f882894a-f735-0410-b71e-b25c423dba1c --- lib/Nagios/Plugin.pm | 2 +- lib/Nagios/Plugin/Functions.pm | 2 +- lib/Nagios/Plugin/Performance.pm | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/Nagios') diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm index b395b68..edcb2c3 100644 --- a/lib/Nagios/Plugin.pm +++ b/lib/Nagios/Plugin.pm @@ -25,7 +25,7 @@ our @EXPORT_OK = qw(%ERRORS); # 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.24"; +our $VERSION = "0.25"; sub new { my $class = shift; diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm index 2638b8d..0f33121 100644 --- a/lib/Nagios/Plugin/Functions.pm +++ b/lib/Nagios/Plugin/Functions.pm @@ -12,7 +12,7 @@ use Params::Validate qw(:types validate); use Math::Calc::Units; # Remember to update Nagios::Plugins as well -our $VERSION = "0.24"; +our $VERSION = "0.25"; our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); diff --git a/lib/Nagios/Plugin/Performance.pm b/lib/Nagios/Plugin/Performance.pm index 55e3ddc..403492c 100644 --- a/lib/Nagios/Plugin/Performance.pm +++ b/lib/Nagios/Plugin/Performance.pm @@ -22,10 +22,12 @@ sub import { Nagios::Plugin::Functions::_use_die($_); } +my $value_re = qr/[-+]?[\d\.]+/; +my $value_re_with_negative_infinity = qr/$value_re|~/; sub _parse { my $class = shift; my $string = shift; - $string =~ s/^([^=]+)=([\d\.]+)([\w%]*);?([\d\.]+)?;?([\d\.]+)?;?([\d\.]+)?;?([\d\.]+)?\s*//; + $string =~ s/^([^=]+)=($value_re)([\w%]*);?($value_re_with_negative_infinity\:?$value_re?)?;?($value_re_with_negative_infinity\:?$value_re?)?;?($value_re)?;?($value_re)?\s*//o; return undef unless ((defined $1 && $1 ne "") && (defined $2 && $2 ne "")); my $p = $class->new( label => $1, value => $2+0, uom => $3, warning => $4, critical => $5, -- cgit v1.2.3-74-g34f1