# #!/bin/sh # # Created by xieyy QQ:5090235 # To determine whether slave is running or not. TATUS_LOGS="/var/log/mysql_status.log" USERNAME=mysql_user PASSWD=mysql_password ADMIN="Email@email.com" DATA=`date '+%Y%m%d%k%M'` IP="192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4" #将所有想监控的从机的IP地址都放到IP表里。以空格为分隔。 cd /usr/bin/ for i in $IP do HOSTNAME=$i RESULT=`./mysql -u$USERNAME -p$PASSWD -h$HOSTNAME -e 'show status like "Slave_running"' -ss | awk '{print $2}'` if [ "$RESULT" == 'ON' ] then echo -e "$HOSTNAME $DATA Slave is running!" >> $TATUS_LOGS else echo -e "$HOSTNAME $DATA Slave is not running!">> $TATUS_LOGS fi sleep 1 done cd /root/bin /bin/mail $ADMIN -s "Status Report For DNS Server mysqld_slave status!!!!" < $TATUS_LOGS >$TATUS_LOGS
?