-
-
Save coderxin/ba0f156be74c636d52096c9c3dc10379 to your computer and use it in GitHub Desktop.
Detect if a mysql slave is still running and touch slave_running, monit then watches the timestamp on the file
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
check file slave_running with path /opt/slave_running | |
if timestamp > 3 minutes then alert |
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 | |
MYSQL=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW SLAVE STATUS \G"` | |
IO=`echo "$MYSQL" | grep 'Slave_IO_Running:' | awk '{print $2}'` | |
SQL=`echo "$MYSQL" | grep 'Slave_SQL_Running:' | awk '{print $2}'` | |
if [ "Yes" == "$IO" ] && [ "Yes" == "$SQL" ]; then | |
touch /opt/slave_running | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment