Monitor MySQL master-slave script

Source: Internet
Author: User
Tags date1 mail account

First, download and unzip SendEmail

Cd/usr/local/srcwget TAR-ZXVF SENDEMAIL-V1.56.TAR.GZCP sendemail-v1.56/sendemail/usr/local/bin/ After the copy, you can use the email command: sendEmail [email protected]-t [email protected]-s "test"-xu zhang_peicheng-xp xxxxxxxxxxx Xx-m "This is a test email"-a/tmp/123.txt Brief description –f Sender address –t sent to who –s sender SMTP Server –u topic-xu Send mail account –XP sender mailbox password-m content –a message attachment

Second, MySQL master-slave monitoring script

#!/bin/bash#write by zhang_pc#at 2015.08.06slave_io_s= ' mysql  -uroot -p123456  -e  "show slave status \g;"  |grep   "slave_io_running" |awk -f  ': '   ' {print $2} ' slave_sql_s= ' mysql   -uroot -p123456 -e  "show slave status \g;"  |grep   "slave_io_running" |awk -f  ': '   ' {print $2} ' date1= ' date +%y%m%d ' if [  $SLAVE _io_s ==  "yes"  ]&&[  $SLAVE _sql_s ==  "yes"  ]; thenecho  "The mysql-master-slave-status is ok" elseecho  "the  Mysql-master-slave-status is failed "if [ ! -d /tmp/$date 1 ];thenmkdir  -p /tmp/$date 1fimysql -uroot -p123456 -e  "show slave status \g;"  >/tmp/$date 1/mysql-master-slave-status.txtsendemail -f [email protected] -t  [Email protected] -s -u  "Mysql_status"  -xu zhang_peicheng -xp  xxxxxxxxxxxxx -m  "The mysql-master-slave status is failed"  -a /tmp/$ Date1/mysql-master-slave-status.txt fi

This article is from the "PC personal blog" blog, make sure to keep this source

Monitor MySQL master-slave script

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: 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.