|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!如今单元为了省钱,我用了shell剧本,复杂的写了一个监控。经由过程curl一个流动页面的200形态码,假如是200,就说网站是一般的,假如不是200就主动重启网站,然后发邮件到QQ邮箱。本人在上QQ的同时,经由过程微信也能够收到报警,不仅能够收到报警,还能够办理成绩。基础上也能够办理web的妨碍。
#!/bin/bash
source/etc/profile
A="webisGood!"
ip=`ifconfigeth0|grep"inetaddr"|awk-F"[:]+"{print$4}`
tt1=`curl-I-shttp://xx.8x.18x.xx:1657/product/pro_detail_-rg000785.shtml|head-1|cut-d""-f2`
Process=`ps-ef|grepjava|egrep"tomcat1"|awk-F""{print$2}`
if[$tt1="200"]
then
echo"$A">>/home/taoyake/scripts/website-error.`date+%F`.log
else
/opt/tomcat1/bin/shutdown.sh
cd/opt/tomcat1/work/Catalina/
rm-rflocalhost
kill-9$Process
/opt/tomcat1/bin/startup.sh
echo"1657isreload.">>/home/taoyake/scripts/website-error.`date+%F`.log
echo"1657isreload."|mail-s"website-1657""505065674@qq.com"
fi
=========================================================
more/home/taoyake/scripts/reload_website-1658.sh
#!/bin/bash
source/etc/profile
B="1658isGood!"
ip=`ifconfigeth0|grep"inetaddr"|awk-F"[:]+"{print$4}`
tt1=`curl-I-shttp://xx.xx.183.xx:1658/product/pro_detail_-rg000785.shtml|head-1|cut-d""-f2`
Process=`ps-ef|grepjava|egrep"tomcat2"|awk-F""{print$2}`
if[$tt1="200"]
then
echo"$B">>/home/taoyake/scripts/website-1658-access.`date+%F`.log
else
/opt/tomcat2/bin/shutdown.sh
cd/opt/tomcat2/work/Catalina/
rm-rflocalhost
kill-9$Process
/opt/tomcat2/bin/startup.sh
echo"1658isreload.">>/home/taoyake/scripts/website-1658-error.`date+%F`.log
echo"1658isreload."|mail-s"website-1658""505065674@qq.com"
fi
[root@web~]#crontab-l
*/10****/usr/sbin/ntpdatetime.windows.com>/dev/null2>&1
*/5****/bin/sh/home/taoyake/scripts/reload_website.sh>/dev/null2>&1
*/5****/bin/sh/home/taoyake/scripts/reload_website-1658.sh>/dev/null2>&1
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|