diff options
Diffstat (limited to 'lib/Nagios/Plugin/Performance.pm')
| -rw-r--r-- | lib/Nagios/Plugin/Performance.pm | 14 |
1 files changed, 10 insertions, 4 deletions
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); |
