diff --git a/attributes/default.rb b/attributes/default.rb index c29e004..cbcb2a9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -72,6 +72,33 @@ default['openstack']['telemetry_metric']['gnocchi-upgrade-options'] = '' # Configuration for /etc/ceilometer/pipeline.yaml default['openstack']['telemetry']['pipeline']['publishers'] = ['gnocchi://'] +# Configuration for /etc/ceilometer/polling.yaml +default['openstack']['telemetry']['polling']['interval'] = 300 +default['openstack']['telemetry']['polling']['meters'] = + %w( + cpu + cpu_l3_cache + memory.usage + network.incoming.bytes + network.incoming.packets + network.outgoing.bytes + network.outgoing.packets + disk.device.read.bytes + disk.device.read.requests + disk.device.write.bytes + disk.device.write.requests + hardware.cpu.util + hardware.memory.used + hardware.memory.total + hardware.memory.buffer + hardware.memory.cached + hardware.memory.swap.avail + hardware.memory.swap.total + hardware.system_stats.io.outgoing.blocks + hardware.system_stats.io.incoming.blocks + hardware.network.ip.incoming.datagrams + hardware.network.ip.outgoing.datagrams + ) %w(telemetry_metric aodh).each do |ts| # specify whether to enable SSL for ceilometer API endpoint diff --git a/recipes/agent-central.rb b/recipes/agent-central.rb index 8eef3d4..8cd901b 100644 --- a/recipes/agent-central.rb +++ b/recipes/agent-central.rb @@ -33,5 +33,6 @@ service 'ceilometer-agent-central' do service_name platform['agent_central_service'] subscribes :restart, "template[#{node['openstack']['telemetry']['conf_file']}]" subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml')}]" + subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'polling.yaml')}]" action [:enable, :start] end diff --git a/recipes/agent-compute.rb b/recipes/agent-compute.rb index 10acb38..b95adb5 100644 --- a/recipes/agent-compute.rb +++ b/recipes/agent-compute.rb @@ -33,5 +33,6 @@ service 'ceilometer-agent-compute' do service_name platform['agent_compute_service'] subscribes :restart, "template[#{node['openstack']['telemetry']['conf_file']}]" subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml')}]" + subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'polling.yaml')}]" action [:enable, :start] end diff --git a/recipes/agent-notification.rb b/recipes/agent-notification.rb index 465e5bd..b18daf8 100644 --- a/recipes/agent-notification.rb +++ b/recipes/agent-notification.rb @@ -32,5 +32,6 @@ service 'ceilometer-agent-notification' do service_name platform['agent_notification_service'] subscribes :restart, "template[#{node['openstack']['telemetry']['conf_file']}]" subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml')}]" + subscribes :restart, "template[#{::File.join(node['openstack']['telemetry']['conf_dir'], 'polling.yaml')}]" action [:enable, :start] end diff --git a/recipes/common.rb b/recipes/common.rb index 1edfc38..9b9e52a 100644 --- a/recipes/common.rb +++ b/recipes/common.rb @@ -109,3 +109,14 @@ template ::File.join(node['openstack']['telemetry']['conf_dir'], 'pipeline.yaml' publishers: node['openstack']['telemetry']['pipeline']['publishers'] ) end + +template ::File.join(node['openstack']['telemetry']['conf_dir'], 'polling.yaml') do + source 'polling.yaml.erb' + owner node['openstack']['telemetry']['user'] + group node['openstack']['telemetry']['group'] + mode 0o0640 + variables( + interval: node['openstack']['telemetry']['polling']['interval'], + meters: node['openstack']['telemetry']['polling']['meters'] + ) +end diff --git a/spec/agent-central_spec.rb b/spec/agent-central_spec.rb index 8e4d450..ba05faa 100644 --- a/spec/agent-central_spec.rb +++ b/spec/agent-central_spec.rb @@ -27,6 +27,9 @@ describe 'openstack-telemetry::agent-central' do it 'subscribes to /etc/ceilometer/pipeline.yaml' do expect(chef_run.service('ceilometer-agent-central')).to subscribe_to('template[/etc/ceilometer/pipeline.yaml]').delayed end + it 'subscribes to /etc/ceilometer/polling.yaml' do + expect(chef_run.service('ceilometer-agent-central')).to subscribe_to('template[/etc/ceilometer/polling.yaml]').delayed + end end end end diff --git a/spec/agent-compute_spec.rb b/spec/agent-compute_spec.rb index 5f09196..345bf70 100644 --- a/spec/agent-compute_spec.rb +++ b/spec/agent-compute_spec.rb @@ -27,6 +27,9 @@ describe 'openstack-telemetry::agent-compute' do it 'subscribes to /etc/ceilometer/pipeline.yaml' do expect(chef_run.service('ceilometer-agent-compute')).to subscribe_to('template[/etc/ceilometer/pipeline.yaml]').delayed end + it 'subscribes to /etc/ceilometer/polling.yaml' do + expect(chef_run.service('ceilometer-agent-compute')).to subscribe_to('template[/etc/ceilometer/polling.yaml]').delayed + end end end end diff --git a/spec/agent-notification_spec.rb b/spec/agent-notification_spec.rb index 0a0de38..4da4a51 100644 --- a/spec/agent-notification_spec.rb +++ b/spec/agent-notification_spec.rb @@ -27,6 +27,9 @@ describe 'openstack-telemetry::agent-notification' do it 'subscribes to /etc/ceilometer/pipeline.yaml' do expect(chef_run.service('ceilometer-agent-notification')).to subscribe_to('template[/etc/ceilometer/pipeline.yaml]').delayed end + it 'subscribes to /etc/ceilometer/polling.yaml' do + expect(chef_run.service('ceilometer-agent-notification')).to subscribe_to('template[/etc/ceilometer/polling.yaml]').delayed + end end end end diff --git a/spec/common_spec.rb b/spec/common_spec.rb index fec824c..5f141d7 100644 --- a/spec/common_spec.rb +++ b/spec/common_spec.rb @@ -50,6 +50,55 @@ EOL end end + describe '/etc/ceilometer/polling.yaml' do + polling_yaml = <<-EOL +# This file is automatically generated by Chef +# Any changes will be overwritten + +--- +sources: + - name: some_pollsters + interval: 300 + meters: + - cpu + - cpu_l3_cache + - memory.usage + - network.incoming.bytes + - network.incoming.packets + - network.outgoing.bytes + - network.outgoing.packets + - disk.device.read.bytes + - disk.device.read.requests + - disk.device.write.bytes + - disk.device.write.requests + - hardware.cpu.util + - hardware.memory.used + - hardware.memory.total + - hardware.memory.buffer + - hardware.memory.cached + - hardware.memory.swap.avail + - hardware.memory.swap.total + - hardware.system_stats.io.outgoing.blocks + - hardware.system_stats.io.incoming.blocks + - hardware.network.ip.incoming.datagrams + - hardware.network.ip.outgoing.datagrams +EOL + + it do + expect(chef_run).to create_template('/etc/ceilometer/polling.yaml') + .with( + source: 'polling.yaml.erb', + owner: 'ceilometer', + group: 'ceilometer', + mode: 0o0640 + ) + end + + it do + expect(chef_run).to render_file('/etc/ceilometer/polling.yaml').with_content(polling_yaml) + end + end + describe '/etc/ceilometer' do let(:dir) { chef_run.directory('/etc/ceilometer') } diff --git a/templates/polling.yaml.erb b/templates/polling.yaml.erb new file mode 100644 index 0000000..4047757 --- /dev/null +++ b/templates/polling.yaml.erb @@ -0,0 +1,9 @@ +<%= node['openstack']['common']['custom_template_banner'] %> +--- +sources: + - name: some_pollsters + interval: <%= @interval %> + meters: + <% @meters.each do |meter| -%> + - <%= meter %> + <% end -%>