Last active
December 14, 2015 03:39
-
-
Save cafuego/5022329 to your computer and use it in GitHub Desktop.
Small shell script to keep an eye on xtradb cluster nodes and their statuses
This file contains hidden or 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/sh | |
CONFIG=/etc/mysql/conf.d/xtradb-cluster.cnf | |
# With a syntax of gcomm://foo,bar,frog this should work eh? | |
NODES="$(grep ^wsrep_cluster_address ${CONFIG} | cut -d '/' -f3- | tr ',' ' ')" | |
if [ -z "${NODES}" ]; then | |
echo "Cannot find cluster nodes in config file: ${CONFIG}" | |
exit 1 | |
fi | |
# Loop de loop. | |
while true; do | |
echo "Cluster at $(date)"; | |
for node in ${NODES}; do | |
printf "%-15s: " ${node} && (nc -w 1 ${node} 9200 || echo "Percona XtraDB Cluster Node is very dead and not at all synced.") | grep sync; | |
done; | |
sleep 10; | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment