Skip to content

Instantly share code, notes, and snippets.

@armon
Created February 21, 2015 01:10
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Reap Graphite nodes using Consul members
#!/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