Use mobile phone emails to set alert messages

Source: Internet
Author: User
A long time ago, I liked to use mobile phone 139 to set up nagios alarm emails. at that time, China Unicom's mobile phone mail text message function was not very mature. I tried the following usage, it still feels very convenient; 139 of mobile phone mail configurations are relatively simple, and SMS alarms are very fast, and colleagues in the system Group once voted for this problem, here, I have used a mail number for more than five years as an example. this is actually a notification of arrival at http://mail.wo.com.cn/smsmail/index.html.

A long time ago, I liked to use mobile phone 139 to set up nagios alarm emails. at that time, China Unicom's mobile phone mail text message function was not very mature. I tried the following usage, it still feels very convenient; 139 of mobile phone mail configurations are relatively simple, and SMS alarms are very fast, and colleagues in the system Group once voted for this problem, here, I have used a mail number for more than five years as an example. In fact, there is a mail arrival notification at http://mail.wo.com.cn/smsmail/index.html. we set it as shown below:

1. monitor important websites in real time on public network servers.
This can be used as an auxiliary function of Nagios, so we do not have to purchase the configured instant scan website warning service. The script content is as follows:

#!/bin/bash while : do status=`curl -s --head http://www.1paituan.com/index.jsp | awk '/HTTP/ {print $2}'` if [ "$status" == "200" ] then    : else   echo "1paituan.com is critical" | mail -s "1paituan.com is critical.please check " 1309889xxxx@wo.com.cn fi sleep 5 done 

Then we run some scripts in the background. the command is as follows:
Nohup sh/root/monitor. sh &
 
2. I used the MySQL master/slave solution when I configured the website for many of my friends. sometimes I monitored them and sent the first version of the monitoring script before. this is the second version after the change, with the DATA parameter added, you can accurately locate the MySQL master-slave problem at which point, and correct some bugs in the first version. the script content is as follows:

#crontab time 00:10 #!/bin/bash #check MySQL_Slave Status #crontab time 00:10 MYSQLPORT=`netstat -na|grep "LISTEN"|grep "3306"|awk -F[:" "]+ '{print $4}'` MYSQLIP=`ifconfig eth0|grep "inet addr" | awk -F[:" "]+ '{print $4}'` IO_env=`echo $STATUS | grep IO | awk  ' {print $2}'` SQL_env=`echo $STATUS | grep SQL | awk  '{print $2}'` DATA=`date +"%y-%m-%d %H:%M:%S"`   if [ "$MYSQLPORT" == "3306" ] then   echo "mysql is running" else   echo $MYSQLIP mysql is down" | mail -s "warn!server: $MYSQLIP mysql is down" 1309889xxxx@wo.com.cn fi   if [ "$IO_env" = "Yes" -a "$SQL_env" = "Yes" ] then   echo "Slave is running!" else echo "Slave is not running!" | mail -s "warn! $DATA $MYSQLIP MySQL Slave is not running" 1309889xxxx@wo.com.cn fi 

Run the command once every 10 minutes, that is, vim/etc/crontab.
*/10 * root sh/root/mysql_slave.sh

If you want to use mobile phone mail, pay attention to the following:
1. the Linux server itself has the sendmaiil service, and its mail sending function is very effective. it does not need to be transferred through the company's email server. We tried it before and failed;
2. we have found many problems with the number delay and arrival of China Unicom. we recommend that you use the mobile number as the primary account;
III. this alert policy is only used as an aid to Nagios.

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.