Skip to content

Commit

Permalink
Ganglia: Don't try to mount EBS volumes if they are not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gruenewald committed Nov 26, 2014
1 parent ae0edc7 commit e03e9cb
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
11 changes: 7 additions & 4 deletions opsworks_ganglia/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@
include_attribute 'apache2::apache'

default[:ganglia][:datadir] = '/vol/ganglia'
default[:ganglia][:conf_dir] = "#{node[:ganglia][:datadir]}/conf"
default[:ganglia][:events_dir] = "#{node[:ganglia][:datadir]}/conf/events.json.d/"
default[:ganglia][:original_datadir] = '/var/lib/ganglia'
default[:ganglia][:autofs_options] = "-fstype=none,bind,rw"
default[:ganglia][:autofs_entry] = "#{node[:ganglia][:original_datadir]} #{node[:ganglia][:autofs_options]} :#{node[:ganglia][:datadir]}"
default[:ganglia][:conf_dir] = "#{node[:ganglia][:original_datadir]}/conf"
default[:ganglia][:events_dir] = "#{node[:ganglia][:original_datadir]}/conf/events.json.d/"
default[:ganglia][:tcp_client_port] = 8649
default[:ganglia][:udp_client_port] = 8666
default[:ganglia][:user] = 'ganglia'
default[:ganglia][:rrds_user] = 'nobody'

if infrastructure_class?('ec2')
default[:ganglia][:autofs_options] = "-fstype=none,bind,rw"
default[:ganglia][:autofs_entry] = "#{node[:ganglia][:original_datadir]} #{node[:ganglia][:autofs_options]} :#{node[:ganglia][:datadir]}"
end

case node[:platform_family]
when "debian"
default[:ganglia][:custom_package_version] = '3.3.8'
Expand Down
2 changes: 1 addition & 1 deletion opsworks_ganglia/recipes/configure-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end

["dwoo/compiled","dwoo/cache"].each do |dir|
directory "#{node[:ganglia][:datadir]}/#{dir}" do
directory "#{node[:ganglia][:original_datadir]}/#{dir}" do
owner node[:apache][:user]
group node[:apache][:group]
mode '0755'
Expand Down
2 changes: 1 addition & 1 deletion opsworks_ganglia/recipes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

ruby_block 'Create new events.json file for Ganglia' do
block do
::File.open(node[:ganglia][:datadir] + '/conf/events.json', 'w') do |file|
::File.open(node[:ganglia][:original_datadir] + '/conf/events.json', 'w') do |file|
file.puts '[' + Dir["#{node[:ganglia][:events_dir]}/*.json"].sort.map {|event| ::File.read(event)}.join(',') + ']'
end
end
Expand Down
4 changes: 2 additions & 2 deletions opsworks_ganglia/recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
action :stop
end

include_recipe 'opsworks_ganglia::bind-mount-data'
include_recipe 'opsworks_ganglia::bind-mount-data' if infrastructure_class?('ec2')

template '/etc/ganglia/gmetad.conf' do
source 'gmetad.conf.erb'
Expand All @@ -76,7 +76,7 @@
end

execute "fix permissions on ganglia rrds directory" do
command "chown -R #{node[:ganglia][:rrds_user]}:#{node[:ganglia][:user]} #{node[:ganglia][:datadir]}/rrds"
command "chown -R #{node[:ganglia][:rrds_user]}:#{node[:ganglia][:user]} #{node[:ganglia][:original_datadir]}/rrds"
end

include_recipe 'apache2::service'
Expand Down
4 changes: 2 additions & 2 deletions opsworks_ganglia/recipes/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# generate individual server view json
instances.keys.each do |instance_name|
template "#{node[:ganglia][:datadir]}/conf/host_#{instance_name}.json" do
template "#{node[:ganglia][:original_datadir]}/conf/host_#{instance_name}.json" do
source 'host_view_json.erb'
mode "0644"
owner node[:apache][:user]
Expand All @@ -27,7 +27,7 @@
end

# generate opsworks view json for autorotation
template "#{node[:ganglia][:datadir]}/conf/view_overview.json" do
template "#{node[:ganglia][:original_datadir]}/conf/view_overview.json" do
source 'view_overview.json.erb'
mode "0644"
owner node[:apache][:user]
Expand Down
2 changes: 1 addition & 1 deletion opsworks_ganglia/specs/configure-server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@
end

it 'displays "Ganglia Monitoring" on the website' do
assert system("curl http://localhost | grep 'Ganglia Monitoring'")
assert system("curl -s http://localhost | grep 'Ganglia Monitoring'")
end
end
4 changes: 2 additions & 2 deletions opsworks_ganglia/specs/views_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

instances.keys.each do |instance_name|
file(
::File.join(node[:ganglia][:datadir], 'conf', "host_#{instance_name}.json")
::File.join(node[:ganglia][:original_datadir], 'conf', "host_#{instance_name}.json")
).must_exist.with(:mode, '644').and(:owner, node[:apache][:user]).and(:group, node[:apache][:group])
end
end

it 'creates view_overview json' do
file(
::File.join(node[:ganglia][:datadir], 'conf', 'view_overview.json')
::File.join(node[:ganglia][:original_datadir], 'conf', 'view_overview.json')
).must_exist.with(:mode, '644').and(:owner, node[:apache][:user]).and(:group, node[:apache][:group])
end
end
2 changes: 1 addition & 1 deletion opsworks_ganglia/templates/default/gmetad.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ gridname "AWS OpsWorks"

# Where gmetad stores its round-robin databases
# default: "/var/lib/ganglia/rrds"
rrd_rootdir "<%= node[:ganglia][:datadir] %>/rrds"
rrd_rootdir "<%= node[:ganglia][:original_datadir] %>/rrds"

0 comments on commit e03e9cb

Please sign in to comment.