ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

磁盘阵列中磁盘状态监控及邮件告警

2021-06-29 23:35:16  阅读:237  来源: 互联网

标签:磁盘阵列 0000.0000 storcli64 007.0415 MegaRAID 磁盘 告警 txt storcli


邮件发送脚本

cat > sendMail.py << EOF
#!/usr/bin/python
#python2
#-*- coding: UTF-8 -*-
import smtplib
import sys
from email.mime.text import MIMEText
from email.utils import formataddr
#发送邮件的地址
mailHost="mail.xxx.com"
#发送邮件的用户名地址
mailUser="user@xxx.com"
#邮箱密码
mailPass="********"

#邮件格式
sender = mailUser
#接收到邮件的成员邮箱地址
receivers = ['xxxx@qq.com', 'xxxxx@qq.com']
#消息主体
message = MIMEText(sys.argv[2], "plain", "utf-8")
message['From'] = formataddr([sender, sender])
message['To'] = formataddr(receivers)
#消息主题
message['Subject'] = "'" + sys.argv[1] + " '" + 'ipfs存储磁盘告警!!!'


try:
    smtpObj = smtplib.SMTP()
    smtpObj.connect(mailHost, 25)
    smtpObj.login(mailUser, mailPass)
    smtpObj.sendmail(sender, receivers, message.as_string())
    print "发送成功!"
except smtplib.SMTPException as e :
    print e
    print "发送失败 !"
smtpObj.close()
EOF

阵列中磁盘检测脚本

cat > checkDisk.sh << EOF
#!/bin/bash
info=' '
ip=' '
function printInfo(){
info=`/opt/MegaRAID/storcli/storcli64 /call show`
}

function check(){
statu=`/opt/MegaRAID/storcli/storcli64 /call show| grep ^[0-9]|awk '{print $3}'`
count=0
for i in $statu
do
    i=`echo $i | sed 's/ //g'`
    if [ "${i}" = "Onln" ]||[ "${i}" = "Optl" ]
    then
        count=$[$count+1]
    else
        return 0
        break
    fi
done
return $count
}

function call(){
check
if [ $? = 0 ]
then
    printInfo
    hostName=`hostname`
    ip=`ip add | grep inet | awk 'NR==2{print $2}'`
    /opt/sendMail.py "${hostName} ${ip}" "${info}"
fi
}

call
EOF

下载阵列卡管理工具StorCLI

wget https://downloadmirror.intel.com/27654/eng/StorCLI_MR7.4p1.zip

解压

unzip StorCLI_MR7.4p1.zip
StorCLI_MR7.4p1
├── Cajun\ C++\ API\ for\ JSON\ license.txt
├── EFI
│   ├── Debug
│   │   └── storcli.efi
│   └── storcli.efi
├── FreeBSD
│   ├── FreeBSD_readme.txt
│   ├── license.txt
│   ├── storcli64.tar
│   └── storcli.tar
├── License_v2.pdf
├── Linux
│   ├── license.txt
│   ├── LINUX_Readme.txt
│   ├── splitpackage.sh
│   └── storcli-007.0415.0000.0000-1.noarch.rpm
├── StorCli_MR7.4_rel-notes.txt
├── Ubuntu
│   ├── read_me.txt
│   └── storcli_007.0415.0000.0000_all.deb
├── VMwareOP
│   ├── readme.txt
│   └── vmware-storcli-007.0415.0000.0000.vib
└── Windows
    ├── license.txt
    ├── storcli64.exe
    ├── storcli.exe
    └── WIN_ReadMe.txt

进入对应版本目录安装

  • centos
rpm -ivh storcli-007.0415.0000.0000-1.noarch.rpm
  • 安装好后会在MegaRAID目录下生成二进制文件
/opt/
├── checkDisk.sh
├── dayDisk.sh
├── MegaRAID
│   ├── MegaCli
│   │   ├── install.log
│   │   ├── libstorelibir-2.so -> /opt/MegaRAID/MegaCli/libstorelibir-2.so.14.07-0
│   │   ├── libstorelibir-2.so.14.07-0
│   │   └── MegaCli64
│   └── storcli
│       ├── install.log
│       └── storcli64

测试

/opt/MegaRAID/storcli/storcli64 /call show
Generating detailed summary of the adapter, it may take a while to complete.

CLI Version = 007.0415.0000.0000 Feb 13, 2018
Operating system = Linux 3.10.0-prsys.2.0.0.0.x86_64
Controller = 0
Status = Success
Description = None
..................
.................
..............
.........
.....
...

标签:磁盘阵列,0000.0000,storcli64,007.0415,MegaRAID,磁盘,告警,txt,storcli
来源: https://www.cnblogs.com/super-age/p/14952463.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有