Skip to content

Commit

Permalink
Merge pull request #911 from prabiegx/collectd_pcie_errors
Browse files Browse the repository at this point in the history
Add pcie_errors plugin
  • Loading branch information
bastelfreak committed Feb 18, 2020
2 parents 20a2f6e + 2fb0e2d commit 176618d
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ documentation for each plugin for configurable attributes.
* `nut` (see [collectd::plugin::nut](#class-collectdpluginnut) below)
* `openldap` (see [collectd::plugin::openldap](#class-collectdpluginopenldap) below)
* `openvpn` (see [collectd::plugin::openvpn](#class-collectdpluginopenvpn) below)
* `pcie_errors` (see [collectd::plugin::pcie_errors](#class-collectdpluginpcie_errors) below)
* `perl` (see [collectd::plugin::perl](#class-collectdpluginperl) below)
* `ping` (see [collectd::plugin::ping](#class-collectdpluginping) below)
* `postgresql` (see [collectd::plugin::postgresql](#class-collectdpluginpostgresql)
Expand Down Expand Up @@ -1245,6 +1246,17 @@ class { 'collectd::plugin::openvpn':
}
```

#### Class: `collectd::plugin::pcie_errors`

```puppet
class { 'collectd::plugin::pcie_errors':
source => undef,
access_dir => undef,
report_masked => false,
persistent_notifications => false,
}
```

#### Class: `collectd::plugin::perl`

This class has no parameters and will load the actual perl plugin.
Expand Down
23 changes: 23 additions & 0 deletions manifests/plugin/pcie_errors.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Class to manage pcie_errors plugin for collectd
#
# @param ensure Ensure param for collectd::plugin type.
# @param source Use sysfs or proc to read data from /sysfs or /proc.
# @param access_dir Directory used to access device config space.
# @param report_masked If true plugin will notify about errors that are set to masked in Error Mask register.
# @param persistent_notifications If false plugin will dispatch notification only on set/clear of error.
#
class collectd::plugin::pcie_errors (
Enum['present', 'absent'] $ensure = 'present',
Enum['sysfs', 'proc'] $source = 'sysfs',
Optional[String] $access_dir = undef,
Boolean $report_masked = false,
Boolean $persistent_notifications = false,
) {

include collectd

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

describe 'collectd::plugin::pcie_errors', 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 pcie_errors>
Globals false
</LoadPlugin>
<Plugin pcie_errors>
Source "sysfs"
ReportMasked false
# PersistentNotifications false
</Plugin>
EOS

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

context ':ensure => present and :source => proc' do
let :params do
{ source: 'proc' }
end

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

context ':ensure => present and :access_dir => /sys/bus/pci' do
let :params do
{ access_dir: '/sys/bus/pci' }
end

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

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

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

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

it "Will create #{options[:plugin_conf_dir]}/10-pcie_errors.conf" do
is_expected.to compile.with_all_deps
is_expected.to contain_file('pcie_errors.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-pcie_errors.conf",
content: %r{PersistentNotifications true}m
)
end
end
end
end
end
14 changes: 14 additions & 0 deletions templates/plugin/pcie_errors.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Plugin pcie_errors>
<% if $collectd::plugin::pcie_errors::source { -%>
Source "<%= $collectd::plugin::pcie_errors::source %>"
<% } -%>
<% if $collectd::plugin::pcie_errors::access_dir { -%>
AccessDir "<%= $collectd::plugin::pcie_errors::access_dir %>"
<% } -%>
<% unless $collectd::plugin::pcie_errors::report_masked =~ Undef { -%>
ReportMasked <%= $collectd::plugin::pcie_errors::report_masked %>
<% } -%>
<% unless $collectd::plugin::pcie_errors::persistent_notifications =~ Undef { -%>
# PersistentNotifications <%= $collectd::plugin::pcie_errors::persistent_notifications %>
<% } -%>
</Plugin>

0 comments on commit 176618d

Please sign in to comment.