首页 > 代码库 > 检查HP服务器内存状态脚本

检查HP服务器内存状态脚本



检查HP服务器内存状态脚本


脚本1(如有问题则发邮件通知):

# vi disk.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 disk.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 (保存并退出)


本文出自 “linux” 博客,谢绝转载!