Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mce log plugin #904

Merged
merged 1 commit into from Feb 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -145,6 +145,7 @@ documentation for each plugin for configurable attributes.
* `logfile` (see [collectd::plugin::logfile](#class-collectdpluginlogfile) below)
* `virt` (see [collectd::plugin::virt](#class-collectdpluginvirt) below)
* `lvm` (see [collectd::plugin::lvm](#class-collectdpluginlvm) below)
* `mcelog` (see [collectd::plugin::mcelog](#class-collectdpluginmcelog) below)
* `memcached`(see [collectd::plugin::memcached](#class-collectdpluginmemcached)
below )
* `memory`(see [collectd::plugin::memory](#class-collectdpluginmemory) below )
Expand Down Expand Up @@ -894,6 +895,16 @@ class { 'collectd::plugin::intel_pmu':
}
```

#### Class: `collectd::plugin::mcelog`

```puppet
class { 'collectd::plugin::mcelog':
mceloglogfile => '/var/log/mcelog'
memory => true
mcelogclientsocket => '/var/run/mcelog-client'
persistentnotification => true
}
```
#### Class: `collectd::plugin::intel_rdt`
```puppet
class { 'collectd::plugin::intel_rdt':
Expand Down
18 changes: 18 additions & 0 deletions manifests/plugin/mcelog.pp
@@ -0,0 +1,18 @@
# https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_mcelog
class collectd::plugin::mcelog (
Enum['present', 'absent'] $ensure = 'present',
# Log file option and memory option are mutualy exclusive.
Optional[String] $mceloglogfile = undef,
Optional[Collectd::MCELOG::Memory] $memory = undef
) {

include collectd

collectd::plugin { 'mcelog':
ensure => $ensure,
content => epp('collectd/plugin/mcelog.conf.epp', {
'mceloglogfile' => $mceloglogfile,
'memory' => $memory
}),
}
}
60 changes: 60 additions & 0 deletions spec/classes/collectd_plugin_mcelog_spec.rb
@@ -0,0 +1,60 @@
require 'spec_helper'

describe 'collectd::plugin::mcelog', type: :class do
on_supported_os(baseline_os_hash).each do |os, facts|
context "on #{os} " do
let :facts do
facts
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please also ensure that this compiles properly?

Something like this should work:

it { is_expected.to compile.with_all_deps }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

it { is_expected.to compile.with_all_deps }

options = os_specific_options(facts)
context ':ensure => present, default params' do
it "Will create #{options[:plugin_conf_dir]}/10-mcelog.conf" do
is_expected.to contain_file('mcelog.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-mcelog.conf"
)
end
end

context ':ensure => :mceloglogfile => true' do
let :params do
{
mceloglogfile: '/var/log/mcelog'
}
end

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

context ':ensure => :memory => true' do
let :params do
{
memory: {
'mcelogclientsocket' => '/var/run/mcelog-client',
'persistentnotification' => true
}
}
end

it "Will create #{options[:plugin_conf_dir]}/10-mcelog.conf" do
is_expected.to contain_file('mcelog.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-mcelog.conf"
)
end
it { is_expected.to contain_file('mcelog.load').with(content: %r{<Memory>}) }
it { is_expected.to contain_file('mcelog.load').with(content: %r{McelogClientSocket "/var/run/mcelog-client"}) }
it { is_expected.to contain_file('mcelog.load').with(content: %r{PersistentNotification true}) }
end
end
end
end
20 changes: 20 additions & 0 deletions templates/plugin/mcelog.conf.epp
@@ -0,0 +1,20 @@
<%- | Optional[String] $mceloglogfile = undef,
Optional $memory = undef,
| -%>
<Plugin mcelog>
<% if $mceloglogfile { %>
McelogLogfile "<%= $mceloglogfile %>"
<% } -%>
<% if $collectd::plugin::mcelog::memory { %>
<Memory>
<% $collectd::plugin::mcelog::memory.keys.sort.each |$key| { -%>
<% if $key == 'mcelogclientsocket' { -%>
McelogClientSocket "<%= $collectd::plugin::mcelog::memory[$key] %>"
<% } -%>
<% if $key == 'persistentnotification' { -%>
PersistentNotification <%= $collectd::plugin::mcelog::memory[$key] %>
<% } -%>
<% } -%>
</Memory>
<% } -%>
</Plugin>
5 changes: 5 additions & 0 deletions types/mcelog/memory.pp
@@ -0,0 +1,5 @@
# https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_mcelog
type Collectd::MCELOG::Memory = Struct[{
NotUndef['mcelogclientsocket'] => String[1],
NotUndef['persistentnotification'] => Boolean,
}]