diff --git a/opsworks_ganglia/attributes/default.rb b/opsworks_ganglia/attributes/default.rb index 89c1516085..00702ee7bb 100644 --- a/opsworks_ganglia/attributes/default.rb +++ b/opsworks_ganglia/attributes/default.rb @@ -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" @@ -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 diff --git a/opsworks_ganglia/recipes/client.rb b/opsworks_ganglia/recipes/client.rb index 6a9af5c3ae..9374c4fa9f 100644 --- a/opsworks_ganglia/recipes/client.rb +++ b/opsworks_ganglia/recipes/client.rb @@ -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 @@ -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 diff --git a/opsworks_ganglia/recipes/configure-client.rb b/opsworks_ganglia/recipes/configure-client.rb index 48a2912d04..8cc7391cb4 100644 --- a/opsworks_ganglia/recipes/configure-client.rb +++ b/opsworks_ganglia/recipes/configure-client.rb @@ -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| diff --git a/opsworks_ganglia/recipes/monitor-apache.rb b/opsworks_ganglia/recipes/monitor-apache.rb index 723fab4578..1627949977 100644 --- a/opsworks_ganglia/recipes/monitor-apache.rb +++ b/opsworks_ganglia/recipes/monitor-apache.rb @@ -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' diff --git a/opsworks_ganglia/recipes/monitor-nginx.rb b/opsworks_ganglia/recipes/monitor-nginx.rb index 742bd7f429..c1b59c54eb 100644 --- a/opsworks_ganglia/recipes/monitor-nginx.rb +++ b/opsworks_ganglia/recipes/monitor-nginx.rb @@ -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" diff --git a/opsworks_ganglia/specs/configure-client_spec.rb b/opsworks_ganglia/specs/configure-client_spec.rb index e08428b5d9..637d8ccff4 100644 --- a/opsworks_ganglia/specs/configure-client_spec.rb +++ b/opsworks_ganglia/specs/configure-client_spec.rb @@ -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 diff --git a/opsworks_ganglia/specs/monitor-nginx_spec.rb b/opsworks_ganglia/specs/monitor-nginx_spec.rb index 6b6fa0a7ad..31f94dda3e 100644 --- a/opsworks_ganglia/specs/monitor-nginx_spec.rb +++ b/opsworks_ganglia/specs/monitor-nginx_spec.rb @@ -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