Created
February 12, 2015 10:40
-
-
Save UserAd/236de9382b01940fbec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
real_lag=`mysql --defaults-file=/etc/mysql/debian.cnf -B -N -e "SELECT now()-timestamp AS replication_lag from tel_p.heartbeat;"` | |
seconds=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" | awk -F ": " {'print $2'}` | |
if [ "$real_lag" -gt "100" ] | |
then | |
logger "lag more than 100" | |
if [ "$seconds" -eq "0" ] | |
then | |
logger "Replication stopped. Restarting..." | |
mysqladmin --defaults-file=/etc/mysql/debian.cnf stop-slave | |
mysqladmin --defaults-file=/etc/mysql/debian.cnf start-slave | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment