本文介绍的是监控dell服务器和hp服务器的raid状态。只要有坏盘现象便会发出报警邮件,以便及时处理,避免数据丢失等严重后果。
       对于脚本中的hpacucli命令可以参考:http://hi.baidu.com/5651741/blog/item/9b8438fc80aed78ab801a001.html
       对于脚本中的MegaCli 命令可以参考:http://hi.baidu.com/shinegun/blog/item/26c2c708f4b6d036e82488e0.html

#!/bin/bash
#For monitoring raid status of XXX.
#Written on XXXX--Singles' Day :)
#Author:Levin.<findingcc@126.com>

IP_Storage=`cat /home/admin/iplist`

for i in $IP_Storage
do
        ip=`echo $i|awk -F'--->' '{print $2}'`
        time=`date +%F--%T`
        echo "$i--->$time"
        if [ $ip = "x.x.x.x" -o $ip = "x.x.x.x" ];then
                ssh $ip "MegaCli -AdpAllInfo -a0|grep \"Degrade\"
                              MegaCli -AdpAllInfo -a0|grep \"Failed Disks\""|awk '{if($NF!="0")print $0}'
        else
                ssh $ip "hpacucli ctrl all show status"|sed -n '/^$/d;/Slot/!p' |awk '{if($NF!="OK")print $0}'
        fi
done |tee /home/adminwxg/raid-status

cd /home/admin/
num1=`grep -c . iplist`
num2=`grep -c . raid-status`

if [ "$num2" -gt "$num1" ];then
   mail -s "STORAGE RAID STATUS WRONG!!!" xxx@xx.com,xxx@xxx.com <raid-status
fi

exit 0