HP服务器raid监控脚本

2021-05-19 10:59:10 浏览数 (1)

[root@HP249centos scripts]# cat hpraid.sh

#!/bin/sh

#set -x

case $1 in

r)

raid=`/usr/sbin/hpacucli ctrl all show status |grep -v Embedded |sed 's/[ ][ ]*/ /g'|sed /^$/d|sed 's/^/'"$suffix"'/g' |awk -F ' ' '{print $NF}' | uniq | awk '!/OK/'`

if [ -z $raid ];

then

echo "OK"

else

echo "ERROR"

fi

;;

v)

vdisk=`/usr/sbin/hpacucli ctrl slot=0 logicaldrive all show|grep 'logicaldrive'|sed 's/[ ][ ]*/ /g'|sed 's/^/'"$suffix"'/g' |awk -F"[()]" '{print $2}' |awk -F ' ' '{print $NF}' | uniq | awk '!/OK/'`

if [ -z $vdisk ];

then

echo "OK"

else

echo "ERROR"

fi

;;

p)

pdisk=`/usr/sbin/hpacucli ctrl slot=0 physicaldrive all show|grep 'physicaldrive'|sed 's/[ ][ ]*/ /g'|sed 's/^/'"$suffix"'/g'|awk -F"[()]" '{print $2}' |awk -F ' ' '{print $NF}' | uniq | awk '!/OK/'`

if [ -z $pdisk ];

then

echo "OK"

else

echo "ERROR"

fi

;;

f)

fans=`/sbin/hpasmcli -s 'show fans' |awk '{print $3}' | awk 'NR>3 {print $1}' |sed '/^$/d' | uniq | awk '!/Yes/'`

if [ -z $fans ];

then

echo "OK"

else

echo "ERROR"

fi

;;

m)

memory=`/sbin/hpasmcli -s 'show dimm'|egrep -i 'module|stat' | awk -F ":" '$1~/^Status/{print $2}' | awk 'gsub(/^ *| *$/,"")' | uniq | awk '!/Ok/'`

if [ -z $memory ];

then

echo "OK"

else

echo "ERROR"

fi

;;

P)

power=`/sbin/hpasmcli -s "show powersupply" | awk -F " " '$1~/^Condition/{print $2}' | uniq | awk '!/Ok/'`

if [ -z $power ];

then

echo "OK"

else

echo "ERROR"

fi

esac

0 人点赞