Skip to content

Instantly share code, notes, and snippets.

@namenu
Last active June 22, 2017 13:14
Show Gist options
  • Save namenu/11129988 to your computer and use it in GitHub Desktop.
Save namenu/11129988 to your computer and use it in GitHub Desktop.
MySQL crontab
#!/bin/bash
MYSQL=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW GLOBAL STATUS LIKE 'Slave_running'" | grep 'Slave_running' | awk '{ print $2 }'`
res="$MYSQL"
if [ $res != "ON" ]; then
touch replication.broken
echo 'Replication was broken' | /usr/bin/mail -s 'echo 'Replication was broken' | /usr/bin/mail -s "[`hostname`] Replication was broken"' infradev.team@ridicorp.com
fi
#MYSQL=`mysql --defaults-file=/etc/mysql/debian.cnf -e "SHOW SLAVE STATUS\G"`
#!/bin/bash
pt-query-digest /storage/mysql/slow.log | mail -s 'echo 'Replication was broken' | /usr/bin/mail -s "[`hostname`] Replication was broken"' infradev.team@ridicorp.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment