Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: update cpu for collectd 5.8 #801

Merged
merged 1 commit into from
May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion manifests/plugin/cpu.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
Boolean $reportbycpu = true,
Boolean $valuespercentage = false,
Boolean $reportnumcpu = false,
Boolean $reportgueststate = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datatypes \o/

Boolean $subtractgueststate = true,
Optional[Integer[1]] $interval = undef,
) {

include ::collectd

collectd::plugin { 'cpu':
ensure => $ensure,
content => template('collectd/plugin/cpu.conf.erb'),
content => epp('collectd/plugin/cpu.conf.epp'),
interval => $interval,
}
}
40 changes: 40 additions & 0 deletions spec/classes/collectd_plugin_cpu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
it "Will not include ValuesPercentage in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{ValuesPercentage})
end

it "Will not include ReportGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{ReportGuestState})
end
it "Will not include SubtractGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{SubtractGuestState})
end
end

context 'cpu options should be set with collectd 5.5' do
Expand All @@ -58,6 +65,13 @@
it "Will include ValuesPercentage in #{options[:plugin_conf_dir]}/10-cpu.conf" do
is_expected.to contain_file('cpu.load').with_content(%r{ValuesPercentage true})
end

it "Will not include ReportGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{ReportGuestState})
end
it "Will not include SubtractGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{SubtractGuestState})
end
end

context 'cpu options should be set with collectd 5.6' do
Expand All @@ -73,6 +87,32 @@
it "Will include ValuesPercentage in #{options[:plugin_conf_dir]}/10-cpu.conf" do
is_expected.to contain_file('cpu.load').with_content(%r{ReportNumCpu true})
end

it "Will not include ReportGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{ReportGuestState})
end
it "Will not include SubtractGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.not_to contain_file('cpu.load').with_content(%r{SubtractGuestState})
end
end

context 'cpu options should be set with collectd 5.8' do
let :facts do
facts.merge(collectd_version: '5.8')
end
let :params do
{
reportgueststate: true,
subtractgueststate: false
}
end

it "Will include ReportGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.to contain_file('cpu.load').with_content(%r{ReportGuestState true})
end
it "Will include SubtractGuestState in #{options[:plugin_conf_dir]}d/10-cpu.conf" do
is_expected.to contain_file('cpu.load').with_content(%r{SubtractGuestState false})
end
end
end

Expand Down
14 changes: 14 additions & 0 deletions templates/plugin/cpu.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% if versioncmp($::collectd::collectd_version_real, '5.5') >= 0 { -%>
<Plugin cpu>
ReportByState <%= $::collectd::plugin::cpu::reportbystate %>
ReportByCpu <%= $::collectd::plugin::cpu::reportbycpu %>
ValuesPercentage <%= $::collectd::plugin::cpu::valuespercentage %>
<% if versioncmp($::collectd::collectd_version_real, '5.6') >= 0 { -%>
ReportNumCpu <%= $::collectd::plugin::cpu::reportnumcpu %>
<% } -%>
<% if versioncmp($::collectd::collectd_version_real, '5.8') >= 0 { -%>
ReportGuestState <%= $::collectd::plugin::cpu::reportgueststate %>
SubtractGuestState <%= $::collectd::plugin::cpu::subtractgueststate %>
<% } -%>
</Plugin>
<% } -%>
10 changes: 0 additions & 10 deletions templates/plugin/cpu.conf.erb

This file was deleted.