Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import os
import os.path
import sys
from graphite.render.hashing import ConsistentHashRing
instances = []
unwelcome_instances = []
for arg in sys.argv[1:]:
unwelcome = False
if arg.startswith('-'):
arg = arg[1:]
unwelcome = True
instance = tuple(arg.split(':', 2))
if unwelcome:
if 0 == len(instances):
print('Usage: python [-]<address>:<instance>[...]')
ring = ConsistentHashRing(instances)
for dirname, dirnames, filenames in os.walk('/var/lib/graphite/whisper'):
for filename in filenames:
pathname = os.path.join(dirname, filename)
basename, ext = os.path.splitext(filename)
if '.wsp' != ext:
print('skipping %s' % os.path.relpath(pathname,
if ring.get_node(os.path.relpath(os.path.join(dirname, basename),
replace('/', '.')) in unwelcome_instances:
print('unlinking %s' % pathname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment