-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yornik Heyl
committed
Jun 22, 2017
1 parent
4937bf5
commit f043e0b
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Script to monitor BGP conections. | ||
# MIT License Copyright (c) [2017] [Yornik Heyl] (yornik@yornik.nl) | ||
|
||
# helper function by Dave Simons | ||
die () { | ||
RETVAL=$1 | ||
shift | ||
echo $@ | ||
exit $RETVAL | ||
} | ||
|
||
status_string=$(vtysh -c 'show ip bgp neighbors'| awk '/Description: '$1'/,/BGP state/' | sed -n -e 's/^.*BGP state = //p' ) | ||
|
||
if [ -z "$status_string" ]; then | ||
die 2 "[UNKNOWN] BGP conection with $1 is not cofigured " | ||
fi | ||
|
||
|
||
if echo "$status_string" |grep --quiet Established ;then | ||
die 0 "[OK] BGP conection with $1 is up" | ||
else | ||
die 2 "[FAIL] BGP conection with $1 is down in state $status_string" | ||
fi |