Web site Server monitoring mail alarm configuration of several server mail alarm settings [III]

Source: Internet
Author: User
Tags server memory

Web site Server monitoring mail alert configuration

Because some of the Web site old server still use 2003 system, often appear in the server paging is full, server memory overflow and so on, resulting in the entire server Web station can not open the situation, the server too much tracing difficult, sometimes difficult to find timely processing, affecting customer experience. So the individual wrote a mail alarm shell, when the overall server can not be opened, timely mail alarm notification.
The first thing is to install a Linux, and then install the MAILX mail system.
Can be used: Yum install mailx–y installed, which has been installed here by viewing.

Configure the messaging system to send and receive settings: Use 163 mail here, feel more convenient.
Vim/etc/mail.rc
Add the following settings:

Write a shell script: monitor.sh
#!/bin/bash

Author by Jerry (2011-2019)

Rm-rf/server/script/log.txt
For line incat -A /server/script/ip.txt
Do
domains=echo $line |cut -d"^" -f1|awk -F"/" ‘{print $1}‘
hostip=echo $line |cut -d"^" -f1|awk -F"/" ‘{print $2}‘

status=curl -sI $domains |grep "200 OK" |awk ‘{print $2}‘
If ["$status"! = "200"]
Then
status=curl -sI $domains |grep "200 OK" |awk ‘{print $2}‘
["$status"! = "$"] && status=curl -o /dev/null -s -w %{http_code} $domains
Fi
echo "$hostip---$status" >>/server/script/log.txt
Localtime=date +%Y-%m-%d" "%H:%M:%S
["$status"! = "$"] && echo "Message Server $hostip report error,pls Check It $status" |mail-s "$hostip Warnni ng $localtime "[email protected]
Done

Note: Ip.txt is the server Ip address and the Web site used to detect the service.

Then add the task schedule settings: 15 minute detection, can be set as needed.
Vim/etc/crontab
Add the following settings:
/15 * root/server/script/monitor.sh

Log.txt is a recorded detection condition:

200 value is normal, the detection station only set 200, not normal will send mail:

Email Alert effect:

Web site Server monitoring mail alarm configuration of several server mail alarm settings [III]

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.