Skip to content

Instantly share code, notes, and snippets.

@kevinclcn
Forked from lefred/check_mysql.sh
Created March 9, 2018 05:29
Show Gist options
  • Save kevinclcn/55f32499a69cc96480e90eafc810e9ec to your computer and use it in GitHub Desktop.
Save kevinclcn/55f32499a69cc96480e90eafc810e9ec to your computer and use it in GitHub Desktop.
MySQL InnoDB Cluster Consul check
# script used in consul
# the following addition to sys is required:
# https://gist.github.com/lefred/153448f7ea0341d6d0daa2738db6fcd8
# v.0.1 - lefred 2018-02-14
read -r mysql_primary mysql_readonly mysql_tx mysql_cert <<<$(mysql -h 127.0.0.1 -P 6446 -BNe "select * from sys.gr_member_routing_candidate_status")
if [[ "${mysql_primary}" == "YES" ]] && [[ "${mysql_readonly}" == "NO" ]]
then
echo "MySQL InnoDB Cluster is fine"
exit 0
fi
echo "MySQL InnoDB Cluster is not OK (Primary: ${mysql_primary}, R/O: ${mysql_readonly})"
exit 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment