Advertisement
fduran

Check and alert if mysql slave is not running

Sep 3rd, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.38 KB | None | 0 0
  1. #!/bin/bash
  2. # check if mysql slave is running
  3.  
  4. log=/var/log/mysqlslave.log
  5. email=user@example.com
  6.  
  7. date >> $log
  8. res=`mysql -u root -pPassword -h db.example.com -N -B -e "show status like 'Slave_running'"|cut -f2`
  9.  
  10. if [ $res = 'ON' ]
  11. then
  12.   echo 'running' >> $log
  13. else
  14.   echo 'NOT RUNNING' >> $log
  15.   echo "Mysql slave not running" |mail -s "Slave not running" $email
  16. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement