-
-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #642 from jkroepke/plugin_turbostat
Add Plugin turbostat
- Loading branch information
Showing
3 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_turbostat | ||
class collectd::plugin::turbostat ( | ||
Enum['present', 'absent'] $ensure = 'present', | ||
Optional[Integer] $core_c_states = undef, | ||
Optional[Integer] $package_c_states = undef, | ||
Optional[Boolean] $system_management_interrupt = undef, | ||
Optional[Boolean] $digital_temperature_sensor = undef, | ||
Optional[Integer] $tcc_activation_temp = undef, | ||
Optional[Integer] $running_average_power_limit = undef, | ||
) { | ||
include ::collectd | ||
|
||
collectd::plugin { 'turbostat': | ||
ensure => $ensure, | ||
content => template('collectd/plugin/turbostat.conf.erb'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::turbostat', type: :class do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '4.8.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
context ':ensure => present, default params' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '4.8.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load'). | ||
with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{# Generated by Puppet\nLoadPlugin turbostat\n\n<Plugin turbostat>\n</Plugin>\n}) | ||
end | ||
end | ||
|
||
context ':ensure => present and :core_c_states => 392' do | ||
let :params do | ||
{ core_c_states: 392 } | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load').with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{CoreCstates "392"}m) | ||
end | ||
end | ||
|
||
context ':ensure => present and :package_c_states => 396' do | ||
let :params do | ||
{ package_c_states: 396 } | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load').with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{PackageCstates "396"}m) | ||
end | ||
end | ||
|
||
context ':ensure => present and :system_management_interrupt => false' do | ||
let :params do | ||
{ system_management_interrupt: false } | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load').with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{SystemManagementInterrupt "false"}m) | ||
end | ||
end | ||
|
||
context ':ensure => present and :digital_temperature_sensor => false' do | ||
let :params do | ||
{ digital_temperature_sensor: false } | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load').with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{DigitalTemperatureSensor "false"}m) | ||
end | ||
end | ||
|
||
context ':ensure => present and :tcc_activation_temp => 40' do | ||
let :params do | ||
{ tcc_activation_temp: 40 } | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load').with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{TCCActivationTemp "40"}m) | ||
end | ||
end | ||
|
||
context ':ensure => present and :running_average_power_limit => 8' do | ||
let :params do | ||
{ running_average_power_limit: 8 } | ||
end | ||
it 'Will create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load').with(ensure: 'present', | ||
path: '/etc/collectd.d/10-turbostat.conf', | ||
content: %r{RunningAveragePowerLimit "8"}m) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :facts do | ||
{ | ||
osfamily: 'RedHat', | ||
collectd_version: '4.8.0', | ||
operatingsystemmajrelease: '7', | ||
python_dir: '/usr/local/lib/python2.7/dist-packages' | ||
} | ||
end | ||
|
||
let :params do | ||
{ ensure: 'absent' } | ||
end | ||
|
||
it 'Will not create /etc/collectd.d/10-turbostat.conf' do | ||
is_expected.to contain_file('turbostat.load'). | ||
with(ensure: 'absent', | ||
path: '/etc/collectd.d/10-turbostat.conf') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Plugin turbostat> | ||
<% 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 -%> | ||
</Plugin> |