Skip to content

Commit

Permalink
Fix ganglia cookbook plugin system and layer awareness.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Requena committed Aug 23, 2013
1 parent 1fc4095 commit 20f0aee
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 29 deletions.
3 changes: 2 additions & 1 deletion opsworks_ganglia/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
default[:ganglia][:monitor_plugins_package_name] = "ganglia-monitor-python"

default[:ganglia][:custom_package_version] = '3.3.8-1'
default[:ganglia][:package_arch] = RUBY_PLATFORM.match(/64/) ? 'amd64':'i386'
default[:ganglia][:package_arch] = RUBY_PLATFORM.match(/64/) ? 'amd64' : 'i386'
default[:ganglia][:package_base_url] = "#{node[:opsworks_commons][:assets_url]}/packages/#{node[:platform]}/#{node[:platform_version]}"

default[:ganglia][:gmetad_package] = "#{node[:ganglia][:gmetad_package_name]}_#{node[:ganglia][:custom_package_version]}_#{node[:ganglia][:package_arch]}.deb"
Expand All @@ -38,6 +38,7 @@
when "rhel"
default[:ganglia][:gmetad_package_name] = "ganglia-gmetad"
default[:ganglia][:monitor_package_name] = "ganglia-gmond"
default[:ganglia][:monitor_plugins_package_name] = "ganglia-gmond-python"
default[:ganglia][:web_frontend_package_name] = "ganglia-web"
end

Expand Down
39 changes: 21 additions & 18 deletions opsworks_ganglia/recipes/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

when "rhel"
package node[:ganglia][:monitor_package_name]
package node[:ganglia][:monitor_plugins_package_name]
end

execute 'stop gmond with non-updated configuration' do
Expand All @@ -49,25 +50,27 @@
include_recipe 'opsworks_ganglia::monitor-fd-and-sockets'
include_recipe 'opsworks_ganglia::monitor-disk'

case node[:opsworks][:instance][:layers]
when 'memcached'
include_recipe 'opsworks_ganglia::monitor-memcached'
when 'db-master'
include_recipe 'opsworks_ganglia::monitor-mysql'
when 'lb'
include_recipe 'opsworks_ganglia::monitor-haproxy'
when 'php-app','monitoring-master'
include_recipe 'opsworks_ganglia::monitor-apache'
when 'web'
include_recipe 'opsworks_ganglia::monitor-nginx'
when 'rails-app'

case node[:opsworks][:rails_stack][:name]
when 'apache_passenger'
include_recipe 'opsworks_ganglia::monitor-passenger'
node[:opsworks][:instance][:layers].each do |layer|
case layer
when 'memcached'
include_recipe 'opsworks_ganglia::monitor-memcached'
when 'db-master'
include_recipe 'opsworks_ganglia::monitor-mysql'
when 'lb'
include_recipe 'opsworks_ganglia::monitor-haproxy'
when 'php-app','monitoring-master'
include_recipe 'opsworks_ganglia::monitor-apache'
when 'nginx_unicorn'
when 'web'
include_recipe 'opsworks_ganglia::monitor-nginx'
end
when 'rails-app'

case node[:opsworks][:rails_stack][:name]
when 'apache_passenger'
include_recipe 'opsworks_ganglia::monitor-passenger'
include_recipe 'opsworks_ganglia::monitor-apache'
when 'nginx_unicorn'
include_recipe 'opsworks_ganglia::monitor-nginx'
end

end
end
8 changes: 3 additions & 5 deletions opsworks_ganglia/recipes/configure-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
end
end

if monitoring_master.nil?
execute 'Stop gmond if there is no monitoring master' do
command 'pkill gmond'
only_if 'pgrep gmond'
end
execute 'Stop gmond if there is no monitoring master' do
command 'pkill gmond'
only_if { monitoring_master.nil? && 'pgrep gmond' }
end

if node[:opsworks][:instance][:layers].any?{ |layer|
Expand Down
2 changes: 1 addition & 1 deletion opsworks_ganglia/recipes/monitor-apache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

cookbook_file '/etc/ganglia/python_modules/apache.py' do
path value_for_platform_family(
"rhel" => "/usr/lib#{RUBY_PLATFORM.match(/64/) ? 'amd64' : 'i386'}/ganglia/python_modules/apache.py",
"rhel" => "/usr/lib#{RUBY_PLATFORM.match[/64/]}/ganglia/python_modules/apache.py",
"debian" => '/usr/lib/ganglia/python_modules/apache.py'
)
source 'apache.py'
Expand Down
2 changes: 1 addition & 1 deletion opsworks_ganglia/recipes/monitor-nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

template "nginx_status.py" do
path value_for_platform_family(
"rhel" => "/usr/lib#{RUBY_PLATFORM.match(/64/) ? 'amd64' : 'i386'}/ganglia/python_modules/nginx_status.py"
"rhel" => "/usr/lib#{RUBY_PLATFORM.match[/64/]}/ganglia/python_modules/nginx_status.py"
"debian" => '/usr/lib/ganglia/python_modules/nginx_status.py'
)
source "nginx_status.py.erb"
Expand Down
9 changes: 6 additions & 3 deletions opsworks_ganglia/specs/configure-client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
file('/etc/ganglia/gmond.conf').must_include node[:opsworks][:stack][:name]
end

it 'makes sure gmond is stopped if there is no monitoring master' do
skip if @monitoring_master
service('gmond').wont_be_running
it 'makes sure gmond is running if necessary' do
if @monitoring_master
service('gmond').must_be_running
else
service('gmond').wont_be_running
end
end
end
12 changes: 12 additions & 0 deletions opsworks_ganglia/specs/monitor-nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@
include MiniTest::Chef::Resources
include MiniTest::Chef::Assertions

it "has the nginx ganglia plugin and configuration" do
plugin_path = case node["platform"]
when 'centos','redhat','fedora','amazon'
"/usr/lib#{RUBY_PLATFORM.match[/64/]}/ganglia/python_modules/nginx_status.py"
when 'debian','ubuntu'
'/usr/lib/ganglia/python_modules/nginx_status.py'
end

file(plugin_path).must_exist
file('/etc/ganglia/conf.d/nginx_status.pyconf').must_exist
end

end

0 comments on commit 20f0aee

Please sign in to comment.