You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assertlen(neighbors_down) ==0, f"BGP neighbors down: {', '.join([line.split()[0] for line in neighbors_down])}"
95
96
```
96
97
*This example executes the `show ip bgp summary` command and checks the status of all BGP neighbors. If any neighbor is in an "Idle," "Active," or "Connect" state, the rule will fail, listing the IP addresses of the down neighbors.*
98
+
99
+
## Using Configuration and Commands
100
+
101
+
### Example: Conditional BGP Neighbor Status Check
102
+
103
+
This rule first verifies whether BGP is configured on a Cisco IOS device. If BGP is configured, then it checks the status of BGP neighbors and reports if any neighbor is down.
neighbors_down = [line for line in bgp_output.splitlines() if'Idle'in line or'Active'in line or'Connect'in line]
114
+
assertlen(neighbors_down) ==0, f"BGP neighbors down: {', '.join([line.split()[0] for line in neighbors_down])}"
115
+
```
116
+
*This example looks for 'router bgp' in configuration and if found then executes the `show ip bgp summary` command and checks the status of all BGP neighbors. If any neighbor is in an "Idle," "Active," or "Connect" state, the rule will fail, listing the IP addresses of the down neighbors.*
0 commit comments