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 dcpmm plugin #914

Merged
merged 1 commit into from
Feb 24, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ documentation for each plugin for configurable attributes.
* `df` (see [collectd::plugin::df](#class-collectdplugindf) below)
* `disk` (see [collectd::plugin::disk](#class-collectdplugindisk) below)
* `dns` (see [collectd::plugin::dns](#class-collectdplugindns) below)
* `dcpmm` (see [collectd::plugin::dcpmm](#class-collectdplugindcpmm) below)
* `entropy` (see [collectd::plugin::entropy](#class-collectdpluginentropy) below)
* `exec` (see [collectd::plugin::exec](#class-collectdpluginexec) below)
* `ethstat` (see [collectd::plugin::ethstat](#class-collectdpluginethstat) below)
Expand Down Expand Up @@ -583,6 +584,17 @@ Boolean for SelectNumericQueryTypes configuration option.

- *Default*: true

#### Class: `collectd::plugin::dcpmm`

```puppet
class { 'collectd::plugin::dcpmm':
interval => 10.0,
collect_health => false,
collect_perf_metrics => true,
enable_dispatch_all => false,
}
```

#### Class: `collectd::plugin::entropy`

```puppet
Expand Down
35 changes: 35 additions & 0 deletions manifests/plugin/dcpmm.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Class to manage dcpmm plugin for collectd.
#
# The dcpmm plugin will collect Intel(R) Optane(TM) DC Persistent Memory related performance statistics.
# Plugin requires root privileges to perform the statistics collection.
#
# @param ensure Ensure param for collectd::plugin type.
# @param interval Sets interval (in seconds) in which the values will be collected.
# @param collect_health Collects health information. collect_health and collect_perf_metrics cannot be true at the same time.
# @param collect_perf_metrics Collects memory performance metrics. collect_health and collect_perf_metrics cannot be true at the same time.
# @param enable_dispatch_all This parameter helps to seamlessly enable simultaneous health and memory perf metrics collection in future. Unused at the moment and must always be false.
#
class collectd::plugin::dcpmm (
Enum['present', 'absent'] $ensure = 'present',
Float $interval = 10.0,
Boolean $collect_health = false,
Boolean $collect_perf_metrics = true,
Boolean $enable_dispatch_all = false,

) {

include collectd

if $collect_health and $collect_perf_metrics {
fail('collect_health and collect_perf_metrics cannot be true at the same time.')
}

if $enable_dispatch_all {
fail('enable_dispatch_all is unused at the moment and must always be false.')
}

collectd::plugin { 'dcpmm':
ensure => $ensure,
content => epp('collectd/plugin/dcpmm.conf.epp'),
}
}
120 changes: 120 additions & 0 deletions spec/classes/collectd_plugin_dcpmm_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
require 'spec_helper'

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

options = os_specific_options(facts)

context ':ensure => present, default params' do
content = <<EOS
# Generated by Puppet
<LoadPlugin dcpmm>
Globals false
</LoadPlugin>

<Plugin dcpmm>
Interval 10.0
CollectHealth false
CollectPerfMetrics true
EnableDispatchAll false
</Plugin>

EOS

it "Will create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do
is_expected.to compile.with_all_deps
is_expected.to contain_file('dcpmm.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf",
content: content
)
end
end

context ':ensure => absent' do
let :params do
{ ensure: 'absent' }
end

it "Will not create #{options[:plugin_conf_dir]}/10-dcpmm.conf" do
is_expected.to compile.with_all_deps
is_expected.to contain_file('dcpmm.load').with(
ensure: 'absent',
path: "#{options[:plugin_conf_dir]}/10-dcpmm.conf"
)
end
end

context ':ensure => present and :interval => 3.14' do
let :params do
{ interval: 3.14 }
end

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

context ':ensure => present, :collect_health => true and :collect_perf_metrics => false' do
let :params do
{ collect_health: true,
collect_perf_metrics: false }
end

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

context ':ensure => present and :collect_perf_metrics => false' do
let :params do
{ collect_perf_metrics: false }
end

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

context ':ensure => present, :collect_health => false and :collect_perf_metrics => true' do
let :params do
{ collect_health: true,
collect_perf_metrics: true }
end

it 'Will raise error' do
is_expected.to compile.and_raise_error(%r{collect_health and collect_perf_metrics cannot be true at the same time.})
end
end

context ':ensure => present and :enable_dispatch_all => true' do
let :params do
{ enable_dispatch_all: true }
end

it 'Will raise error' do
is_expected.to compile.and_raise_error(%r{enable_dispatch_all is unused at the moment and must always be false.})
end
end
end
end
end
14 changes: 14 additions & 0 deletions templates/plugin/dcpmm.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Plugin dcpmm>
<% if $collectd::plugin::dcpmm::interval { -%>
Interval <%= $collectd::plugin::dcpmm::interval %>
<% } -%>
<% unless $collectd::plugin::dcpmm::collect_health =~ Undef { -%>
CollectHealth <%= $collectd::plugin::dcpmm::collect_health %>
<% } -%>
<% unless $collectd::plugin::dcpmm::collect_perf_metrics =~ Undef { -%>
CollectPerfMetrics <%= $collectd::plugin::dcpmm::collect_perf_metrics %>
<% } -%>
<% unless $collectd::plugin::dcpmm::enable_dispatch_all =~ Undef { -%>
EnableDispatchAll <%= $collectd::plugin::dcpmm::enable_dispatch_all %>
<% } -%>
</Plugin>