检查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" zhiming.yang@spreadtrum.com < /log/$Date.log
i=$(( $i + 1 ))
fi
done
按Esc退出编辑模式
:wq (保存并退出)
本文出自 “linux” 博客,谢绝转载!
原文地址:http://yangzhiming.blog.51cto.com/4849999/1427253