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 Smtp.163.com-u "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 smtp.163.com -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 http://pc1990.blog.51cto.com/10541224/1682433
Monitor MySQL master-slave script