Skip to content

Instantly share code, notes, and snippets.

@kazu634
Created March 1, 2016 13:36
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/bdfa819c8ae4df36aee5 to your computer and use it in GitHub Desktop.
Save kazu634/bdfa819c8ae4df36aee5 to your computer and use it in GitHub Desktop.
#!/opt/td-agent/embedded/bin/ruby
require 'growthforecast'
COLOR_CPU = {
'hiq' => '#77cc11',
'idl' => '#77cccc',
'siq' => '#77cc11',
'sys' => '#cc7711',
'usr' => '#cc77cc',
'wai' => '#cccc11'
}
COLOR_MEMORY = {
'buff' => '#77cc11',
'cach' => '#cccc11',
'free' => '#11cccc',
'used' => '#cc77cc',
}
COLOR_DISK_IO = {
'read' => '#11cc11',
'writ' => '#6699cc',
}
COLOR_NETWORK = {
'recv' => '#11cc11',
'send' => '#6699cc',
}
COLOR_DF = '#33cc66'
gf = GrowthForecast.new('localhost', 5125)
glist = gf.graphs()
glist.each do |g|
# puts "#{g.service_name}:#{g.section_name}:#{g.graph_name}"
graph = gf.graph(g.id)
case g.section_name
when 'cpu' then
graph.color = COLOR_CPU[g.graph_name[-3..-1]]
graph.type = 'AREA'
graph.llimit = 0
graph.ulimit = 100
when 'df' then
graph.color = COLOR_DF
graph.type = 'LINE'
when 'loadavg' then
graph.type = 'LINE'
graph.adjustval = 100
graph.llimit = 0
graph.ulimit = 10000
when 'disk_io' then
graph.color = COLOR_DISK_IO[g.graph_name[-4..-1]]
graph.type = 'AREA'
when 'memory' then
graph.color = COLOR_MEMORY[g.graph_name[-4..-1]]
graph.type = 'AREA'
graph.llimit = 0
graph.ulimit = 1000000000
when /(tcp|udp)/ then
graph.type = 'LINE'
when 'network' then
graph.color = COLOR_NETWORK[g.graph_name[-4..-1]]
graph.type = 'AREA'
end
result = gf.edit(graph)
raise "Something goes wrong..." unless result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment