Skip to content

Instantly share code, notes, and snippets.

@Dnile
Created July 14, 2015 07:28
Show Gist options
  • Save Dnile/92ac42cea8e75a6e21c8 to your computer and use it in GitHub Desktop.
Save Dnile/92ac42cea8e75a6e21c8 to your computer and use it in GitHub Desktop.
import json
import click
import requests
def get_status(node):
es_stats = requests.get("http://%s:8080/_cluster/health?level=indices" % node)
indices = es_stats.json()['indices']
bad_indices = {k:v['status'] for k,v in indices.items() if 'green' not in v['status'] and 'nginx' in k}
for k,v in bad_indices.items():
requests.delete('http://%s:8080/%s/' % (node, k))
print k
@click.command()
@click.option('--node', help='es node to query')
def main(node):
get_status(node)
if __name__=="__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment