Created
January 27, 2016 14:19
-
-
Save william20111/6cbe7aed040b8de98fcf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# !/bin/bash | |
# Name: check_bond | |
# Description : Icinga script to check the current status of network bonds | |
# Version : 1.0 | |
# Author : William Fleming | |
# License : BSD | |
STATE_OK=0 | |
STATE_WARNING=1 | |
STATE_CRITICAL=2 | |
STATE_UNKNOWN=3 | |
BONDDIR=/sys/class/net | |
BONDS=$BONDDIR/bonding_masters | |
# check for bond0 directory | |
if [ ! -f $BONDS ] | |
then | |
echo "cant find bonds!" | |
exit $STATE_UNKNOWN | |
fi | |
# loop through bonds on server checking for down slaves | |
for i in `cat $BONDS`; | |
do | |
for x in `cat /sys/class/net/$i/bonding/slaves`; | |
do | |
z=`cat $BONDDIR/$i/lower_$x/operstate` | |
if [ $z == 'down' ] | |
then | |
echo "interface has failed in $i" | |
exit $STATE_CRITICAL | |
fi | |
done | |
done | |
# if no slaves are down print summary | |
for i in `cat $BONDS`; | |
do | |
echo $i "active slave is" `cat $BONDDIR/$i/bonding/active_slave` "in" `cat $BONDDIR/$i/bonding/mode` "mode" | |
done | |
exit $STATE_OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment