适用于所有MegaCli的机器。无论dell、浪潮还是H3C。
必须每天上午、下午各检查一下所有物理机的磁盘啊,有问题及时处理。
172.18.31.2 /usr/local/bin/check_disk.sh 脚本:
L1到L5,是5个机柜,从上到下是172.18.x.x的ip分布
#!/bin/bash
L1=(30.1 30.2 30.3 30.4 30.5 30.6 30.7 30.8 30.9 30.10 30.11 30.12 30.13 30.14 30.15 30.16 20.25 30.18)
L2=(30.19 20.23 20.24 20.30 20.31 20.9 20.10 20.37 20.38 20.39 30.29 30.30 20.16 20.17 30.33 30.34 30.35 30.36)
L3=(30.37 20.44 20.45 22.200 30.41 30.42 30.43 30.44 30.45 30.46 30.47 22.201 30.49 30.50 20.51 20.52 20.58 20.59)
L4=(20.65 20.66 30.57 30.58 30.59 30.60 20.1 20.2 30.63 30.64 30.65 30.66 30.67 30.68 30.69 30.70 30.71 30.72)
L5=(30.73 30.74 30.75 30.76)
> /tmp/idrac.txt
> /tmp/idracout.txt
for i in L1 L2 L3 L4 L5
do
var=$i[@]
for j in ${!var}
do
echo "Scan $i 172.18.$j......" >> /tmp/idrac.txt
sshpass -p "xxxxxxxx" ssh -oStrictHostKeyChecking=no root@172.18.$j /opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0|grep "S.M.A.R.T" >> /tmp/idrac.txt
done
done
lines=($(grep -n "Yes" /tmp/idrac.txt | cut -f1 -d:))
if [ ${#lines[@]} -eq 0 ]; then
exit 1
else
for findline in ${lines[@]}
do
array=($(grep -n "\.\.\.\.\.\." /tmp/idrac.txt |cut -f1 -d:))
newarray=(${array[*]} ${findline})
sortarray=($(echo ${newarray[@]} | tr ' ' '\n'|sort -n))
for((i=0;i<${#sortarray[*]};i++))
do
if [ ${sortarray[$i]} -eq $findline ];then
beginline=${sortarray[(($i-1))]}
endline=${sortarray[(($i+1))]}
if [ "$endline" == "" ];then
endline="$"
else
endline=$(($endline-1))
fi
break
fi
done
sed -n "$beginline,$endline p" /tmp/idrac.txt >> /tmp/idracout.txt
done
/usr/local/bin/mailsend -to "zhangranrui@ddky.com" -from monit@ddky.com -ssl -port 465 -auth -auth-plan -smtp smtp.exmail.qq.com -sub "IDC机器硬件故障" -v -user "monit@ddky.com" -pass "xxxxxxxx" -cs "gb2312" -enc-type "base64" -M "$(cat /tmp/idracout.txt)"
fi