Simple monitoring of website access is normal shell script, mail alarm. Continue running after the site resumes.

Source: Internet
Author: User

#!/bin/bash# uses curl to check if the Web page can be accessed properly and to send the message if it is unreachable. Site=crm.bjzgjh.comprot=80url= "/http $SITE: $PROT" #mail_infoemail_sender = ([email protected] [email  Protected]) email_title= "$SITE Port $prot fault WARNING!!! "Email_content=" host $site: $PROT do not pass! Please deal with it in time. \ n Monitor mail without replying "time=3check_once () {echo echo" $ (date) monitor check once "# 2018.03.09-i/-- Head-s/--silent #if curl-s-i--connect-timeout 5--max-time http://localhost:$1/; Then if Curl-s-i-l--connect-timeout 5--max-time $URL |       Grep-q ' OK '; Then echo "$ (date) Web maybe OK" time=3 else echo "$ (date) Web maybe FAILURE "If [$time-gt 0];thennotify_error ((time = time-1)) Fiecho" $ (date) mail send ok "fi} #故障邮件报警notify_error ( {for var in ${email_sender[@]};d oecho--------------------------------------------echo-e ' date + '%y-%m-%d%h:%m.%s ' $email _content | /bin/mail-s $email _title $vardone}# Check that the webpage is normal while true at every minute;  Do Sleep check_once >>/root/logs/check.$ (date +%y-%m-%d). Log Done    

  

Reference Link: https://www.cnblogs.com/dim2046/p/5913701.html

Simple monitoring of website access is normal shell script, mail alarm. Continue running after the site resumes.

Related Article

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.