Skip to content

Commit

Permalink
turbotstat: Add LogicalCoreNames option
Browse files Browse the repository at this point in the history
Since collectd-5.7, we can configure the name convention for core names.

This change adds this.
  • Loading branch information
sileht committed Jun 12, 2018
1 parent e69dd24 commit d5c1fc1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
3 changes: 2 additions & 1 deletion manifests/plugin/turbostat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
Optional[Boolean] $digital_temperature_sensor = undef,
Optional[Integer] $tcc_activation_temp = undef,
Optional[Integer] $running_average_power_limit = undef,
Optional[Boolean] $logical_core_names = undef,
) {
include ::collectd

collectd::plugin { 'turbostat':
ensure => $ensure,
content => template('collectd/plugin/turbostat.conf.erb'),
content => epp('collectd/plugin/turbostat.conf.epp'),
}
}
18 changes: 18 additions & 0 deletions spec/classes/collectd_plugin_turbostat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@
end
end

context ':ensure => present and :logical_core_names => true and collectd 5.7' do
let :facts do
facts.merge(collectd_version: '5.7')
end

let :params do
{ logical_core_names: true }
end

it "Will create #{options[:plugin_conf_dir]}/10-turbostat.conf" do
is_expected.to contain_file('turbostat.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-turbostat.conf",
content: %r{LogicalCoreNames "true"}m
)
end
end

context ':ensure => present and :tcc_activation_temp => 40' do
let :params do
{ tcc_activation_temp: 40 }
Expand Down
25 changes: 25 additions & 0 deletions templates/plugin/turbostat.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Plugin turbostat>
<% if $collectd::plugin::turbostat::core_c_states { -%>
CoreCstates "<%= $collectd::plugin::turbostat::core_c_states %>"
<% } -%>
<% if $collectd::plugin::turbostat::package_c_states { -%>
PackageCstates "<%= $collectd::plugin::turbostat::package_c_states %>"
<% } -%>
<% if $collectd::plugin::turbostat::system_management_interrupt != undef { -%>
SystemManagementInterrupt "<%= $collectd::plugin::turbostat::system_management_interrupt %>"
<% } -%>
<% if $collectd::plugin::turbostat::digital_temperature_sensor != undef { -%>
DigitalTemperatureSensor "<%= $collectd::plugin::turbostat::digital_temperature_sensor %>"
<% } -%>
<% if $collectd::plugin::turbostat::tcc_activation_temp { -%>
TCCActivationTemp "<%= $collectd::plugin::turbostat::tcc_activation_temp %>"
<% } -%>
<% if $collectd::plugin::turbostat::running_average_power_limit { -%>
RunningAveragePowerLimit "<%= $collectd::plugin::turbostat::running_average_power_limit %>"
<% } -%>
<% if versioncmp($collectd::collectd_version_real, '5.7') >= 0 { -%>
<% if $collectd::plugin::turbostat::logical_core_names { -%>
LogicalCoreNames "<%= $collectd::plugin::turbostat::logical_core_names %>"
<% } -%>
<% } -%>
</Plugin>
20 changes: 0 additions & 20 deletions templates/plugin/turbostat.conf.erb

This file was deleted.

0 comments on commit d5c1fc1

Please sign in to comment.