Search code examples
socketsredhathaproxyzabbix

Zabbix-agent on HAProxy discover load-balanced host doesn't show up on Zabbix Server


I have been following this tutorial for a moment but I don't know why it isn't working: https://github.com/anapsix/zabbix-haproxy/blob/master/README.md

To make a long story short: I have a Zabbix server on Amazon EC2 and I want to monitor a HAproxy server which is inside my network. The HAProxy Server has a Zabbix Agent working on it. The tutorial explain how to setup a script for the zabbix-agent to explore what's behind it (what's the haproxy is load-balancing) and send it back to the Zabbix Server.

However everything is working fine but nothing shows up on the Zabbix server, no host are discovered despite the zabbix agent and server are communicating.

1 - I did place the userparameter_haproxy.conf into /etc/zabbix/zabbix_agentd.d/ and set it in the zabbix_agend.conf file.

2 - I did place the haproxy_discovery.sh into /usr/local/bin/ and gave it the +x rights

3 - I did import haproxy_zbx_template.xml

4 - Configure HAProxy control socket: I assume there is my mistake.

5- The scripts are working because I get result when I execute this commands:

zabbix_agentd -t haproxy.list.discovery[FRONTEND]
zabbix_agentd -t haproxy.list.discovery[BACKEND]
zabbix_agentd -t haproxy.list.discovery[SERVERS]

6 - I added the host with HAproxy on it to the right template

7 - I can wait forever nothing is showing up, no new hosts.

I think the step 4 is where I am doing wrong. In the tutorial they say:

Configure HAProxy to listen on /var/run/haproxy/info.sock or set custom socket path in checks (set {$HAPROXY_SOCK} template macro to your custom socket path) or update userparameter_haproxy.conf and haproxy_discovery.sh with your socket path

I did make the haproxy.cfg file listen to the file /var/lib/haproxy/stats and set a custom socket path in the template macro.

Additionnal info: Version of Zabbix: 3.4 Zabbix Server: RHEL 7.4 Zabbix Agent: Centos 7.2 No errors when I restart zabbix-agent No errors in haproxy.log


UPDATE: I did add Zabbix to the root group.

Now, in Zabbix server logs I can see this message:

changed: Value "which: no nc in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
2" of type "string" is not suitable for value type "Numeric (unsigned)"

And I'm lost again.


UPDATE: I was missing netcat, I installed it on the zabbix server and client.


UPDATE: It's working


Solution

  • According to your update, I guess netcat (nc) is not installed on your system.

    Install it and try again