mysql从库延迟检查脚本

脚本如下:

复制代码
[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
复制代码

 

posted @   slnngk  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示