Last active
August 29, 2015 14:15
-
-
Save kazu634/8196a578fa1ec9ff9364 to your computer and use it in GitHub Desktop.
`Serf`で管理していないノードのグラフを削除する
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
#!/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