mysql监控从库状态
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql监控从库状态相关的知识,希望对你有一定的参考价值。
#!/bin/bash #check mysql_Slave Status #crontab time 09:00 MYSQLPORT=`netstat -na|grep "LISTEN"|grep "3306"|awk ‘{print $4}‘|awk -F: ‘{print $2}‘` MYSQLIP=`ifconfig|awk ‘NR==2{print $2}‘|awk -F: ‘{print $2}‘` STATUS=$(mysql -hxxx -uxxx -pxxx -S /tmp/mysql.sock -e "show slave status\G" | grep -i "running") IO_env=`echo $STATUS | grep IO | awk ‘ {print $2}‘` SQL_env=`echo $STATUS | grep SQL | awk ‘{print $2}‘` DATA=`date +"%y-%m-%d %H:%M:%S"` if [ "$MYSQLPORT" == "3306" ] then echo "mysql is running" else echo $MYSQLIP mysql is down" | mail -s "warn!server: $MYSQLIP mysql is down" [email protected] fi if [ "$IO_env" = "Yes" -a "$SQL_env" = "Yes" ] then echo "Slave is running!" else echo "Slave is not running!" | mail -s "warn! $DATA $MYSQLIP MySQL Slave is not running" [email protected] fi
本文出自 “八英里” 博客,请务必保留此出处http://5921271.blog.51cto.com/5911271/1749149
以上是关于mysql监控从库状态的主要内容,如果未能解决你的问题,请参考以下文章