Skip to content

Instantly share code, notes, and snippets.

@cafuego
Last active December 14, 2015 03:39
Show Gist options
  • Save cafuego/5022329 to your computer and use it in GitHub Desktop.
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
#!/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