hpasmcli查看HP服务器内存状态:
(Redhat或Centos下载地址,步骤同Ubuntu)
(Ubuntu)
# 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/bashName=`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 )) elsetouch /log/$Date.logecho "$Name $i Memory($Mem2) is bad" >> /log/$Date.logecho "$Num" >> /log/$Date.log/usr/bin/mail -s "$Name Memory bad" zhiming.yang@spreadtrum.com < /log/$Date.log i=$(( $i + 1 )) fidone按Esc退出编辑模式:wq (保存并退出)脚本2(每天发邮件通知):
# vi mem.sh
按a或i进入编辑模式#!/bin/bashName=`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" ]thenecho "$Name $i Memory($Mem2) is ok" >> /log/$Date.log
i=$(( $i + 1 ))
elseecho "$Name $i Memory($Mem2) is bad" >> /log/$Date.logecho "$Num" >> /log/$Date.log/usr/bin/mail -s "$Name Memory bad" zhiming.yang@spreadtrum.com < /log/$Date.log i=$(( $i + 1 )) fidone按Esc退出编辑模式:wq (保存并退出)