diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2008-03-17 20:32:11 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2008-03-17 20:32:11 +0000 |
commit | 9d5427f392b4b03b7fd558b4be628653d140f6c0 (patch) | |
tree | 6d52797148baf7371071c05d98a6b60e97f1e6e2 /lib | |
parent | 405590a12a5552df48d8153f91e529bad0a9c528 (diff) | |
download | monitoring-plugin-perl-9d5427f392b4b03b7fd558b4be628653d140f6c0.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Nagios/Plugin.pm | 2 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Functions.pm | 2 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Performance.pm | 4 |
3 files changed, 5 insertions, 3 deletions
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); | |||
25 | # CPAN stupidly won't index this module without a literal $VERSION here, | 25 | # CPAN stupidly won't index this module without a literal $VERSION here, |
26 | # so we're forced to duplicate it explicitly | 26 | # so we're forced to duplicate it explicitly |
27 | # Make sure you update $Nagios::Plugin::Functions::VERSION too | 27 | # Make sure you update $Nagios::Plugin::Functions::VERSION too |
28 | our $VERSION = "0.24"; | 28 | our $VERSION = "0.25"; |
29 | 29 | ||
30 | sub new { | 30 | sub new { |
31 | my $class = shift; | 31 | 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); | |||
12 | use Math::Calc::Units; | 12 | use Math::Calc::Units; |
13 | 13 | ||
14 | # Remember to update Nagios::Plugins as well | 14 | # Remember to update Nagios::Plugins as well |
15 | our $VERSION = "0.24"; | 15 | our $VERSION = "0.25"; |
16 | 16 | ||
17 | our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); | 17 | our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT); |
18 | 18 | ||
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 { | |||
22 | Nagios::Plugin::Functions::_use_die($_); | 22 | Nagios::Plugin::Functions::_use_die($_); |
23 | } | 23 | } |
24 | 24 | ||
25 | my $value_re = qr/[-+]?[\d\.]+/; | ||
26 | my $value_re_with_negative_infinity = qr/$value_re|~/; | ||
25 | sub _parse { | 27 | sub _parse { |
26 | my $class = shift; | 28 | my $class = shift; |
27 | my $string = shift; | 29 | my $string = shift; |
28 | $string =~ s/^([^=]+)=([\d\.]+)([\w%]*);?([\d\.]+)?;?([\d\.]+)?;?([\d\.]+)?;?([\d\.]+)?\s*//; | 30 | $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; |
29 | return undef unless ((defined $1 && $1 ne "") && (defined $2 && $2 ne "")); | 31 | return undef unless ((defined $1 && $1 ne "") && (defined $2 && $2 ne "")); |
30 | my $p = $class->new( | 32 | my $p = $class->new( |
31 | label => $1, value => $2+0, uom => $3, warning => $4, critical => $5, | 33 | label => $1, value => $2+0, uom => $3, warning => $4, critical => $5, |