Skip to content

Instantly share code, notes, and snippets.

@kazu634
Last active August 29, 2015 14:15
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 kazu634/8196a578fa1ec9ff9364 to your computer and use it in GitHub Desktop.
Save kazu634/8196a578fa1ec9ff9364 to your computer and use it in GitHub Desktop.
`Serf`で管理していないノードのグラフを削除する
#!/opt/sensu/embedded/bin/ruby
require 'growthforecast'
# Create `Growthforecast` instance:
gf = GrowthForecast.new('localhost', 5125)
glist = gf.graphs()
glist.each do |graph|
# Do nothing if the graph's name does not start with `host:`:
next unless graph.service_name =~ /^host:/
# delete the graph if the graph's name does not include the hostnames of `serf members`:
hostname = graph.service_name.sub(/^host:/, '')
unless `serf members | awk ' { print $1 } '`.include?(hostname)
gf.delete(graph)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment