jonathanio / monitoring-nagios-haproxy

Nagios plugin (suitable for Nagios Check-compatible programs) for monitoring HAProxy services.
GNU General Public License v2.0
16 stars 19 forks source link

Define multiple backends with "--override" doesn't work in Icinga2 #9

Open xtavras opened 5 years ago

xtavras commented 5 years ago

Hello,

I have strange problems, I've defined multiple backends in "--override" option in Icinga2. but somehow, Icinga command run ignores it. Trying to run command copy-pasted from "Inspect" in terminal give the same result.

'/usr/local/hs/icinga-plugins/check_haproxy' '--overrides' 'backend-gscache:,1,0 be-rancher:,2,0 be-letsencrypt:x' '--socket' '/var/lib/haproxy/stats'
HAPROXY CRITICAL: BACKEND be-letsencrypt has fallen below 2 available server(s) (0 up, 0 down, 0 disabled) (check_haproxy 1.0.3)

but if I remove single quotes for --override, it's working

 '/usr/local/hs/icinga-plugins/check_haproxy' '--overrides' backend-gscache:,1,0 be-rancher:,2,0 be-letsencrypt:x '--socket' '/var/lib/haproxy/stats'
HAPROXY OK: HAProxy is functioning within established parameters. (3 frontends, 3 backends, 6 servers, 6 services) (check_haproxy 1.0.3)

Not sure there is the bug, I'm using latest Icinga 2.10 with Director.

object Service "Check HAProxy" {
    host_name = "ldb.example.com"
    import "check haproxy"

    vars.haproxy_overrides = "backend-gscache:,1,0 be-rancher:,2,0 be-letsencrypt:x"
}
bensig commented 2 years ago

I used the code from @fdellinwing to make this work for overrides.

Critical to have this change for the haproxy plugin to be functional on icinga2. Does not appear to be reflected in the state on master branch.

        "--overrides" = {
            value = {{
                return macro("$haproxy_overrides$").split(" ")
            }}            
            description = "Override the defaults for a particular frontend or backend, in the form {name}:{override}, where {override} is the same format as --defaults above."
        }