mysql主从同步监控脚本
#!/bin/bash#author wangning
#date 2017-7-17
#qq 1198143315
#Email 1198143315@qq.com
################################## define variable#############################
define_variable(){
ip=`ifconfig|sed -n '2p'|awk -F "[: ]+" '{print $4}'`
code=(1158 1159 1008 1007 1062)
status=(`mysql -uroot -p123456 -S /data/3309/mysql.sock -e "show slave status\G"|egrep "Running|Behind_Master|Last_Errno"|awk '{print $2}'`)
}
############################ judge master #######################################
judge_master(){
mysql -uroot -p123456 -S /data/3306/mysql.sock -e "show databases" &>/dev/null
if [ $? -ne 0 ];then
echo "ip $ip the master mysql service is downed" >/mail/mysql_master.log &&\
mail -s "wangning tile" 1198143315@qq.com /mail/mysql_master.log &&\
mail -s "wangning tile" 1198143315@qq.com /mail/mysql_slave.log &&\
mail -s "wangning tile" 1198143315@qq.com /mail/mysql_slave.log &&\
mail -s "wangning tile" 1198143315@qq.com
页:
[1]