当前位置:   article > 正文

hpacucli查看HP服务器硬盘状态

hpacucli

hpacucli查看HP服务器硬盘状态:


http://downloads.linux.hp.com/downloads/ManagementComponentPack/centos/6/x86_64/9.40/  (Redhat或Centos下载地址,步骤同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 hpacucli


查看硬盘状态:

# hpacucli ctrl all show config | grep physicaldrive


检查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`

Disk=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -F[:" "]+ '{print $15}'`
Disk2=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -F[:" "]+ '{print $13}'`

i=1;

for OK in $Disk
  do
    if [ $OK = "OK)" ]
then
     i=$(( $i + 1 ))
    elif [ $OK = "Failed)" ] || [ $OK = "Predictive" ]

then
touch /log/$Date.log
echo "$Name $i disk($Disk2) is bad"  >> /log/$Date.log
echo "$Num" >> /log/$Date.log
/usr/bin/mail -s "$Name disk bad" zhi.ming@ming.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`

Disk=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -F[:" "]+ '{print $15}'`
Disk2=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -F[:" "]+ '{print $13}'`

touch /log/$Date.log

i=1;

for OK in $Disk
  do
    if [ $OK = "OK)" ]
then

echo "$Name $i disk($Disk2) is ok"  >> /log/$Date.log

     i=$(( $i + 1 ))
    elif [ $OK = "Failed)" ] || [ $OK = "Predictive" ]

then
echo "$Name $i disk($Disk2) is bad"  >> /log/$Date.log
echo "$Num" >> /log/$Date.log
 i=$(( $i + 1 ))

else

echo "$Name $i disk is ok"  >> /log/$Date.log

i=$(( $i + 1 ))

/usr/bin/mail -s "$Name disk bad" zhi.ming@ming.com < /log/$Date.log

  fi
done

按Esc退出编辑模式

:wq (保存并退出)

本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1427252如需转载请自行联系原作者


yangzhimingg

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/960671
推荐阅读
相关标签
  

闽ICP备14008679号