首页 > 数据库技术 > 详细

监控mysql主从脚本

时间:2015-08-07 07:09:08      阅读:398      评论:0      收藏:0      [点我收藏+]

一、下载并解压sendEmail

 

cd /usr/local/src
wget tar -zxvf sendEmail-v1.56.tar.gz
cp sendEmail-v1.56/sendEmail /usr/local/bin/    
拷贝之后就能用了

发邮件命令:
sendEmail -fzhang_peicheng@163.com -t 756475064@qq.com -s smtp.163.com -u "test"-xu zhang_peicheng -xp xxxxxxxxxxxxx  -m"this is a test email"  -a/tmp/123.txt
简要说明 –f 发送方地址 –t发给谁 –s发送方smtp服务器 –u 主题
-xu 发送邮件账号 –xp  发送方邮箱的密码  -m 内容–a 邮件附件

二、mysql主从监控脚本

#!/bin/bash
#write by zhang_pc
#at 2015.08.06

SLAVE_IO_S=`mysql  -uroot -p123456 -e "show slave status \G;" |grep  "Slave_IO_Running"|awk -F ‘:‘ ‘{print $2}‘`
SLAVE_SQL_S=`mysql  -uroot -p123456 -e "show slave status \G;" |grep  "Slave_IO_Running"|awk -F ‘:‘ ‘{print $2}‘`
date1=`date +%Y%m%d`

if [ $SLAVE_IO_S == "Yes" ]&&[ $SLAVE_SQL_S == "Yes" ];then
	echo "the mysql-master-slave-status is ok"
else
	echo "the mysql-master-slave-status is failed"
	if [ ! -d /tmp/$date1 ];then
		mkdir -p /tmp/$date1
	fi
	mysql -uroot -p123456 -e "show slave status \G;" >/tmp/$date1/mysql-master-slave-status.txt
	sendEmail -f zhang_peicheng@163.com -t 756475064@qq.com -s smtp.163.com -u "mysql_status" -xu zhang_peicheng -xp xxxxxxxxxxxxx -m "the mysql-master-slave status is failed" -a /tmp/$date1/mysql-master-slave-status.txt 
fi


本文出自 “pc的个人博客” 博客,请务必保留此出处http://pc1990.blog.51cto.com/10541224/1682433

监控mysql主从脚本

原文:http://pc1990.blog.51cto.com/10541224/1682433

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!