diff --git a/README.md b/README.md index a4f7f6fbc..583fdd089 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/manifests/plugin/dcpmm.pp b/manifests/plugin/dcpmm.pp new file mode 100644 index 000000000..31da1208c --- /dev/null +++ b/manifests/plugin/dcpmm.pp @@ -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'), + } +} diff --git a/spec/classes/collectd_plugin_dcpmm_spec.rb b/spec/classes/collectd_plugin_dcpmm_spec.rb new file mode 100644 index 000000000..9d62793bd --- /dev/null +++ b/spec/classes/collectd_plugin_dcpmm_spec.rb @@ -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 = < + Globals false + + + + Interval 10.0 + CollectHealth false + CollectPerfMetrics true + EnableDispatchAll false + + +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 diff --git a/templates/plugin/dcpmm.conf.epp b/templates/plugin/dcpmm.conf.epp new file mode 100644 index 000000000..af6859329 --- /dev/null +++ b/templates/plugin/dcpmm.conf.epp @@ -0,0 +1,14 @@ + +<% 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 %> +<% } -%> +