diff options
Diffstat (limited to 'lib/Nagios/Plugin')
-rw-r--r-- | lib/Nagios/Plugin/Functions.pm | 2 | ||||
-rw-r--r-- | lib/Nagios/Plugin/Performance.pm | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/Nagios/Plugin/Functions.pm b/lib/Nagios/Plugin/Functions.pm index b7348f3..c7e899c 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.30"; | 15 | our $VERSION = "0.31"; |
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 df591fb..c35653e 100644 --- a/lib/Nagios/Plugin/Performance.pm +++ b/lib/Nagios/Plugin/Performance.pm | |||
@@ -35,8 +35,18 @@ sub _parse { | |||
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 |
37 | map { defined $info[$_] && $info[$_] =~ s/,/./go } (1, 3, 4, 5, 6); | 37 | map { defined $info[$_] && $info[$_] =~ s/,/./go } (1, 3, 4, 5, 6); |
38 | |||
39 | # Check that $info[1] is an actual value | ||
40 | # We do this by returning undef if a warning appears | ||
41 | my $performance_value; | ||
42 | { | ||
43 | my $not_value; | ||
44 | local $SIG{__WARN__} = sub { $not_value++ }; | ||
45 | $performance_value = $info[1]+0; | ||
46 | return undef if $not_value; | ||
47 | } | ||
38 | my $p = $class->new( | 48 | my $p = $class->new( |
39 | label => $info[0], value => $info[1]+0, uom => $info[2], warning => $info[3], critical => $info[4], | 49 | label => $info[0], value => $performance_value, uom => $info[2], warning => $info[3], critical => $info[4], |
40 | min => $info[5], max => $info[6] | 50 | min => $info[5], max => $info[6] |
41 | ); | 51 | ); |
42 | return $p; | 52 | return $p; |