mysql主从检测脚本

#!/bin/bash
# check mysql slave status
USER="check"
PSW="***"
RUNTIME=3600
ADDR="192.168.*.*"
declare -a slave_is
for IP in $ADDR
do
slave_is=($(/usr/local/mysql/bin/mysql -h$IP -u${USER} -p${PSW} -e "show slave status\G"|grep Running|awk ‘{print $2}‘))
if [ "${slave_is[0]}" = "Yes" -a "${slave_is[1]}" = "Yes" ]
then
 echo -e "${IP} - Slave Status: \e[1;32m [ OK ] \e[0m" > /app/sqlstatus
else
 echo "${IP} - Slave Status: \e[1;31m [ ERROR ] \e[0m" > /app/sqlstatus
 cat "/app/sqlstatus" |mutt -s "mysql slave" your_mail@163.com
fi
sleep $RUNTIME
done

mysql主从检测脚本

间隔一小时检查一次,如果出错,发送邮件

本文出自 “一颗石头 BBOTTE的博客” 博客,请务必保留此出处http://bbotte.blog.51cto.com/6205307/1410008

mysql主从检测脚本,布布扣,bubuko.com

mysql主从检测脚本

上一篇:adb 发送短信


下一篇:drdb安装测试