Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2012 11:12
Show Gist options
  • Save anonymous/4368868 to your computer and use it in GitHub Desktop.
Save anonymous/4368868 to your computer and use it in GitHub Desktop.
include_recipe 'gdash'
all_deployments = search(:customer_deployments, "*:*").map { |d| d['id'] }
Chef::Log.info( "Found deployments: #{all_deployments.inspect}" )
all_deployments.each do |d|
nodes = search(:node, "customer_deployment:#{d}").map { |n| n['hostname'] }
nodes_in_deployment = nodes.select { |n| customer_deployment(n) == d }
Chef::Log.info( "Found nodes in deployment #{d} #{nodes_in_deployment}")
nodes_in_deployment.each do |n|
gdash_dashboard "#{n}" do
category "#{d}"
description "#{d} - #{n}"
end
# CPU
gdash_dashboard_component 'cpu' do
dashboard_name "#{n}"
dashboard_category "#{d}"
colours{
'idle' => 'red',
'system' => 'yellow',
'interrupt' => 'blue',
'nice' => 'green',
'softirq' => 'purple',
'steal' => 'brown',
'user' => 'orange',
'wait' => 'pink'
}
%w{idle system interrupt nice softirq steal user wait}.each do |s|
fields{ s.to_sym => {
:data => "collectd.#{d}.#{n}.cpu.0.cpu.#{s}.value",
:alias => s,
:cacti_style => true,
:color => colours[s]
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment