forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
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 redhat-openstack#297 from ChrisHeerschap/master
adding ValuesAbsolute and ValuesPercentage to memory and swap
- Loading branch information
Showing
6 changed files
with
116 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
# https://collectd.org/wiki/index.php/Plugin:Memory | ||
class collectd::plugin::memory ( | ||
$ensure = present, | ||
$interval = undef, | ||
$ensure = present, | ||
$valuesabsolute = true, | ||
$valuespercentage = false, | ||
$interval = undef, | ||
) { | ||
|
||
validate_bool( | ||
$valuesabsolute, | ||
$valuespercentage, | ||
) | ||
|
||
collectd::plugin {'memory': | ||
ensure => $ensure, | ||
content => template('collectd/plugin/memory.conf.erb'), | ||
interval => $interval, | ||
} | ||
} |
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,70 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::memory', :type => :class do | ||
|
||
context ':ensure => present, default params' do | ||
let :facts do | ||
{:osfamily => 'RedHat'} | ||
end | ||
it 'Will create /etc/collectd.d/10-memory.conf' do | ||
should contain_file('memory.load').with({ | ||
:ensure => 'present', | ||
:path => '/etc/collectd.d/10-memory.conf', | ||
:content => /LoadPlugin memory/, | ||
}) | ||
end | ||
end | ||
|
||
context ':ensure => present, specific params, collectd version 5.4.2' do | ||
let :facts do | ||
{ :osfamily => 'Redhat', | ||
:collectd_version => '5.4.2' | ||
} | ||
end | ||
|
||
it 'Will create /etc/collectd.d/10-memory.conf for collectd < 5.5' do | ||
should contain_file('memory.load').with({ | ||
:ensure => 'present', | ||
:path => '/etc/collectd.d/10-memory.conf', | ||
:content => /LoadPlugin memory/, | ||
}) | ||
end | ||
|
||
it 'Will not include ValuesPercentage in /etc/collectd.d/10-memory.conf' do | ||
should_not contain_file('memory.load').with_content(/ValuesPercentage/) | ||
end | ||
end | ||
|
||
context ':ensure => present, specific params, collectd version 5.5.0' do | ||
let :facts do | ||
{ :osfamily => 'Redhat', | ||
:collectd_version => '5.5.0' | ||
} | ||
end | ||
|
||
it 'Will create /etc/collectd.d/10-memory.conf for collectd >= 5.5' do | ||
should contain_file('memory.load').with({ | ||
:ensure => 'present', | ||
:path => '/etc/collectd.d/10-memory.conf', | ||
:content => "# Generated by Puppet\n<LoadPlugin memory>\n Globals false\n</LoadPlugin>\n\n<Plugin memory>\n ValuesAbsolute = true\n ValuesPercentage = false\n</Plugin>\n\n", | ||
}) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :facts do | ||
{:osfamily => 'RedHat'} | ||
end | ||
let :params do | ||
{:ensure => 'absent'} | ||
end | ||
|
||
it 'Will not create /etc/collectd.d/10-memory.conf' do | ||
should contain_file('memory.load').with({ | ||
:ensure => 'absent', | ||
:path => '/etc/collectd.d/10-memory.conf', | ||
}) | ||
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
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,6 @@ | ||
<% if @collectd_version and (scope.function_versioncmp([@collectd_version, '5.5']) >= 0) -%> | ||
<Plugin memory> | ||
ValuesAbsolute = <%= @valuesabsolute %> | ||
ValuesPercentage = <%= @valuespercentage %> | ||
</Plugin> | ||
<% 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