Skip to content

Commit

Permalink
Merge 7a05bb3 into ed996d4
Browse files Browse the repository at this point in the history
  • Loading branch information
matejzero committed Oct 21, 2016
2 parents ed996d4 + 7a05bb3 commit fa76ebb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class { 'collectd::plugin::conntrack':
* `reportbystate` available from collectd version >= 5.5
* `reportbycpu` available from collectd version >= 5.5
* `valuespercentage` available from collectd version >= 5.5
* `reportnumcpu` available from collectd version >= 5.6

See [collectd plugin_cpu documentation](https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_cpu) for more details.

Expand Down
2 changes: 2 additions & 0 deletions manifests/plugin/cpu.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$reportbystate = true,
$reportbycpu = true,
$valuespercentage = false,
$reportnumcpu = false,
$interval = undef,
) {

Expand All @@ -13,6 +14,7 @@
$reportbystate,
$reportbycpu,
$valuespercentage,
$reportnumcpu,
)

collectd::plugin { 'cpu':
Expand Down
22 changes: 21 additions & 1 deletion spec/classes/collectd_plugin_cpu_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,34 @@
should contain_file('cpu.load').with_content(%r{ValuesPercentage true})
end
end

context 'cpu options should be set with collectd 5.6' do
let :facts do
{
osfamily: 'RedHat',
collectd_version: '5.6',
operatingsystemmajrelease: '7'
}
end
let :params do
{
reportnumcpu: true
}
end

it 'Will include ValuesPercentage in /etc/collectd.d/10-cpu.conf' do
should contain_file('cpu.load').with_content(%r{ReportNumCpu true})
end
end
end

context 'default parameters are not booleans' do
let :params do
{
reportbystate: 'string_a',
reportbycpu: 'string_b',
valuespercentage: 'string_c'
valuespercentage: 'string_c',
reportnumcpu: 'string_d'
}
end

Expand Down
3 changes: 3 additions & 0 deletions templates/plugin/cpu.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
ReportByState <%= @reportbystate %>
ReportByCpu <%= @reportbycpu %>
ValuesPercentage <%= @valuespercentage %>
<% if scope.lookupvar('collectd::collectd_version_real') and scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.6']) >= 0 -%>
ReportNumCpu <%= @reportnumcpu %>
<% end -%>
</Plugin>
<% end -%>

0 comments on commit fa76ebb

Please sign in to comment.