web analytics

Script to monitor software raid array

#!/bin/sh

TO=”abc@xyz.com”

CONTENT=`/sbin/mdadm –detail /dev/md3 ; /sbin/mdadm –detail /dev/md1`

COMPARE_md3=`/sbin/mdadm –detail /dev/md3 | grep “State :” | awk -F’:’ ‘{ print $2 }’`
COMPARE_md1=`/sbin/mdadm –detail /dev/md1 | grep “State :” | awk -F’:’ ‘{ print $2 }’`

if [ $COMPARE_md3 == “clean” ] || [ $COMPARE_md3 == “active” ] || [ $COMPARE_md3 == “clean, checking” ] || [ $COMPARE_md3 == “active, checking” ] && [ $COMPARE_md1 == “clean” ] || [ $COMPARE_md1 == “active” ] || [ $COMPARE_md1 == “clean, checking” ] || [ $COMPARE_md1 == “active, checking” ]
then
SUBJECT=”RAID Check OK – $HOSTNAME ”
echo¬† “$CONTENT”| /bin/mail -s “$SUBJECT” “$TO”
else
SUBJECT=”URGENT – Suspected failed drive in $HOSTNAME”
echo “$CONTENT” | /bin/mail -s “$SUBJECT” “$TO”
fi

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>