#! /bin/bash # 3ware_monitor-raid.sh # 2012 - thomas@zumbrunnen.ch # # 1. tw_cli need to be installed # 2. set up a cronjob for this script to check every 30 minutes #checkraid=`/usr/sbin/tw_cli /c2 show | grep VERIFYING` checkraid=`/usr/sbin/tw_cli /c2 show | grep MIGRATING` #checkraid=`/usr/sbin/tw_cli /c2 show | grep DEGRADED` if [ "$checkraid" == "" ]; then echo "Everything ok" else echo "Error, array DEGRADED"; SUBJECT="vmonster.badewetter.ch -- RAID ARRAY DEGRADED!" EMAIL="thomas.zumbrunnen@dmdtwo.com" EMAILMESSAGE="/tmp/emailmessage.txt" # echo "Below is the output of the CLI tool (tw_cli /c2 show):"> $EMAILMESSAGE # echo `/usr/sbin/tw_cli /c2 show` >>$EMAILMESSAGE /usr/sbin/tw_cli /c2 show > $EMAILMESSAGE mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE fi