Last active
January 4, 2018 04:12
-
-
Save sicksand/564c420b208b72ece1d60332a5e8f995 to your computer and use it in GitHub Desktop.
Check MySQL Replication Slave is running. If not will email to sysadmin using mailgun
This file contains 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 | |
COUNT=`'SHOW SLAVE STATUS\G' | mysql -u root --password=password123 mysql | grep 'Master_Log_Pos' | awk '/Read/{a=$NF} /Exec/{b=$NF} END{print a-b}'` | |
# echo "count" $COUNT | |
# check if COUNT value is zero or not zero | |
if [ $COUNT -gt 0 ]; then | |
curl -s --user 'api:key-getyourkeyatmailgun' \ | |
https://api.mailgun.net/v3/mg.shafiqmustapa.my/messages \ | |
-F from='MySQL Replication Status <postmaster@mg.shafiqmustapa.my>' \ | |
-F to='Shafiq Mustapa <sicksand@gmail.com>' \ | |
-F cc='Project Manager <pm@zanko.com.my>, Support <support@zanko.com.my>, ' \ | |
-F subject='Please check MySQL Replication Status' \ | |
-F text="Ada beza logs. $COUNT" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment