Mi è capitato l’altro giorno di configurare un Bonding su un Cluster Redhat, e giocando un po con i comandi ho fatto uno script che mi avvisa appena una delle interfaccie di rete appartenenti al bonding vanno giu.
Di seguito lo script:
#!/bin/bash
ADMIN=”francesco.gabriele@ gmail.com“
for i in `ifconfig |grep -i bond |awk ‘{print $1}’| grep ‘[a-z]{4}[0-9]$’`
do
cat /proc/net/bonding/$i |grep down >/dev/null
if [ $? -eq 0 ];then
echo “<u><h2>Currently $i consist of these network devices.</h2></u>” | cat /sys/class/net/$i/bonding/ slaves > /tmp/slavestatus
echo “<u><H2>$i Bonding Status</h2></u>” >> /tmp/bond_status
cat /proc/net/bonding/$i >> /tmp/bond_status
while read lines
do
echo $lines | grep down >/dev/null
if [ $? == 0 ] ; then
echo “<font color=red><b>$lines</b></font> <br>” >> /tmp/bondstatus
else
echo “$lines<br>” >> /tmp/bondstatus
fi
done < /tmp/bond_status
rm /tmp/bond_status
mv /tmp/bondstatus /tmp/bond_status
cat /tmp/slavestatus | cat /tmp/bond_status | mail -s “[`hostname -f`] $i one of the bonding interface is down. please check” -a ‘Content-Type: text/html’ $ADMIN
rm /tmp/bond_status
rm /tmp/slavestatus
fi
done
Spero sia utile a molti
Frank
