-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #911 from prabiegx/collectd_pcie_errors
Add pcie_errors plugin
- Loading branch information
Showing
4 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |