jmton 发表于 2018-1-2 10:35:15

CentOS下zabbix监控mysql5.6版本主从

#!/usr/bin/env bash  #Create by zijin 2014.09.28

  ##Need "grant REPLICATION CLIENT on *.* to zabbix_select@localhost>  #Mysql5.6
  # mysql_config_editor set --login-path=local --host=localhost --user=zabbix_select -p
  MYSQL_SOCK="/tmp/mysql.sock"
  MYSQL_PWD="zabbix"
  MYSQL="/usr/local/mysql/bin/mysql"
  MYSQL_ADMIN="${MYSQL}admin"
  ARGS=1
  if [ $# -ne "$ARGS" ];then
  echo "Please input one arguement:"
  fi
  case $1 in
  Slave_Running)
  slave_is=($(sudo ${MYSQL} --login-path=local -S $MYSQL_SOCK -e "show slave status\G"|egrep "\bSlave_.*_Running\b"|awk '{print $2}'))
  if [ "${slave_is}" = "Yes" -a "${slave_is}" = "Yes" ];then
  result="1"
  else
  result="0"
  fi
  echo $result
  ;;
  Seconds_Behind)
  result=$(sudo ${MYSQL} --login-path=local -S $MYSQL_SOCK -e "show slave status\G"|egrep "\bSeconds_Behind_Master\b"|awk '{print $2}')
  echo $result
  ;;
  *)
  echo "Usage:$0(Slave_Running|Seconds_Behind)"
  ;;
  esac

chelly 发表于 2018-3-14 15:56:05

这个很不错
页: [1]
查看完整版本: CentOS下zabbix监控mysql5.6版本主从