现在单位为了省钱,我用了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脚本监控网站页面
更新动态
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]