Nagios / Icinga check multi plugin problem

Nagios / Icinga check multi plugin problem

The Nagios / Icinga plugin check_multi is a convenient tool to execute multiple checks within a single check command that generates an overall returned state and output from it.

It calls multiple child plugins and displays their output in the long_plugin_output. A summary is given in the standard plugin output. The child return code with the highest severity becomes the parent (check_multi) plugin return code.

check_multi problem


When I configure to run multiple nagios/icinga monitoring plugins with check_multi plugin, icinga web server show me this error messages:

OK - 18 plugins checked, 18 ok [global_result_rating: parsing error (Evaluation error in 'COUNT(UNKNOWN) >: 0': syntax error at (eval 16) line 1, near ">" ),global_result_rating: parsing error (Evaluation error in 'COUNT(CRITICAL) >: 0': syntax error at (eval 18) line 1, near ">" )] 
OK - 4 plugins checked, 4 ok [global_result_rating: parsing error (Evaluation error in 'COUNT(WARNING) > 0': syntax error at (eval 15) line 1, near "&gt"  ),global_result_rating: parsing error (Evaluation error in 'COUNT(CRITICAL) > 0': syntax error at (eval 16) line 1, near "&gt"  )]
OK - 18 plugins checked, 18 ok [global_result_rating: parsing error (Evaluation error in 'COUNT(CRITICAL) >: 0': syntax error at (eval 18) line 1, near ">" )] 
OK - 18 plugins checked, 18 ok [global_result_rating: parsing error (Evaluation error in 'COUNT(WARNING) >: 0': syntax error at (eval 17) line 1, near ">" )] 
OK - 17 plugins checked, 17 ok [global_result_rating: parsing error (Evaluation error in 'COUNT(CRITICAL) >: 0': syntax error at (eval 18) line 1, near ">" )] 

Problem is caused when the & character returned in the xml is sometimes double escaped due to the variable sorting of keys in the perl hash which is used to transform the response.

Solution


You must edit check_multi.pl nagios plugin source code:

OLD

#---
#--- helper routine which encodes several XML specific characters
#---
sub xml_encode {
        my $input=shift;
        my %transtab=(
                '\''    => ''',
                '&'     => '&',
                '<'     => '&lt;',
                '>'     => '&gt;',
                '\|'    => '&#124;',
        );
        for (keys(%transtab)) {
                $input=~s/$_/$transtab{$_}/g;
        }
        $input;
}

NEW working solution

#---
#--- helper routine which encodes several XML specific characters
#---
sub xml_encode {
        my $input=shift;
        my %transtab=(
                '\''    => '&#039;',
                '<'     => '&lt;',
                '>'     => '&gt;',
                '\|'    => '&#124;',
        );
        # must encode '&' first, otherwise double encoding can happen
        # hash keys() doesn't guarantee order.
        $input=~s/&/&amp;/g;
        for (keys(%transtab)) {
                $input=~s/$_/$transtab{$_}/g;
        }
        $input;
}

Or you can download my edited check_multi.pl source code.

SUBSCRIBE FOR NEW ARTICLES

@
comments powered by Disqus