Reap Graphite nodes using Consul members
This file contains 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/bash | |
# Store the live members | |
consul members | grep alive | awk '{ print $1 }' > /tmp/alive.txt | |
# Clean-up the collectd metrics | |
cd /data/graphite/whisper/collectd | |
ls | awk '{print substr($1, 0, index($1, "_node_")) }' > /tmp/monitored.txt | |
for NODE in `cat /tmp/monitored.txt`; do if grep -q $NODE /tmp/alive.txt; then echo $NODE alive; else echo $NODE dead; sudo rm -Rf ${NODE}_node_*; fi; done | |
# Cleanup the gauges | |
cd /data/graphite/whisper/statsite/gauges | |
for DIR in `ls`; | |
do | |
pushd $DIR | |
for NODE in `ls`; do if grep -q $NODE /tmp/alive.txt; then echo $NODE alive; else echo $NODE dead; sudo rm -Rf ${NODE}; fi; done | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment