diff options
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 | 14 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Threshold.pm | 3 |
4 files changed, 15 insertions, 6 deletions
diff --git a/lib/Nagios/Plugin.pm b/lib/Nagios/Plugin.pm index b0b053d..bd0d483 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.31"; | 28 | our $VERSION = "0.32"; |
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 c7e899c..165aafa 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.31"; | 15 | our $VERSION = "0.32"; |
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 c35653e..6b85dc0 100644 --- a/lib/Nagios/Plugin/Performance.pm +++ b/lib/Nagios/Plugin/Performance.pm | |||
@@ -30,7 +30,7 @@ my $value_with_negative_infinity = qr/$value_re|~/; | |||
30 | sub _parse { | 30 | sub _parse { |
31 | my $class = shift; | 31 | my $class = shift; |
32 | my $string = shift; | 32 | my $string = shift; |
33 | $string =~ /^([^=]+)=($value_re)([\w%]*);?($value_with_negative_infinity\:?$value_re?)?;?($value_with_negative_infinity\:?$value_re?)?;?($value_re)?;?($value_re)?/o; | 33 | $string =~ /^'?([^'=]+)'?=($value_re)([\w%]*);?($value_with_negative_infinity\:?$value_re?)?;?($value_with_negative_infinity\:?$value_re?)?;?($value_re)?;?($value_re)?/o; |
34 | return undef unless ((defined $1 && $1 ne "") && (defined $2 && $2 ne "")); | 34 | return undef unless ((defined $1 && $1 ne "") && (defined $2 && $2 ne "")); |
35 | my @info = ($1, $2, $3, $4, $5, $6, $7); | 35 | my @info = ($1, $2, $3, $4, $5, $6, $7); |
36 | # We convert any commas to periods, in the value fields | 36 | # We convert any commas to periods, in the value fields |
@@ -60,8 +60,13 @@ sub _nvl { | |||
60 | 60 | ||
61 | sub perfoutput { | 61 | sub perfoutput { |
62 | my $self = shift; | 62 | my $self = shift; |
63 | # Add quotes if label contains a space character | ||
64 | my $label = $self->label; | ||
65 | if ($label =~ / /) { | ||
66 | $label = "'$label'"; | ||
67 | } | ||
63 | my $out = sprintf "%s=%s%s;%s;%s;%s;%s", | 68 | my $out = sprintf "%s=%s%s;%s;%s;%s;%s", |
64 | $self->label, | 69 | $label, |
65 | $self->value, | 70 | $self->value, |
66 | $self->_nvl($self->uom), | 71 | $self->_nvl($self->uom), |
67 | $self->_nvl($self->warning), | 72 | $self->_nvl($self->warning), |
@@ -79,8 +84,9 @@ sub parse_perfstring { | |||
79 | my $obj; | 84 | my $obj; |
80 | while ($perfstring) { | 85 | while ($perfstring) { |
81 | $perfstring =~ s/^\s*//; | 86 | $perfstring =~ s/^\s*//; |
82 | if ($perfstring =~ /\s/) { | 87 | # If there is more than 1 equals sign, split it out and parse individually |
83 | $perfstring =~ s/^(.*?)\s//; | 88 | if (@{[$perfstring =~ /=/g]} > 1) { |
89 | $perfstring =~ s/^(.*?=.*?)\s//; | ||
84 | $obj = $class->_parse($1); | 90 | $obj = $class->_parse($1); |
85 | } else { | 91 | } else { |
86 | $obj = $class->_parse($perfstring); | 92 | $obj = $class->_parse($perfstring); |
diff --git a/lib/Nagios/Plugin/Threshold.pm b/lib/Nagios/Plugin/Threshold.pm index 145b89f..73fce53 100644 --- a/lib/Nagios/Plugin/Threshold.pm +++ b/lib/Nagios/Plugin/Threshold.pm | |||
@@ -39,6 +39,9 @@ sub _inflate | |||
39 | return $value; | 39 | return $value; |
40 | } | 40 | } |
41 | 41 | ||
42 | # Another quick exit if $value is an empty string | ||
43 | return Nagios::Plugin::Range->new if $value eq ""; | ||
44 | |||
42 | # Otherwise parse $value | 45 | # Otherwise parse $value |
43 | my $range = Nagios::Plugin::Range->parse_range_string($value); | 46 | my $range = Nagios::Plugin::Range->parse_range_string($value); |
44 | nagios_die("Cannot parse $key range: '$value'") unless(defined($range)); | 47 | nagios_die("Cannot parse $key range: '$value'") unless(defined($range)); |