zoukankan      html  css  js  c++  java
  • 监控mysql状态并发送Email

    */10 * * * *  /shell/mysql_status.sh > /dev/null 2>&1

    #!/bin/bash

          port55=`/usr/sbin/lsof -i:3355 | wc -l`
          if test $port55 != 0
            then
            echo "$(date +%F-%T) xxx.xxx.xxx.xxx MySQL status runing!!" >> /shell/mysql_status.log
             else
             echo "$(date +%F-%T) xxx.xxx.xxx.xxx mysql status stop" >> /shell/mysql_status.log
             echo "$(date +%F-%T) xxx.xxx.xxx.xxx mysql status stop" > /shell/mysql_status_err.log
             /bin/mail -s "mysql55" xxxxx@qq.com < /shell/mysql_status_err.log
             fi

          declare -a sync55
          sync55=($(/usr/local/mysql5/bin/mysql -S /tmp/mysql55.sock -uroot -xxxxx -e 'show slave statusG' | grep "Running" | awk '{print $2}'))
          if [ "${sync55[0]}" = "Yes" -a "${sync55[1]}" = "Yes" ]
             then
             echo "$(date +%F-%T) xxx.xxx.xxx.xxx msyql synchronous security" >> /shell/mysql_status.log
             else
             echo "$(date +%F-%T) xxx.xxx.xxx.xxx msyql synchronous failure" >> /shell/mysql_status.log
             echo "$(date +%F-%T) xxx.xxx.xxx.xxx msyql synchronous failure" > /shell/mysql_status_err.log
             /bin/mail -s "mysql55" xxxxx@qq.com < /shell/mysql_status_err.log
             fi
    for i in 31 32 33 36;
    do
          port=`/usr/sbin/lsof -i:33$i | wc -l`
          if test $port != 0
            then
            echo "$(date +%F-%T) 192.168.180.$i mysql status runing!!" >> /shell/mysql_status.log
             else
             echo "$(date +%F-%T) 192.168.180.$i mysql status stop" >> /shell/mysql_status.log
             echo "$(date +%F-%T) 192.168.180.$i mysql status stop" > /shell/mysql_status_err.log
             /bin/mail -s "mysql$i" xxxxxxxxx@qq.com < /shell/mysql_status_err.log
             fi

          declare -a sync
          sync=($(/usr/local/mysql5/bin/mysql -S /tmp/mysql$i.sock -e 'show slave statusG' | grep "Running" | awk '{print $2}'))
          if [ "${sync[0]}" = "Yes" -a "${sync[1]}" = "Yes" ]
             then
             echo "$(date +%F-%T) 192.168.180.$i msyql synchronous security" >> /shell/mysql_status.log
             else
             echo "$(date +%F-%T) 192.168.180.$i msyql synchronous failure" >> /shell/mysql_status.log
             echo "$(date +%F-%T) 192.168.180.$i msyql synchronous failure" > /shell/mysql_status_err.log
             /bin/mail -s "mysql$i" xxxxxx@qq.com < /shell/mysql_status_err.log
             fi
    done

  • 相关阅读:
    二叉树的节点删除
    PHP开启错误日志详细说明
    jsonpath模块
    Gunicorn-配置详解
    Vmware创建虚拟机步骤说明,详细配置解释
    Python multiprocessing使用详解
    Python定时任务框架apscheduler
    Access-Control-Allow-Origin跨域解决及详细介绍
    web安全:x-content-type-options头设置
    sqlalchemy的基本操作大全
  • 原文地址:https://www.cnblogs.com/moss_tan_jun/p/6400805.html
Copyright © 2011-2022 走看看