[monitoring-plugin-perl] Performance.pm->perfoutput does not handle empty value correctly (#4)

daku3649 notifications at github.com
Thu Dec 3 08:50:27 CET 2015

I use check_squid.pl developed by Cyril Feraudet in Version 1.1

That uses package Nagios::Plugin which is version 0.36

The script gives out invalid performance data because value is sometimes
empty and that is not handleded correctly and leads to invalid performance
data output.

check_squid.pl creates a new Nagios::Plugin object and then adds the
performance value with method add_perfdata 

pnp4nagios claims invalid performance data, which is true, because after the
= sign comes directly the UOM:

`2015-11-27 11:45:06 [2996] [1] Found Performance Data for MYHOST /
Squid_Cache ('Requests Hit Ratio 5min'=0.0%;; 'Requests Hit Ratio
60min'=0.2%;; 'Byte Hit Ratio 5min'=%;; 'Byte Hit Ratio 60min'=%;;)
2015-11-27 11:45:06 [2996] [1] Invalid Perfdata detected`

I did a workaround for this in Performance.pm perfoutput method like so:

sub perfoutput {
    my $self = shift;
    # Add quotes if label contains a space character
    my $label = $self->label;
    if ($label =~ / /) {
        $label = "'$label'";

    my $value = $self->value;

    if ($value eq '') {
        $value = 'U';

    my $out = sprintf "%s=%s%s;%s;%s;%s;%s",
    # Previous implementation omitted trailing ;; - do we need this?
    $out =~ s/;;$//;

    return $out;
So if value is empty, it is changed to value "U" which means that the value
could not have been determined, according to Nagios Plugin development
guidelines, section Performance data.

Reply to this email on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20151202/c6524be4/attachment.html>

More information about the Devel mailing list