欢迎光临
我们一直在努力

使用shell检测raid状态并制作表格发送到邮箱

本站教程收集整理的这篇文章主要介绍了使用shell检测raid状态并制作表格发送到邮箱,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。

caTraid_fzt.sh
#!/bin/bash
#data:2018.3.9
#checkraidstatusandmailtosomeone
DIR="/home/s/ops/pantheon/argos/raid.check"#脚本所在目录
cd$DIR
LOG='raid_check.2018-03-09_11:17:31'
#LOG=$(ls-Traid_check.`date+"%F"`.*|xargsecho|cut-d''-f1)
BAD_RAID=$(python/raid.check/marshalv3.py$LOG)#有问题Raid的列表

html_input(){
echo"<tr>
<td>$1</td>
<td>$2</td>
<td>$3</td>
<td>$4</td>
</tr>">>$DIR/mail.html
}#构造一横行表格信息

set_info(){
echo"<head>
<Metahttp-equiv="Content-Type"content="text/html\;charset=UTF-8">
<p><fontcolor="red">如下服务器硬件报警,请业务尽快报修,报修时请在报修工单中写明故障信息。</font></p>
</head>
<tableborder=1>
<tr>
<th>主机信息</th>
<th>Hermes信息</th>
<th>接口负责人</th>
<th>业务负责人</th>
</tr>">$DIR/mail.html
host_list=$(grep$1raid_info|awk'{print$1}')#主机信息列表
forhtml_hosTin$host_list
do
html_owner=$(grep$html_hosTraid_info|awk'{print$4}')#对应owner信息
html_hermes=$(grep$html_hosTraid_info|awk'{print$2}')#对应hermes信息
echo$html_host$html_hermes$1$html_owner
html_input$html_host$html_hermes$1$html_owner#构造每行表格信息
done
echo"</table>
<p><font>如有问题请联系:</font><ahref="mailto:go-sa@mail.net">go-sa@mail.net</a></p>
<p><fontface="arial"color="red">此邮件为系统发送,请勿回复!!!</font></p>">>mail.html
#catmail.html>>all.html#报表汇总
muttmubai@mail.net-s"Raidcheck"-e"setcontent_type=text/html"<$DIR/mail.html#发送邮件
#mutt$1-s"Raid检测报警"-e"setcontent_type=text/html"<$DIR/mail.html
}#制作mail.html,并使用邮件发送

forhosTin$BAD_RAID
do
HERMES=$(Pwhoismycluster$host|grep"hermes:"-A1|sed-n'2p'|cut-d:-f1|sed's/[[:space:]]//g')#
owneR=$(curl-s"http://10.95.22.14:9093/element/findServerUserBy"-H"Content-Type:application/json"-d'{"HostnameIn":"'$host'"}'|grep-Po'"owner":".*?"'|awk-F":"'{print$NF}'|sed's/"//g')
OPS=$(curl-s"http://10.95.22.14:9093/element/findServerUserBy"-H"Content-Type:application/json"-d'{"HostnameIn":"'$host'"}'|grep-Po'"ops":".*?"'|awk-F":"'{print$NF}'|sed's/"//g')
OPS=${OPS:=fanzhengteng@360.net}
HERMES=${HERMES:=没查到HERMES}
owneR=${owneR:=没查到owneR}
#echo$host$HERMES$OPS$owneR
echo$host$HERMES$OPS$owneR>>$DIR/raid_info
done#找到hosthermesopsowner信息并写入raid_info这个文件中,供后续处理

OPS_LIST=$(cat$DIR/raid_info|awk'{print$3}'|sort|uniq)#相同邮件人去重
forhtml_opsin$OPS_LIST
do
set_info$html_ops#set_info来发送邮件
done
rm$DIR/raid_info#删除raid_info这个文件

本站总结

便宜香港vps

以上是本站教程为你收集整理的使用shell检测raid状态并制作表格发送到邮箱全部内容,希望文章能够帮你解决使用shell检测raid状态并制作表格发送到邮箱所遇到的程序开发问题。

如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。