Mysql 主从状态监控

来源:互联网 发布:java random生成随机数 编辑:程序博客网 时间:2024/05/20 22:28
#!/bin/bashDBuser=rootDBpasswd=123456Mail="wang@163.com"Result=/tmp/mysql.txtState=`netstat -lnpt | grep 3306`if [ -z "$State" ]  then#    mail -s "Can't connect to Mysql database" $Mail < /dev/null    echo "Can't connect to Mysql database"  else    mysql -u$DBuser -p$DBpasswd -e "show slave status\G" > $Result 2> /dev/null    Slave_IO_Running=`grep -i slave_io_running $Result | cut -d : -f 2`    Slave_SQL_Running=`grep -i slave_sql_running $Result | cut -d : -f 2`  if [ "$Slave_IO_Running" != ' Yes' -o "$Slave_SQL_Running" != ' Yes' ]    then#      mail -s "Mysql replication has stopped" $Mail < $Result      echo "Mysql replication has stopped"  fifi

0 0