Shell脚本监控网站页面正常打开情况
2014-12-21 00:00
609 查看
现在单位为了省钱,我用了shell脚本,简单的写了一个监控。通过curl一个固定页面的200状态码,如果是200,就说网站是正常的,如果不是200就自动重启网站,然后发邮件到QQ邮箱。自己在上QQ的同时,通过微信也可以收到报警,不但可以收到报警,还可以解决问题。基本上也可以解决web的故障。
#! /bin/bash source /etc/profile A="web is Good !" ip=`ifconfig eth0 | grep "inet addr" | awk -F "[: ]+" '{print $4}'` tt1=`curl -I -s http://xx.8x.18x.xx:1657/product/pro_detail_-rg000785.shtml | head -1 | cut -d " " -f2` Process=`ps -ef | grep java | 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 -rf localhost kill -9 $Process /opt/tomcat1/bin/startup.sh echo "1657 is reload." >>/home/taoyake/scripts/website-error.`date +%F`.log echo "1657 is reload." | mail -s "website-1657" "505065674@qq.com" fi
more /home/taoyake/scripts/reload_website-1658.sh #! /bin/bash source /etc/profile B="1658 is Good !" ip=`ifconfig eth0 | grep "inet addr" | awk -F "[: ]+" '{print $4}'` tt1=`curl -I -s http://xx.xx.183.xx:1658/product/pro_detail_-rg000785.shtml | head -1 | cut -d " " -f2` Process=`ps -ef | grep java | 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 -rf localhost kill -9 $Process /opt/tomcat2/bin/startup.sh echo "1658 is reload." >>/home/taoyake/scripts/website-1658-error.`date +%F`.log echo "1658 is reload." | mail -s "website-1658" "505065674@qq.com" fi [root@web ~]# crontab -l */10 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1 */5 * * * * /bin/sh /home/taoyake/scripts/reload_website.sh >/dev/null 2>&1 */5 * * * * /bin/sh /home/taoyake/scripts/reload_website-1658.sh >/dev/null 2>&1
相关文章推荐
- Shell脚本监控网站页面正常打开情况
- 监控网站是否可以正常打开的Shell脚本分享
- 监控网站是否可以正常打开的Shell脚本分享
- linux增加epel源,yum安装nignx,脚本安装mysql服务端,shell脚本监控网站页面
- 简单监控网站访问是否正常的shell脚本,邮件报警。网站恢复后继续运行。
- 简单shell脚本监控网站页面
- 利用shell脚本监控网站状态 推荐
- 使用shell脚本进行服务器系统监控——页面调度与交换空间监控
- 利用shell脚本来监控linux系统的负载与CPU和内存使用情况
- 利用shell脚本来监控linux系统的负载与CPU占用情况
- Shell脚本 检查网站是否正常浏览
- shell脚本监控linux系统内存使用情况的方法(不使用nagios监控linux)
- 利用shell脚本来监控linux系统的负载与CPU占用情况
- shell脚本监控网站状态(附注释)
- 利用shell脚本来监控linux系统的负载与CPU占用情况
- a标签是否新开一个页面的问题各大网站的打开情况整理
- 利用shell脚本来监控linux系统的负载与CPU占用情况
- 利用shell脚本来监控linux系统的负载与CPU占用情况 推荐
- 利用shell脚本监控网站状态
- shell 监控网站是否异常的脚本