DEV Community

Rocky
Rocky

Posted on

The BGP Neighbor Nobody Caught Because Nobody Was Checking With Anything Other Than Eyes

from netmiko import ConnectHandler

flagged = []

for device in load_inventory("routers.csv"):
conn = ConnectHandler(**device)
output = conn.send_command("show ip bgp summary")
for line in output.splitlines():
if is_neighbor_row(line) and "Established" not in line:
flagged.append((device["host"], line.strip()))
conn.disconnect()

if flagged:
send_alert(flagged)

Top comments (1)

Collapse
 
szp2005 profile image
szp2005

Established only means the session is up. It says nothing about whether what comes over it is still what it was last week. We keep first-seen and last-seen per ASN, so a range quietly changing origin shows up even when every neighbor row reads Established.