Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. DB_USER=replc
  2. DB_PASS="your_password"
  3.  
  4. alert_to="your_email@address.org"
  5. alert_cc=""
  6. alert_subject="REPLICATION FAILED"
  7. alert_message="one of the replication threads on\
  8. the slave server failed or the server is down\n";
  9.  
  10. rf=$(mktemp)
  11.  
  12. echo "show slave status\G"|\
  13. mysql -u $DB_USER --password=$DB_PASS > $rf 2>&1
  14.  
  15.  
  16. repl_IO=$(cat $rf|grep "Slave_IO_Running"|cut -f2 -d':')
  17. repl_SQL=$(cat $rf|grep "Slave_SQL_Running"|cut -f2 -d':')
  18.  
  19.  
  20. if [ "$repl_IO" != " Yes" -o "$repl_SQL" != " Yes" ] ; then
  21.         if [ "$alert_cc" != "" ] ; then
  22.                 cc=" -c $alert_cc "
  23.         fi
  24.  
  25. cat <<EOF | mail -s "$alert_subject"  $alert_to $cc
  26. $alert_message
  27.  
  28. return from slave status command:
  29. $(cat $rf)
  30. EOF
  31. rm $rf
  32. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement