1、下載並解壓sendEmailmysql
cd /usr/local/src tar -zxvf sendEmail-v1.56.tar.gz cp sendEmail-v1.56/sendEmail /usr/local/bin/ 拷貝以後就能用了 發郵件命令: sendEmail -fzhang_peicheng@163.com -t 756475064@qq.com -s smtp.163.com -u "test"-xu zhang_peicheng -xp xxxxxxxxxxxxx -m"this is a test email" -a/tmp/123.txt 簡要說明 –f 發送方地址 –t發給誰 –s發送方smtp服務器 –u 主題 -xu 發送郵件帳號 –xp 發送方郵箱的密碼 -m 內容 –a 郵件附件
2、mysql主從監控腳本sql
#!/bin/bash #write by zhang_pc #at 2015.08.06 SLAVE_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" ];then echo "the mysql-master-slave-status is ok" else echo "the mysql-master-slave-status is failed" if [ ! -d /tmp/$date1 ];then mkdir -p /tmp/$date1 fi mysql -uroot -p123456 -e "show slave status \G;" >/tmp/$date1/mysql-master-slave-status.txt sendEmail -f zhang_peicheng@163.com -t 756475064@qq.com -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