Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fduran/e6229925993be4d50e2d to your computer and use it in GitHub Desktop.
Save fduran/e6229925993be4d50e2d to your computer and use it in GitHub Desktop.
Check and alert if mysql slave is not running
#!/bin/bash
# check if mysql slave is running
log=/var/log/mysqlslave.log
email=user@example.com
date >> $log
res=`mysql -u root -pPassword -h db.example.com -N -B -e "show status like 'Slave_running'"|cut -f2`
if [ $res = 'ON' ]
then
echo 'running' >> $log
else
echo 'NOT RUNNING' >> $log
echo "Mysql slave not running" |mail -s "Slave not running" $email
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment