脚本如下:
[root@dev-env23 scripts]# vi check_slave_delay.sh #!/bin/bash check_time=`date "+%Y-%m-%d,%H:%M:%S"` mysql -h localhost -uroot -p123456 -e 'show slave status\G'>/tmp/slave_23.txt 2>&1 seconds_behind=`cat /tmp/slave_23.txt|grep Seconds_Behind_Master|sed s/[[:space:]]//g|cut -d ':' -f2` echo $seconds_behind ##seconds_behind=NULL Last_IO_Errno=`cat /tmp/slave_23.txt|grep Last_IO_Errno|sed s/[[:space:]]//g|cut -d ':' -f2` Last_SQL_Errno=`cat /tmp/slave_23.txt|grep Last_SQL_Errno|sed s/[[:space:]]//g|cut -d ':' -f2` echo $Last_IO_Errno echo $Last_SQL_Errno ##Last_IO_Errno=100 ##Last_SQL_Errno=100 if [ "$seconds_behind" -ge 100 ]||[ "$seconds_behind" == "NULL" ]; then msg="测试环境23从库延迟=$seconds_behind秒,检查时间:${check_time}" /scripts/senddingd.sh 15889569091 "$msg" fi if [ "$Last_IO_Errno" -ne 0 ]||[ "$Last_SQL_Errno" -ne 0 ]; then msg="测试环境23从库复制报错,IO错误号:$Last_IO_Errno,SQL错误号:$Last_SQL_Errno,检查时间:${check_time}" /scripts/senddingd.sh 15889569091 "$msg" fi
标签:Last,Errno,mysql,behind,IO,SQL,slave,从库,延迟 From: https://www.cnblogs.com/hxlasky/p/17121873.html