RabbitMQ — alert on queue depth growth
Consumer can not keep up; queue grows; disk eventually fills. Need an alert on messages-ready count.
Recipe
bash
#!/usr/bin/env bash
# /opt/rmq-depth.sh — expose queue depth as plain text
QUEUE="${1:-payments}"
VHOST="${2:-%2F}" # url-encoded /
RMQ_USER="${RMQ_USER:-guest}"
RMQ_PASS="${RMQ_PASS:-guest}"
THRESHOLD="${DEPTH_THRESHOLD:-5000}"
DEPTH=$(curl -s -u "$RMQ_USER:$RMQ_PASS" \
"http://localhost:15672/api/queues/$VHOST/$QUEUE" \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("messages_ready",-1))')
[ "$DEPTH" -lt 0 ] && { echo "no-data"; exit 1; }
[ "$DEPTH" -ge "$THRESHOLD" ] && echo "deep $DEPTH" || echo "ok $DEPTH"
Same thing in Enterno.io
Endpoint + Enterno HTTP monitor with keyword "ok" gives an instant Telegram alert when the queue blows past threshold. Pro+ stores response-time which often correlates with a deep queue.
Related recipes
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.
Detect the moment a replica falls behind the primary by more than 10 seconds.