HAProxy — alert when any backend goes DOWN
HAProxy balances over 5 backends; one starts erroring and goes DOWN. Alert before users notice.
Recipe
bash
#!/usr/bin/env bash
# Reads HAProxy stats socket; prints "ok" if every backend is UP, "down N" otherwise.
SOCK="${SOCK:-/var/run/haproxy/admin.sock}"
DOWN=$(echo "show stat" | socat - "UNIX-CONNECT:$SOCK" \
| awk -F, 'NR>1 && $2 != "FRONTEND" && $2 != "BACKEND" && $18 == "DOWN" {print $2"/"$1}')
[ -z "$DOWN" ] && echo "ok" || echo "down $DOWN"
Same thing in Enterno.io
Expose the endpoint and point an Enterno HTTP monitor at it with rule "body = ok". Multi-region check (Pro+) confirms whether DOWN is real or an edge-router blip.
Related recipes
Production ES cluster goes yellow status. Need an alert now, not 30 minutes later via Kibana.
Ensure your site returns 2xx every minute, alert to Slack/Telegram on failure.
Minimal script that checks an SSL certificate and alerts 14 days before expiry.