邮件发送脚本
cat > sendMail.py << EOF
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
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.4 p1.zip
StorCLI_MR7.4 p1
├── 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
进入对应版本目录安装
rpm -ivh storcli-007.0415.0000.0000-1.noarch.rpm
/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
..................
.................
..............
.........
.....
...
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)