MySQL主从监控脚本

#!/bin/bash


PORT=`netstat-na|grep"LISTEN"|grep"3306"|awk-F[:" "]+ ‘{print $4}‘`
IP=`ifconfigeth0|grep"inet addr"| awk-F[:" "]+ ‘{print $4}‘`
IO_env=`echo$STATUS | grepIO | awk‘ {print $2}‘`

SQL_env=`echo$STATUS | grepSQL | awk‘{print $2}‘`

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


if[ "$PORT"== "3306"]
then
   echo "mysql is running"
else
   echo "$IP mysql is down" | mail -s "warn!server: $IP mysql is down" [email protected]

fi


if[ "$IO_env"= "Yes"-a "$SQL_env"= "Yes"]
then
   echo "Slave is running!"

else

echo "Slave iserror!" | mail -s "warn! $DATA $IP MySQL Slave is not running" [email protected]

fi


然后每10分钟运行一次,编辑/etc/crontab文件,添加内容如下所示:

*/10* * * * root sh /root/mysql_slave.sh

本文出自 “流水莫须” 博客,请务必保留此出处http://yangjianwei.blog.51cto.com/4622731/1370167

MySQL主从监控脚本,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。