Created
January 19, 2014 20:57
-
-
Save zsprackett/8510906 to your computer and use it in GitHub Desktop.
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
#!/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