shell监控mysql主从同步

前端之家收集整理的这篇文章主要介绍了shell监控mysql主从同步前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

#!/bin/bah

#check_master-slave_status

#check_time=10m

MysqLIP=`ifconfig eth1|grep "inet addr"|awk -F[:" "]+{'print $4'}`

MysqLPORT=`netstat -lntp|grep 3306|awk -F[:" "]+ {'print $5'}`

STATUS=$(MysqL -uroot -p123456 -e"show slave status\G;|grep -i running")

IO_env=`echo $STATUS|grep -i io|awk {'print $2'}`

sql_env=`echo $STATUS|grep -i sql|awk {'print $2'}`

DATE=`date +"%y-%m-%d %H:%M:%S"`


if["$MysqLPORT"=="3306"];then

echo "MysqL is running..."

else

mail -s "warn!server:$MysqLIP MysqL is down..." 1243983186@163.com

fi


if["$IO_env"=="yes" -a "$sql_env"=="yes"];then

echo "slave is running..."

else

echo "###########$DATE##############">> /opt/check_MysqL_slave.log

echo "slave is not running...">> /opt/check_MysqL_sqlve.log

eceo "slave is not running..."|mail -s "warn!server:$MysqLIP MysqL_slave is not running..." 1243983186@163.com

fi

原文链接:https://www.f2er.com/bash/392000.html

猜你在找的Bash相关文章