Shell script monitoring website page

Source: Internet
Author: User
Tags log e egrep
Now, in order to save money, I use shell scripts and write a monitoring script. The status code 200 of a fixed page through curl. if it is 200, the website is normal. if it is not 200, the website is automatically restarted and then sent to the QQ mailbox. When you go to QQ, you can also receive an alarm to solve the problem. It can also solve web faults.

Now, in order to save money, I use shell scripts and write a monitoring script. The status code 200 of a fixed page through curl. if it is 200, the website is normal. if it is not 200, the website is automatically restarted and then sent to the QQ mailbox. When you go to QQ, you can also receive an alarm to solve the problem. It can also solve web faults.

  #! /Bin/bashsource/etc/profileA = "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 '. logelse/opt/tomcat1/bin/shutdown. sh cd/opt/cmdat1/work/Catalina/rm-rf localhost kill-9 $ Process/opt/cmdat1/bin/startup. sh echo "1657 is reload. ">/home/taoyake/scripts/website-error. 'date + % f '. log echo "1657 S reload. "| mail-s" website-1657 "" 505065674@qq.com "fi ============================ ============================ more/home/taoyake/scripts/reload_website-1658.sh #! /Bin/bashsource/etc/profileB = "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 '. logelse/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 e Cho "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> & amp; 1

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.