Shell monitoring website alert script

Source: Internet
Author: User

Mail can be usedAlarm, you can also install an email reminder tool on your Android phone. If you are in trouble, you can use mobile Feixin, but the current smart phones are basically wcdma and cdma, there are few people around me who use mobile devices. Everyone is on the Internet. Just use third-party email reminders.

In addition, the mail commands provided by linux are often blocked by various email services, especially those of qq and sina ~~~

Therefore, use mutt to log on to the 163 mailbox and then send an alert email. In this way, it will not be blocked. How can we say that 163mail is also a brand ~~~~~~~ I am using Android, and my mailbox is under Netease's Android mailbox apk package. I feel pretty good ...............

The mutt method can also be used in nagios ......

Http://as.baidu.com/a/item? Docid = 649780501 & f = web_alad_1

This is the mutt configuration script, which has integrated a 163 account and password ~~~~~~~~~~ I just created this so that you can send an alert and email directly. Of course, you can change your email password or something ~~~~~~~!!!

 
  1. #! /Bin/bash

  2. # Info: ruifengyunceshi@163.com 7256958

  3. Wget http://rfyiamcool.googlecode.com/files/msmtp-1.4.18.tar.bz2

  4. Tar xjvf msmtp-1.4.18.tar.bz2

  5. Cd msmtp-1.4.18

  6. ./Configure -- prefix =/usr/local/msmtp

  7. Make

  8. Make install

  9. Ln-s/usr/local/msmtp/bin/msmtp

  10. Mkdir-p/usr/local/msmtp/etc

  11. Cat>/usr/local/msmtp/etc/msmtprc <EOF

  12. Account default

  13. Host smtp.163.com

  14. From ruifengyunceshi@163.com

  15. Auth login

  16. Port 25

  17. User ruifengyunceshi@163.com

  18. Password 7256958

  19. Tls off

  20. Syslog on

  21. EOF

  22. Cd ~

  23. Cat> muttrc <EOF

  24. Set sendmail = "/usr/local/msmtp/bin/msmtp"

  25. Set use_from = yes

  26. Set from = ruifengyunceshi@163.com

  27. Set envelope_from = yes

  28. EOF

  29. Cat>/etc/Muttrc. local <EOF

  30. /Bin/msmtp-host = smtp.163.com-domain = 163.com-auth = plain-user = 7256958-f = ruifengyunceshi@163.com-t ruifengyunceshi@163.com-d

  31. EOF

  32. Echo "hello" | mutt-s "baojing" 123l@163.com

This is an alert script. It monitors the URL ~~~


 
  1. #! /Bin/bash

  2. While true

  3. Do

  4. Url = "http: // 10.10.10.22/index.html"

  5. Status = $ (/usr/bin/curl-s -- head "$ url" | awk '/HTTP/{print $2 }')

  6. If ["$ status "! = "200"]; then

  7. Echo "bad"

  8. Echo "not 200" | mutt-s "baojing" 123l@163.com

  9. Else

  10. Echo "good"

  11. Fi

  12. Sleep 10

  13. Done

Save

 
  1. Vi baojing. sh

  2. Sh baojing. sh &


This is to monitor the remote port, such as port 80 110 25 1723.

 
  1. #! /Bin/bash

  2. While true

  3. Do

  4. Newip1 = 120.92.251.18

  5. Date = $ (date-d "today" + "% Y-% m-% d _ % H: % M: % S ")

  6. Newport = 80

  7. # Kkk ()

  8. #{

  9. # Nmap-sT $ newip-p $ newport | grep open

  10. #}

  11. If! Nmap-sT $ newip1-p $ newport | grep open

  12. Then

  13. Echo "$ newip1 is bad $ {date}" | mutt-s "baojing" 123l@163.com

  14. Else

  15. Echo "web is good"

  16. Fi

  17. Sleep 10

  18. Done

This is the slave server status of mysql ~

 
  1. #! /Bin/bash

  2. Mima= 123123

  3. While true

  4. Do

  5. Mysql-uroot-p $ mima-e "show slave status \ G; "| grep-I Running | egrep" IO | SQL "| grep-I yes | wc-l>/root/num

  6. If [$ (cat/root/num)-eq 2]; then

  7. Echo "mysql slave is running OK !!"

  8. Else

  9. Echo "$ newip1 is bad" | mutt-s "mysql is bad" 123l@163.com

  10. Fi

  11. Done


This article is from "Fengyun, it's her ." Blog, please be sure to keep this source http://rfyiamcool.blog.51cto.com/1030776/910970


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.