#!/bin/bash
user="root"
password="123456"
mycmd="mysql -u$user -p$password -h 192.168.100.20"


function chkdb() {
list=($($mycmd -e "show slave status \G"|egrep "Running|Behind"|awk -F: '{print $2}'))
if [ ${list[0]} = "Yes" -a ${list[1]} = "Yes" -a ${list[2]} -lt 120 ]
then echo "Mysql slave is ok"
else echo "Mysql slave replation is filed"
fi
}

function main() {
while true
do chkdb
   sleep 3
done
}
main

  

posted on 2019-09-29 15:54  一纸情书べ  阅读(83)  评论(0编辑  收藏  举报