Chinaunix首页 | 论坛 | 博客
  • 博客访问: 877917
  • 博文数量: 354
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 3730
  • 用 户 组: 普通用户
  • 注册时间: 2017-08-21 18:43
文章分类

全部博文(354)

文章存档

2019年(126)

2018年(223)

2017年(5)

我的朋友

分类: Mysql/postgreSQL

2018-06-21 16:07:46

写监控脚本 不同步时发送邮件

#!/bin/bash

. /etc/init.d/functions

function check(){

rep_file=/tmp/rep$(date +%F).txt

while true

 do

rep=(`/application/mysql/bin/mysql -e "show slave status\G"|awk '/Slave_SQL_Running:/{print $2};/Slave_IO_Running:/{print $2};$1~/Seconds_Behind_Master/{print $2}'|xargs`)

  if [ "${rep[0]}" != "Yes" ]; then

     echo "Slave_IO_Running: NO" >$rep_file

     break 1

  fi

  if [ "${rep[1]}" != "Yes" ]; then

     echo "Slave_SQL_Running: NO" >$rep_file

  fi


  if [ "${rep[2]}" -ne 0 ]; then

     echo " Seconds_Behind_Master delay" >$rep_file

     break 1

  fi

  sleep 3

done

}


function main(){

  while true

  do

     check

     mail -s "replication false" snowxue521520@163.com



阅读(1281) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~