hpasmcli查看HP服务器内存状态:
# vi /etc/apt/source.list
按a或i进入编辑模式
deb http://downloads.linux.hp.com/downloads/ManagementComponentPack/ubuntu precise current/non-free
按ESC退出编辑模式
:wq (保存并退出)
# apt-get install hp-health
查看内存状态:
# hpasmcli -s "show dimm" | grep Status
检查HP服务器内存状态脚本
脚本1(如有问题则发邮件通知):
# vi mem.sh
按a或i进入编辑模式
#!/bin/bash
Name=`hostname`
Date=`date +%m%d%y`
Num=`dmidecode | grep -i 'serial number' | head -n 1`
Mem=`/sbin/hpasmcli -s "show dimm" | grep Status | awk -F[:" "]+ '{print $2}'`
Mem=`/sbin/hpasmcli -s "show dimm" | grep Size | awk -F[:" "]+ '{print $2}' | head -n 1`
i=1;
for OK in $Mem
do
if [ $OK = "Ok" ]
then
i=$(( $i + 1 ))
else
touch /log/$Date.log
echo "$Name $i Memory($Mem2) is bad" >> /log/$Date.log
echo "$Num" >> /log/$Date.log
/usr/bin/mail -s "$Name Memory bad" zhiming.yang@spreadtrum.com < /log/$Date.log
i=$(( $i + 1 ))
fi
done
按Esc退出编辑模式
:wq (保存并退出)
脚本2(每天发邮件通知):
# vi mem.sh
按a或i进入编辑模式
#!/bin/bash
Name=`hostname`
Date=`date +%m%d%y`
Num=`dmidecode | grep -i 'serial number' | head -n 1`
Mem=`/sbin/hpasmcli -s "show dimm" | grep Status | awk -F[:" "]+ '{print $2}''`
Mem=`/sbin/hpasmcli -s "show dimm" | grep Size | awk -F[:" "]+ '{print $2}' | head -n 1`
touch /log/$Date.log
i=1;
for OK in $Mem
do
if [ $OK = "Ok" ]
then
echo "$Name $i Memory($Mem2) is ok" >> /log/$Date.log
i=$(( $i + 1 ))
else
echo "$Name $i Memory($Mem2) is bad" >> /log/$Date.log
echo "$Num" >> /log/$Date.log
/usr/bin/mail -s "$Name Memory bad" zhiming.yang@spreadtrum.com < /log/$Date.log
i=$(( $i + 1 ))
fi
done
按Esc退出编辑模式
:wq (保存并退出)