jjbuchan / docs

0 stars 0 forks source link

How to see if haproxy thinks a backend is down #6

Open jjbuchan opened 3 years ago

jjbuchan commented 3 years ago

Log into the desired server and pull the current haproxy stats:

echo "show stat" | sudo nc -U /etc/sv/haproxy/locks/haproxy.sock|awk "NR == 1 {print} /DOWN/ {print}"

They will have an "svname" of "127.0.0.n" where "n" is the service instance + 3. So "endpoint-6" is "127.0.0.9". If you see a down one, see if it is not properly listening on its 127.* address:

netstat -an|grep 127.0.0.$N|grep LISTEN

If it's not, that service instance likely needs to be restarted. NOTE it might take an sv force-stop to really stop it. Check that it is really gone in ps after attempted stop.

You also list all of the HAproxy services including the status column in a pretty format using:

echo "show stat" | \
  sudo nc -U /etc/sv/haproxy/locks/haproxy.sock| \
  cut -d, -f-18 | column -s, -nt