monitoring: add .91-.93 IP rehab to daily Telegram warmup alert

Tracks the rehab pool (rehab02-04 / .91-.93) delivery + bounce + Spamhaus ZEN
DNSBL status in the daily report and alert body. Alerts only if a rehab IP lands
on a DNSBL or rehab delivery drops <40% with real volume (recipient quality
slipped) -- a recovering IP naturally bounces more so the threshold is lenient.
This commit is contained in:
justin 2026-06-09 20:34:41 -05:00
parent 1c2e263bb7
commit 1854753c70

View file

@ -27,6 +27,20 @@ HBOUNCE=$(mlog 'hcout[0-9]/smtp' | grep -c 'status=bounced')
HSPAM=$(mlog 'hcout[0-9]/smtp' | grep 'status=bounced' | grep -c '550-5.7.1') HSPAM=$(mlog 'hcout[0-9]/smtp' | grep 'status=bounced' | grep -c '550-5.7.1')
HTOTAL=$((HSENT + HBOUNCE)); HDEL=0 HTOTAL=$((HSENT + HBOUNCE)); HDEL=0
[ "$HTOTAL" -gt 0 ] && HDEL=$(python3 -c "print(round(100*$HSENT/$HTOTAL))") [ "$HTOTAL" -gt 0 ] && HDEL=$(python3 -c "print(round(100*$HSENT/$HTOTAL))")
# IP rehab pool (.91-.93 / rehab02-04) — recovering after the May 30-31 blast.
# A recovering IP naturally bounces more on a cold list, so the rehab bounce
# threshold is lenient; we only flag if it is alarmingly high (a sign the rehab
# recipient quality regressed) or if a rehab IP lands on a DNSBL.
RSENT=$(mlog 'rehab0[234]/smtp' | grep -c 'status=sent')
RBOUNCE=$(mlog 'rehab0[234]/smtp' | grep -c 'status=bounced')
RTOTAL=$((RSENT + RBOUNCE)); RDEL=0
[ "$RTOTAL" -gt 0 ] && RDEL=$(python3 -c "print(round(100*$RSENT/$RTOTAL))")
# DNSBL check for the rehab IPs (reuse Spamhaus ZEN — the one that matters most).
RBL=''
for ip in 91 92 93; do
hit=$(dig +short +time=3 +tries=1 ${ip}.124.174.207.zen.spamhaus.org 2>/dev/null | head -1)
[ -n "$hit" ] && RBL="${RBL}.${ip} on Spamhaus ZEN ($hit); "
done
PROBLEMS='' PROBLEMS=''
if [ "$MSENT" -ge "$MIN_SENT" ]; then if [ "$MSENT" -ge "$MIN_SENT" ]; then
[ "$MDEL" -lt "$MIN_DELIVERY" ] && PROBLEMS="${PROBLEMS}- Main pool delivery ${MDEL}% (below ${MIN_DELIVERY}%)\n" [ "$MDEL" -lt "$MIN_DELIVERY" ] && PROBLEMS="${PROBLEMS}- Main pool delivery ${MDEL}% (below ${MIN_DELIVERY}%)\n"
@ -36,13 +50,20 @@ if [ "$HSENT" -ge "$MIN_SENT" ]; then
[ "$HDEL" -lt "$MIN_DELIVERY" ] && PROBLEMS="${PROBLEMS}- HC stream delivery ${HDEL}%\n" [ "$HDEL" -lt "$MIN_DELIVERY" ] && PROBLEMS="${PROBLEMS}- HC stream delivery ${HDEL}%\n"
[ "$HSPAM" -gt "$MAX_SPAMBLOCK" ] && PROBLEMS="${PROBLEMS}- HC stream spam/policy blocks: ${HSPAM}\n" [ "$HSPAM" -gt "$MAX_SPAMBLOCK" ] && PROBLEMS="${PROBLEMS}- HC stream spam/policy blocks: ${HSPAM}\n"
fi fi
# Rehab problems: DNSBL listing is always a problem; bounce >60% with real
# volume means the recipient quality slipped (rehab should be on clean domains).
[ -n "$RBL" ] && PROBLEMS="${PROBLEMS}- IP rehab DNSBL: ${RBL}\n"
if [ "$RSENT" -ge 10 ] && [ "$RDEL" -lt 40 ]; then
PROBLEMS="${PROBLEMS}- IP rehab delivery ${RDEL}% (recipient quality slipped)\n"
fi
{ {
echo "==== TG WARMUP CHECK $(date) ====" echo "==== TG WARMUP CHECK $(date) ===="
echo "MAIN: sent=$MSENT bounced=$MBOUNCE delivery=${MDEL}% spamblock=$MSPAM" echo "MAIN: sent=$MSENT bounced=$MBOUNCE delivery=${MDEL}% spamblock=$MSPAM"
echo "HC: sent=$HSENT bounced=$HBOUNCE delivery=${HDEL}% spamblock=$HSPAM" echo "HC: sent=$HSENT bounced=$HBOUNCE delivery=${HDEL}% spamblock=$HSPAM"
echo "REHAB(.91-.93): sent=$RSENT bounced=$RBOUNCE delivery=${RDEL}% dnsbl=${RBL:-clean}"
echo "problems: ${PROBLEMS:-none}" echo "problems: ${PROBLEMS:-none}"
} >> "$REPORT" 2>&1 } >> "$REPORT" 2>&1
if [ -n "$PROBLEMS" ]; then if [ -n "$PROBLEMS" ]; then
MSG=$(printf '⚠️ Performance West IP reputation alert (%s)\n\nMain pool: %d%% delivery, %d sent, %d bounced, %d spam-blocks\nHC stream: %d%% delivery, %d sent, %d spam-blocks\n\nIssues:\n%b' "$TODAY" "$MDEL" "$MSENT" "$MBOUNCE" "$MSPAM" "$HDEL" "$HSENT" "$HSPAM" "$PROBLEMS") MSG=$(printf '⚠️ Performance West IP reputation alert (%s)\n\nMain pool: %d%% delivery, %d sent, %d bounced, %d spam-blocks\nHC stream: %d%% delivery, %d sent, %d spam-blocks\nRehab (.91-.93): %d%% delivery, %d sent, %d bounced (dnsbl: %s)\n\nIssues:\n%b' "$TODAY" "$MDEL" "$MSENT" "$MBOUNCE" "$MSPAM" "$HDEL" "$HSENT" "$HSPAM" "$RDEL" "$RSENT" "$RBOUNCE" "${RBL:-clean}" "$PROBLEMS")
tg "$MSG" tg "$MSG"
fi fi