Now in order to save money, I used a shell script, simply write a monitoring. By Curl a fixed page of 200 status code, if it is 200, said the site is normal, if not 200 automatically restart the site, and then send mail to QQ mailbox. QQ on their own at the same time, through the micro-letter can also receive the alarm, not only can receive the alarm, but also to solve the problem. Basically, you can also troubleshoot the web.
Copy Code code as follows:
#! /bin/bash
Source/etc/profile
A= "web is good!"
ip= ' Ifconfig eth0 | grep "inet addr" | Awk-f "[:]+" ' {print $} '
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 $} '
if [$tt 1 = "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
Copy Code code as follows:
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 $} '
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 $} '
if [$tt 1 = "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