監控mysql主從指令碼

來源:互聯網
上載者:User

標籤:sendemail mysql 監控指令碼

一、下載並解壓sendEmail

 

cd /usr/local/srcwget tar -zxvf sendEmail-v1.56.tar.gzcp sendEmail-v1.56/sendEmail /usr/local/bin/    拷貝之後就能用了發郵件命令:sendEmail [email protected] -t [email protected] -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 郵件附件

二、mysql主從監控指令碼

#!/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/$date1 ];thenmkdir -p /tmp/$date1fimysql -uroot -p123456 -e "show slave status \G;" >/tmp/$date1/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


本文出自 “pc的個人部落格” 部落格,請務必保留此出處http://pc1990.blog.51cto.com/10541224/1682433

監控mysql主從指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.