anapsix / zabbix-haproxy

HAProxy Zabbix Discovery and Template
170 stars 77 forks source link

zabbix_agentd fails with zabbix-haproxy conf #52

Closed davama closed 4 years ago

davama commented 5 years ago

I cannot get this to work :disappointed:

Below command gives this output:

/usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf -p
haproxy.list.discovery                        [t|{
    "data":[

        {
            "{#FRONTEND_NAME}":"stats"},
        {
            "{#FRONTEND_NAME}":"xml50"},
        {
            "{#FRONTEND_NAME}":"xml40_nonsecure"},
        {
            "{#FRONTEND_NAME}":"xml40_secure"},
        {
            "{#FRONTEND_NAME}":"main"}]}]
haproxy.stats                                 [t|ERROR:  is unsupported]
haproxy.stat.qcur                             [t|ERROR:  is unsupported]
[...]
haproxy.stat.hrsp_3xx                         [t|ERROR:  is unsupported]
haproxy.stat.hrsp_4xx                         [t|ERROR:  is unsupported]
haproxy.stat.hrsp_5xx                         [t|ERROR:  is unsupported]
haproxy.stat.hrsp_other                       [t|ERROR:  is unsupported]
haproxy.stat.hanafail                         [t|ERROR:  is unsupported]
haproxy.stat.last_chk                         [t|ERROR:  is unsupported]
haproxy.stat.last_agt                         [t|ERROR:  is unsupported]

Running below works well:

echo "show stat" | nc -U /run/haproxy.sock | cut -d "," -f 1,2,5-11,18,24,27,30,36,50,37,56,57,62 | column -s, -t

Our /etc/haproxy/haproxy.cfg

global
[...]
   stats socket /run/haproxy.sock  mode 666 level user
id zabbix
uid=995(zabbix) gid=993(zabbix) groups=993(zabbix),994(haproxy)

Noticed that this guys had similar issues but not sure what the resolution was: https://github.com/anapsix/zabbix-haproxy/issues/46

zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 4.4.0alpha3

Any input is appreciated!

Thanks, dave

davama commented 5 years ago
haproxy_stats.sh xml50 FRONTEND  status
OPEN

$2 and $3 are reverse

https://github.com/anapsix/zabbix-haproxy#haproxy_statssh-script

Hmm :thinking:

anapsix commented 5 years ago

admittedly, it's been a while sine I've made or used it.. haproxy_stats.sh takes optional HAProxy socket path as first argument, the name of the frontend/backend as second, BACKEND or FRONTEND as third argument, and name of the stat as last. (Shift by one if socket path is not used as first argument) So, haproxy_stats.sh xml50 FRONTEND status should work. When creating Zabbix items, the order might be different, so take a look at the template. Hope that helps..

davama commented 5 years ago

Thank you for the reply!

Any input on the “is unsupported” error?

Thanks!!

anapsix commented 5 years ago

46 might be helpful in finding ways of debugging it, as well as other closed issues

basically, trace it step by step, check if cache file get's generated and contains data, check if it's owned by whatever user Zabbix Agent is running as, try some manual steps described in userparameter_haproxy.conf#L81-L108, making sure you get data Also, consider using haproxy.stats[*] instead of haproxy.stat.*

davama commented 5 years ago

Yeah i reviewed #46 before posting. I'll keep looking/testing and report back if anything new. Thanks!

davama commented 5 years ago

Thanks again for replying!

davama commented 4 years ago

Trying to revisit this...

At a lost at what could be the issue. I see no data in zabbix dashboard :( I've looked on the issues to see what others have done and implemented some things but no change.

> su zabbix -s /bin/bash -c 'echo "show stat" | socat /var/run/haproxy/info.sock stdio'
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,agent_status,agent_code,agent_duration,check_desc,agent_desc,check_rise,check_fall,check_health,agent_rise,agent_fall,agent_health,addr,cookie,mode,algo,conn_rate,conn_rate_max,conn_tot,intercepted,dcon,dses,
stats,FRONTEND,,,1,2,2000,129,548539,185729357,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,1,,,,0,1431,0,0,0,0,,1,2,1431,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,0,1,129,1431,0,0,
stats,BACKEND,0,0,0,0,200,0,548539,185729357,0,0,,0,0,0,0,UP,0,0,0,,0,1980,,,1,2,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,0,0,0,0,0,0,0,0,,,0,0,2,1311,,,,,,,,,,,,,,http,,,,,,,,
xml50,FRONTEND,,,422,968,2000,172224,733076324,643135894,0,0,5796,,,,,OPEN,,,,,,,,,1,3,0,,,,0,103,0,295,,,,0,630461,0,5796,10087,28,,381,662,646423,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,100,405,173206,0,1,0,
xml40_nonsecure,FRONTEND,,,142,300,2000,100695,130963405,841462560,0,0,42,,,,,OPEN,,,,,,,,,1,4,0,,,,0,30,0,218,,,,0,111784,0,42,466,0,,38,234,112297,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,30,218,100695,0,0,0,
xml40_secure,FRONTEND,,,230,1466,2000,242857,426953727,1063020370,0,0,3915,,,,,OPEN,,,,,,,,,1,5,0,,,,0,138,0,557,,,,0,391875,0,3915,1798,6,,223,841,397629,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,157,610,243616,0,0,0,
main,FRONTEND,,,0,71,2000,2659,2049672,182630069,0,0,0,,,,,OPEN,,,,,,,,,1,6,0,,,,0,0,0,69,,,,0,2659,0,0,3,0,,0,69,2662,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,0,69,2659,0,0,0,
jwebs,jweb01,0,0,0,8,10,7919,9157290,55752994,,0,,0,0,0,0,UP,1,1,0,0,0,1980,0,,1,7,1,,7919,,2,2,,17,L4OK,,6,0,7886,0,0,33,0,,,,,0,0,,,,,0,,,0,2,56,206,,,,Layer4 check passed,,2,3,4,,,,,,http,,,,,,,,
jwebs,jweb02,0,0,0,9,10,7840,9164621,55773480,,0,,0,0,0,0,UP,1,1,0,0,0,1980,0,,1,7,2,,7840,,2,3,,19,L4OK,,6,0,7809,0,0,31,0,,,,,0,0,,,,,0,,,0,2,63,204,,,,Layer4 check passed,,2,3,4,,,,,,http,,,,,,,,
jwebs,jweb03,0,0,0,8,10,8186,9526070,48154442,,0,,0,0,0,0,UP,1,1,0,0,0,1980,0,,1,7,3,,8186,,2,3,,19,L4OK,,6,0,8154,0,0,32,0,,,,,0,0,,,,,0,,,0,2,53,188,,,,Layer4 check passed,,2,3,4,,,,,,http,,,,,,,,
[...]

There are no files in /var/tmp/ :confused:

> su zabbix -s /bin/bash -c 'sudo --list'
[...]
User zabbix may run the following commands on haproxy-01:
    (root) NOPASSWD: /usr/bin/nmap, /usr/local/bin/haproxy_discovery.sh, /usr/local/bin/haproxy_stats.sh, /usr/bin/nc, /usr/bin/socat

Any input is appreciated.

Thanks!

anapsix commented 4 years ago

checkout a note about SELinux to the Troubleshooting, and https://github.com/anapsix/zabbix-haproxy/issues/55