Skip to content

BGP — alert when a peer session is down

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.

Recipe

bash
#!/usr/bin/env bash
# /etc/cron.d/bgp-session
# */1 * * * * root /opt/bgp-session.sh

# Works with FRRouting (vtysh) — adapt for bird/junos as needed
DOWN=$(vtysh -c 'show bgp summary' \
  | awk '/^[0-9]/ && $11 != "Established" {print $1}' \
  | tr '\n' ',')

if [ -n "$DOWN" ]; then
  curl -fsS "$HEARTBEAT_URL" --data-urlencode "bgp_down=$DOWN"
  exit 2
fi
echo "OK (all peers Established)"

Same thing in Enterno.io

Wire to an Enterno heartbeat — learn the peer dropped immediately, and your alert beats the customer-ticket pile-up.

Set up HTTP monitor → ← All recipes

Related recipes