Skip to content

Instantly share code, notes, and snippets.

@william20111
Created January 27, 2016 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save william20111/6cbe7aed040b8de98fcf to your computer and use it in GitHub Desktop.
Save william20111/6cbe7aed040b8de98fcf to your computer and use it in GitHub Desktop.
# !/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