Skip to content

Instantly share code, notes, and snippets.

@SharaaEsper
Created December 20, 2014 00:44
Show Gist options
  • Save SharaaEsper/888e225db3db38cb933e to your computer and use it in GitHub Desktop.
Save SharaaEsper/888e225db3db38cb933e to your computer and use it in GitHub Desktop.
Raid Stuff
#!/bin/bash
#Get controller number
controller=`tw_cli show | tail -2 | head -1 | awk '{print $1}'`
#Set Email
email='[email protected]'
#Get Hostname
hostname=`/bin/hostname`
#Build Reports
/sbin/tw_cli info $controller > /tmp/raidreport
/sbin/tw_cli alarms >> /tmp/raidreport
#Check Raid Status
raidstatus=`/usr/bin/head -n4 /tmp/raidreport | /usr/bin/tail -n 1 | /usr/bin/awk '{print $3}'`
#Send email if needed
if [ $raidstatus != "OK" ] && [ $raidstatus != "VERIFYING" ]
then
/usr/bin/mail $email -s"3Ware RAID health report for $hostname: Raid Degraded" < /tmp/raidreport
fi
#Clean Up
/bin/rm -rf /tmp/raidreport
#!/bin/bash
date=`date +%F`
for n in {0..7}
do
echo -e "\n\n Slot $n \n" >> /root/drivelogs/drivelog-short-"$date"
echo -e "\n\n Slot $n \n" >> /root/drivelogs/drivelog-full-"$date"
/usr/local/sbin/smartctl -d 3ware,$n -a /dev/twa0 | grep -i err >> /root/drivelogs/drivelog-short-"$date"
/usr/local/sbin/smartctl -d 3ware,$n -a /dev/twa0 >> /root/drivelogs/drivelog-full-"$date"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment