February 2020
Intermediate to advanced
734 pages
38h 13m
English
One of the reasons we enabled the HAProxy stats socket is so we can send commands to the service. Some of these are diagnostic, while others are commands to manage the backends themselves.
Rather than connecting and then using the inet_server_addr function to determine which PostgreSQL node we're connecting to as we have done in the past, we can simply ask HAProxy. If we have socat installed, all it takes is this command to show the state of the stick table:
echo "show table bk_db" | socat /var/run/haproxy/sock -
Assuming that the HAProxy service was freshly restarted, we should see something like this:

HAProxy numbers server ...
Read now
Unlock full access