写监控脚本 不同步时发送邮件
#!/bin/bash
. /etc/init.d/functions
function check(){
rep_file=/tmp/rep$(date +%F).txt
while true
do
rep=(`/application/mysql/bin/mysql -e "show slave status\G"|awk '/Slave_SQL_Running:/{print $2};/Slave_IO_Running:/{print $2};$1~/Seconds_Behind_Master/{print $2}'|xargs`)
if [ "${rep[0]}" != "Yes" ]; then
echo "Slave_IO_Running: NO" >$rep_file