DinoTools / monitoring-check_haproxy

Monitoring plugin to check HAProxy with Icinga, Nagios and other compatible monitoring solutions
https://DinoTools.github.io/monitoring-check_haproxy/
GNU General Public License v2.0
7 stars 4 forks source link

The x override flag seems to be broken in release 1.2.0, was working in 1.1.1 #17

Closed cschug closed 7 months ago

cschug commented 1 year ago

In HAProxy I have a default backend which catches all cases where no ACL was matched in a frontend. It just looks like that

backend                                 BE_http_no_match
    mode                                http
    http-request                        deny deny_status 400

It's pretty obvious that this backend will never have any servers, therefore it should be possible to exempt such backends from monitoring. So far, up to release 1.1.1, this was possible by providing -O BE_http_no_match:x as a parameter.

With 1.2.0 running in debug mode I can see that the override is still processed correctly but the check goes critical and complains exactly about that backend which should rather be ignored.

$ check_haproxy -S /run/haproxy-stats.xymon.sock -D u,2,1 -O BE_http_no_match:x --debug | grep BE_http_no_match
build_checks{} building BACKEND check for BE_http_no_match
build_checks{} processing override BE_http_no_match:x
check_backends{} checking BACKEND BE_http_no_match
check_haproxy CRITICAL - Backend BE_http_no_match servers (up: 0, down 0, disabled 0, total 0) | [REDACTED] backend_BE_http_no_match_servers_up=0;2;1;;0 backend_BE_http_no_match_servers_down=0;;;;0 backend_BE_http_no_match_servers_disabled=0;;;;0 backend_BE_http_no_match_sessions=0;4796;5755 [REDACTED]

I'm not really a Perl guy, but the latest code change around the code comment "Merge the two arrays" looks a suspicious to me, because the rewritten regular expression https://github.com/DinoTools/monitoring-check_haproxy/blob/1.2.0/check_haproxy#L150-L154 doesn't match the x case anymore, https://github.com/DinoTools/monitoring-check_haproxy/blob/1.2.0/check_haproxy#L459, and the configuration doesn't get applied.