admin avatar

使用shell脚本监控硬Raid并配置MegaCli監控硬碟健康报警发送邮件

🕦 by admin





使用shell脚本监控硬Raid并配置MegaCli报警发送邮件

MegaCli的安裝參考以下連結

https://www.vpslala.com/t/997

程式代碼如下

Bash:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
Optimal=" Optimal"
VDSTATE=$(/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL | /bin/grep "^State")
STATE=$(/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL | /bin/grep "^State" | /bin/awk -F\: '{print $2}')
#echo $? >> /tmp/vdiskstatus.log
#echo $STATE >> /tmp/vdiskstatus.log
if [ $STATE = $Optimal ];then
        echo OK -- "Virtual Disk : $STATE"
        #echo  CRITICAL -- "Virtual Disk : $STATE" | mail -s "硬盘检测正常" [email protected]

        exit $STATE_OK
else
        #default:echo CRITICAL -- "Virtual Disk : $STATE"
        echo  CRITICAL -- "Virtual Disk : $STATE" | mail -s "硬盤故障報警" [email protected]
        exit $STATE_CRITICAL
fi

如果MegaCli檢測道硬碟返回狀態非正常的Optimal ,則發送郵件道指定的郵箱。

注意,請先開啟防火牆的25,465,587端口。





💘 相关文章

写一条评论

Based on Golang + fastHTTP + sdb | go1.18.3 Processed in 1ms