Skip to content

Commit

Permalink
Merge pull request #565 from crimpy88/thermal
Browse files Browse the repository at this point in the history
Addition of thermal plugin
  • Loading branch information
jyaworski committed Nov 7, 2016
2 parents bb3a6d7 + e7fa943 commit 9dd3749
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ documentation for each plugin for configurable attributes.
* `target_v5upgrade` (see [collectd::plugin::target_v5upgrade](#class-collectdplugintarget_v5upgrade)
below)
* `tcpconns` (see [collectd::plugin::tcpconns](#class-collectdplugintcpconns) below)
* `thermal` (see [collectd::plugin::thermal](#class-collectdpluginthermal) below)
* `unixsock` (see [collectd::plugin::unixsock](#class-collectdpluginunixsock) below)
* `uptime` (see [collectd::plugin::uptime](#class-collectdpluginuptime) below)
* `users` (see [collectd::plugin::users](#class-collectdpluginusers) below)
Expand Down Expand Up @@ -1532,7 +1533,16 @@ collectd::plugin::tail::file { 'exim-log':
}
```

#### Class: `collectd::plugin::unixsock`
####Class: `collectd::plugin::thermal`

```puppet
class { '::collectd::plugin::thermal':
devices => ['foo0'],
ignoreselected => false,
}
```

####Class: `collectd::plugin::unixsock`

```puppet
class {'collectd::plugin::unixsock':
Expand Down
6 changes: 6 additions & 0 deletions examples/plugins/thermal.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include ::collectd

class { '::collectd::plugin::thermal':
device => ['foo0'],
ignoreselected => false,
}
19 changes: 19 additions & 0 deletions manifests/plugin/thermal.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://collectd.org/wiki/index.php/Plugin:thermal
class collectd::plugin::thermal (
$devices = [],
$ensure = 'present',
$ignoreselected = false,
$interval = undef,
) {

include ::collectd

validate_array($devices)
validate_bool($ignoreselected)

collectd::plugin { 'thermal':
ensure => $ensure,
content => template('collectd/plugin/thermal.conf.erb'),
interval => $interval,
}
}
49 changes: 49 additions & 0 deletions spec/classes/collectd_plugin_thermal_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
require 'spec_helper'

describe 'collectd::plugin::thermal', type: :class do
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
options = os_specific_options(facts)
context ':ensure => present' do
let :params do
{
devices: ['foo0'],
ensure: 'present'
}
end
it { is_expected.to contain_collectd__plugin('thermal') }
it 'Will create 10-thermal.conf' do
is_expected.to contain_file('thermal.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-thermal.conf",
content: "#\ Generated by Puppet\n<LoadPlugin thermal>\n Globals false\n</LoadPlugin>\n\n<Plugin \"thermal\">\n Device \"foo0\"\n IgnoreSelected false\n</Plugin>\n\n"
)
end
end

context ':ensure => absent' do
let :params do
{ ensure: 'absent' }
end
it 'Will not create 10-thermal.conf' do
is_expected.to contain_file('thermal.load').with(
ensure: 'absent',
path: "#{options[:plugin_conf_dir]}/10-thermal.conf"
)
end
end

context ':devices is not an array' do
let :params do
{ devices: 'foo0' }
end
it 'Will raise an error about :devices not being an array' do
is_expected.to compile.and_raise_error(%r{String})
end
end
end
end
end
8 changes: 8 additions & 0 deletions templates/plugin/thermal.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '4.5']) >= 0) -%>
<Plugin "thermal">
<% @devices.each do |device| -%>
Device "<%= device %>"
<% end -%>
IgnoreSelected <%= @ignoreselected %>
</Plugin>
<% end -%>

0 comments on commit 9dd3749

Please sign in to comment.