Chinaunix首页 | 论坛 | 博客
  • 博客访问: 198949
  • 博文数量: 75
  • 博客积分: 2049
  • 博客等级: 大尉
  • 技术积分: 780
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-08 12:37
文章分类

全部博文(75)

文章存档

2011年(1)

2010年(9)

2009年(65)

我的朋友

分类:

2009-04-30 17:12:04

#!/bin/bash

#configuration

slave_host='localhost'
slave_port='3306'
slave_user='root'
slave_password='123456'
my_command='/usr/bin/mysql'
io_ok="Slave_IO_Running: Yes"
sql_ok="Slave_SQL_Running: Yes"
Behind_Master_NULL="Seconds_Behind_Master: NULL"
###############################


##function


#sebd Email

send_mail(){
        mail -s "Slave status" root@localhost.localdomain << EOF
        $io_status
        $sql_status
        $Behind_Master_Status
EOF

}


#get slave status

result=$($my_command -h"$slave_host" -P"$slave_port" -u"$slave_user" -p"$slave_password" -e 'show slave status\G')
io_status=$(echo "$result" | grep "Slave_IO_Running:")
sql_status=$(echo "$result"|grep "Slave_SQL_Running:")
Behind_Master_Status=$(echo "$result" | grep "Seconds_Behind_Master")

if [[ $io_ok || $sql_ok || $Behind_Master_Status=$Behind_Master_NULL ]]
then
        send_mail
fi

阅读(751) | 评论(0) | 转发(0) |
0

上一篇:mysql二进制日志备份

下一篇:英语笔记

给主人留下些什么吧!~~