Skip to content

Commit

Permalink
add hugepages plugin
Browse files Browse the repository at this point in the history
In collectd 5.7, the hugepage plugin have been added.

This change adds its support in puppet-collectd
  • Loading branch information
sileht committed Jun 5, 2018
1 parent bb6aea3 commit 6797b59
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
59 changes: 59 additions & 0 deletions manifests/plugin/hugepages.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#== Class: collectd::plugin::hugepages
#
# Class to manage hugepages write plugin for collectd
#
# Documentation:
# https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_hugepages
#
# === Parameters
#
# [*ensure*]
# Ensure param for collectd::plugin type.
# Defaults to 'ensure'
#
# [*interval*]
# Interval setting for the plugin
# Defaults to undef
#
# [*report_per_node_hp*]
# If enabled, information will be collected from the hugepage counters in
# "/sys/devices/system/node/*/hugepages". This is used to check the per-node
# hugepage statistics on a NUMA system.
# Defaults to true
#
# [*report_root_hp*]
# If enabled, information will be collected from the hugepage counters in
# "/sys/kernel/mm/hugepages". This can be used on both NUMA and non-NUMA
# systems to check the overall hugepage statistics.
# Defaults to true
#
# [*values_pages*]
# Whether to report hugepages metrics in number of pages
# Defaults to true
#
# [*values_bytes*]
# Whether to report hugepages metrics in bytes
# Defaults to false
#
# [*values_percentage*]
# Whether to report hugepages metrics in percentage
# Defaults to false
#
class collectd::plugin::hugepages (
Enum['present', 'absent'] $ensure = 'present',
Optional[Integer] $interval = undef,
Boolean $report_per_node_hp = true,
Boolean $report_root_hp = true,
Boolean $values_pages = true,
Boolean $values_bytes = false,
Boolean $values_percentage = false,
) {

include collectd

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

describe 'collectd::plugin::hugepages', 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 'default' do
it 'defaults' do
content = <<EOS
# Generated by Puppet
<LoadPlugin hugepages>
Globals false
</LoadPlugin>
<Plugin "hugepages">
ReportPerNodeHP true
ReportRootHP true
ValuesPages true
ValuesBytes false
ValuesPercentage false
</Plugin>
EOS

is_expected.to compile.with_all_deps
is_expected.to contain_file('hugepages.load').with(
content: content,
path: "#{options[:plugin_conf_dir]}/10-hugepages.conf"
)
end
end

options = os_specific_options(facts)
context 'all set' do
let :params do
{
'report_per_node_hp' => false,
'report_root_hp' => false,
'values_pages' => false,
'values_bytes' => true,
'values_percentage' => true
}
end

it 'overrides defaults' do
content = <<EOS
# Generated by Puppet
<LoadPlugin hugepages>
Globals false
</LoadPlugin>
<Plugin "hugepages">
ReportPerNodeHP false
ReportRootHP false
ValuesPages false
ValuesBytes true
ValuesPercentage true
</Plugin>
EOS

is_expected.to compile.with_all_deps
is_expected.to contain_class('collectd')
is_expected.to contain_file('hugepages.load').with(
content: content,
path: "#{options[:plugin_conf_dir]}/10-hugepages.conf"
)
end
end
end
end
end
7 changes: 7 additions & 0 deletions templates/plugin/hugepages.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Plugin "hugepages">
ReportPerNodeHP <%= $collectd::plugin::hugepages::report_per_node_hp %>
ReportRootHP <%= $collectd::plugin::hugepages::report_root_hp %>
ValuesPages <%= $collectd::plugin::hugepages::values_pages %>
ValuesBytes <%= $collectd::plugin::hugepages::values_bytes %>
ValuesPercentage <%= $collectd::plugin::hugepages::values_percentage %>
</Plugin>

0 comments on commit 6797b59

Please sign in to comment.