检查HP服务器硬盘状态脚本(如有问题则发邮件通知):
# vi disk.sh
按a或i进入编辑模式
#!/bin/bash
Name=`hostname`
Date=`date +%m%d%y`
Num=`dmidecode | grep -i ‘serial number‘ | head -n 1`
Disk=`hpacucli ctrl all show config | grep physicaldrive | awk -F[:" "]+ ‘{print $15}‘`
#echo $Disk
i=1;
for OK in $Disk
do
if [ $OK = "OK)" ]
then
i=$(( $i + 1 ))
elif [ $OK = "Failed)" ]
then
touch /log/$Date.log
echo "$Name $i disk is bad" >> /log/$Date.log
echo "$Num" >> /log/$Date.log
/usr/bin/mail -s "$Name disk bad" [email protected] < /log/$Date.log
i=$(( $i + 1 ))
fi
done
按Esc退出编辑模式
:wq (保存并退出)
时间: 2024-10-13 13:11:07