Skip to content

Instantly share code, notes, and snippets.

@zsprackett
Created January 19, 2014 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsprackett/8510906 to your computer and use it in GitHub Desktop.
Save zsprackett/8510906 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Copyright (C) 2014 - S. Zachariah Sprackett <zac@sprackett.com>
#
require 'rubygems'
require 'json'
require 'open-uri'
state_json = open('http://localhost:9200/_cluster/state').read
state = JSON.parse(state_json)
unless state.kind_of?(Hash) and
state.has_key?('routing_nodes') and
state['routing_nodes'].kind_of?(Hash) and
state['routing_nodes'].has_key?('unassigned') and
state['routing_nodes']['unassigned'].kind_of?(Array)
warn "Failed to retrieve and parse state"
exit 1
end
indexes = []
state['routing_nodes']['unassigned'].each do |u|
if u.kind_of?(Hash) and u.has_key?('index') and
not indexes.include?(u['index'])
puts u['index']
indexes << u['index']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment