Network — alert on packet loss to an upstream (via mtr)
Connection to a database / partner API loses 5–10 % of packets — the app sees timeouts, but `ping -c 4` says 'all good'. TCP retransmits silently chop throughput.
Recipe
#!/usr/bin/env bash
# /etc/cron.d/packet-loss
# */5 * * * * root /opt/packet-loss.sh
TARGET=${TARGET:-db.internal}
THRESH_PCT=${THRESH_PCT:-3} # alert above 3 % loss
# mtr -r = report mode, -c 100 = 100 packets, -n = numeric only
LOSS=$(mtr -r -c 100 -n "$TARGET" \
| awk 'END {gsub(/%/,"",$3); print $3+0}')
if [ "${LOSS:-0}" -gt "$THRESH_PCT" ]; then
curl -fsS "$HEARTBEAT_URL" --data "loss_pct=$LOSS,target=$TARGET"
exit 2
fi
echo "OK (loss=${LOSS}%)"
Same thing in Enterno.io
Use Enterno ping/port instead of your own mtr cron — multi-region monitoring at once, you find geographic issues without standing up your own VPN probes.
Related recipes
A BGP session with an upstream / cloud peering drops — half of routes are gone. The peer does not notify you, and your network monitoring (if any) often is not wired to BGP state.
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.