From 4434110d88683681655b4609782d317504a3f662 Mon Sep 17 00:00:00 2001 From: daku3649 Date: Thu, 3 Dec 2015 12:35:19 +0100 Subject: [PATCH] output empty values as "U" output empty performance data value as value "U" to "indicate that the actual value couldn't be determined" (defined in https://nagios-plugins.org/doc/guidelines.html#AEN200) and do valid output --- lib/Monitoring/Plugin/Performance.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Monitoring/Plugin/Performance.pm b/lib/Monitoring/Plugin/Performance.pm index f1e7a16..0871042 100644 --- a/lib/Monitoring/Plugin/Performance.pm +++ b/lib/Monitoring/Plugin/Performance.pm @@ -64,9 +64,16 @@ sub perfoutput { if ($label =~ / /) { $label = "'$label'"; } + + my $value = $self->value; + # To prevent invalid output, we change empty value to value "U" + if ($value eq '') { + $value = 'U'; + } + my $out = sprintf "%s=%s%s;%s;%s;%s;%s", $label, - $self->value, + $value, $self->_nvl($self->uom), $self->_nvl($self->warning), $self->_nvl($self->critical),