檢查HP伺服器硬碟狀態指令碼

2021-09-20 20:54:14 字數 1879 閱讀 2461

檢查hp伺服器硬碟狀態指令碼(如有問題則發郵件通知):

指令碼1(有問題才發郵件):

# vi disk.sh

按a或i進入編輯模式

#!/bin/bash

name=`hostname`

date=`date +%m%d%y`

num=`/usr/sbin/dmidecode | grep -i 'serial number' | head -n 1`

disk=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -f[:" "]+ ''`

disk2=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -f[:" "]+ '' | head -n 1`

i=1;

for ok in $disk

doif [ $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" [email protected] < /log/$date.log

i=$(( $i + 1 ))

fidone

按esc退出編輯模式

:wq (儲存並退出)

指令碼2(每天都發郵件):

# vi disk.sh

按a或i進入編輯模式

#!/bin/bash

name=`hostname`

date=`date +%m%d%y`

num=`/usr/sbin/dmidecode | grep -i 'serial number' | head -n 1`

disk=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -f[:" "]+ ''`

disk2=`/usr/sbin/hpacucli ctrl all show config | grep physicaldrive | awk -f[:" "]+ ''`

touch /log/$date.log

i=1;

for ok in $disk

doif [ $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" [email protected] < /log/$date.log

fidone

按esc退出編輯模式

:wq (儲存並退出)

yangzhimingg

hpacucli檢視HP伺服器硬碟狀態

hpacucli檢視hp伺服器硬碟狀態 vi etc apt source.list 按a或i進入編輯模式 deb precise current non free 按esc退出編輯模式 wq 儲存並退出 apt get install hpacucli 檢視硬碟狀態 hpacucli ctrl a...

hp伺服器 新增硬碟 HP伺服器增加硬碟實施方案

hp 伺服器增加硬碟實施方案 一 raid 配置 進機房操作 停止伺服器上的程序 用xsmgss 使用者登入,執行 停資料庫 oracle 使用者 home oracle sqlplus nolog sql conn as sysdba sql shutdown immediate sql exit...

hp惠普伺服器監控硬碟

惠普 hpssacli 工具使用 檢視raid卡資訊 包括控制器狀態 cache狀態 電池狀態 hpssacli ctrl all show status 檢視raid詳細資訊 hpssacli ctrl slot 0 show config detail 檢視raid狀態 hpssacli ctr...