From d5c1fc111968b09800ca23a3e9ba8059a1e16489 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Tue, 5 Jun 2018 15:15:34 +0200 Subject: [PATCH] turbotstat: Add LogicalCoreNames option Since collectd-5.7, we can configure the name convention for core names. This change adds this. --- manifests/plugin/turbostat.pp | 3 ++- .../classes/collectd_plugin_turbostat_spec.rb | 18 +++++++++++++ templates/plugin/turbostat.conf.epp | 25 +++++++++++++++++++ templates/plugin/turbostat.conf.erb | 20 --------------- 4 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 templates/plugin/turbostat.conf.epp delete mode 100644 templates/plugin/turbostat.conf.erb diff --git a/manifests/plugin/turbostat.pp b/manifests/plugin/turbostat.pp index 8c68d9c2c..306196e05 100644 --- a/manifests/plugin/turbostat.pp +++ b/manifests/plugin/turbostat.pp @@ -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'), } } diff --git a/spec/classes/collectd_plugin_turbostat_spec.rb b/spec/classes/collectd_plugin_turbostat_spec.rb index 4cd00a22a..affe9ee42 100644 --- a/spec/classes/collectd_plugin_turbostat_spec.rb +++ b/spec/classes/collectd_plugin_turbostat_spec.rb @@ -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 } diff --git a/templates/plugin/turbostat.conf.epp b/templates/plugin/turbostat.conf.epp new file mode 100644 index 000000000..4e370b9d1 --- /dev/null +++ b/templates/plugin/turbostat.conf.epp @@ -0,0 +1,25 @@ + +<% 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 %>" +<% } -%> +<% } -%> + diff --git a/templates/plugin/turbostat.conf.erb b/templates/plugin/turbostat.conf.erb deleted file mode 100644 index f6e631335..000000000 --- a/templates/plugin/turbostat.conf.erb +++ /dev/null @@ -1,20 +0,0 @@ - -<% if @core_c_states -%> - CoreCstates "<%= @core_c_states %>" -<% end -%> -<% if @package_c_states -%> - PackageCstates "<%= @package_c_states %>" -<% end -%> -<% unless @system_management_interrupt.nil? -%> - SystemManagementInterrupt "<%= @system_management_interrupt %>" -<% end -%> -<% unless @digital_temperature_sensor.nil? -%> - DigitalTemperatureSensor "<%= @digital_temperature_sensor %>" -<% end -%> -<% if @tcc_activation_temp -%> - TCCActivationTemp "<%= @tcc_activation_temp %>" -<% end -%> -<% if @running_average_power_limit -%> - RunningAveragePowerLimit "<%= @running_average_power_limit %>" -<% end -%> - \ No newline at end of file