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.
- Loading branch information
Showing
6 changed files
with
191 additions
and
55 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,25 +1,43 @@ | ||
# https://collectd.org/wiki/index.php/Graphite | ||
class collectd::plugin::write_graphite ( | ||
$ensure = present, | ||
$graphitehost = 'localhost', | ||
$graphiteport = 2003, | ||
$storerates = true, | ||
$graphiteprefix = 'collectd.', | ||
$graphitepostfix = undef, | ||
$carbons = {}, | ||
$interval = undef, | ||
$escapecharacter = '_', | ||
$alwaysappendds = false, | ||
$protocol = 'tcp', | ||
$separateinstances = false, | ||
$logsenderrors = true, | ||
$ensure = present, | ||
$globals = false, | ||
) { | ||
validate_bool($storerates) | ||
validate_bool($separateinstances) | ||
validate_bool($logsenderrors) | ||
include collectd::params | ||
|
||
validate_hash($carbons) | ||
|
||
collectd::plugin {'write_graphite': | ||
ensure => $ensure, | ||
content => template('collectd/plugin/write_graphite.conf.erb'), | ||
globals => $globals, | ||
interval => $interval, | ||
} | ||
|
||
# should be loaded after global plugin configuration | ||
$graphite_conf = "${collectd::params::plugin_conf_dir}/write_graphite-config.conf" | ||
|
||
concat{ $graphite_conf: | ||
ensure => $ensure, | ||
mode => '0640', | ||
owner => 'root', | ||
group => $collectd::params::root_group, | ||
notify => Service['collectd'], | ||
ensure_newline => true, | ||
} | ||
|
||
concat::fragment{'collectd_plugin_write_graphite_conf_header': | ||
order => '00', | ||
content => '<Plugin write_graphite>', | ||
target => $graphite_conf, | ||
} | ||
|
||
concat::fragment{'collectd_plugin_write_graphite_conf_footer': | ||
order => '99', | ||
content => '</Plugin>', | ||
target => $graphite_conf, | ||
} | ||
|
||
create_resources(collectd::plugin::write_graphite::carbon, $carbons) | ||
} |
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,30 @@ | ||
# a single graphite backend | ||
define collectd::plugin::write_graphite::carbon ( | ||
$ensure = present, | ||
$graphitehost = 'localhost', | ||
$graphiteport = 2003, | ||
$storerates = true, | ||
$graphiteprefix = 'collectd.', | ||
$graphitepostfix = undef, | ||
$interval = undef, | ||
$escapecharacter = '_', | ||
$alwaysappendds = false, | ||
$protocol = 'tcp', | ||
$separateinstances = false, | ||
$logsenderrors = true, | ||
){ | ||
include collectd::params | ||
include collectd::plugin::write_graphite | ||
|
||
validate_bool($storerates) | ||
validate_bool($alwaysappendds) | ||
validate_bool($separateinstances) | ||
validate_bool($logsenderrors) | ||
|
||
concat::fragment{"collectd_plugin_write_graphite_conf_${title}": | ||
ensure => $ensure, | ||
order => '50', # somewhere between header and footer | ||
target => $collectd::plugin::write_graphite::graphite_conf, | ||
content => template('collectd/plugin/write_graphite/carbon.conf.erb'), | ||
} | ||
} |
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::write_graphite::carbon', :type => :define do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:id => 'root', | ||
:concat_basedir => tmpfilename('collectd-graphite'), | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
} | ||
end | ||
|
||
context 'protocol should not be include with version < 5.4' do | ||
let(:title) { 'graphite_udp' } | ||
let :facts do | ||
{ :osfamily => 'RedHat', | ||
:collectd_version => '5.3', | ||
} | ||
end | ||
let :params do | ||
{ :protocol => 'udp', | ||
} | ||
end | ||
|
||
it 'Should not include protocol in /etc/collectd.d/write_graphite.conf for collectd < 5.4' do | ||
should_not contain_concat__fragment( | ||
'collectd_plugin_write_graphite_conf_localhost_2003' | ||
).with_content(/.*Protocol \"udp\".*/) | ||
end | ||
end | ||
|
||
context 'protocol should be include with version >= 5.4' do | ||
let(:title) { 'graphite_udp' } | ||
let :facts do | ||
{ :osfamily => 'RedHat', | ||
:collectd_version => '5.4', | ||
} | ||
end | ||
let :params do | ||
{ :protocol => 'udp', | ||
} | ||
end | ||
|
||
it 'Should include protocol in /etc/collectd.d/write_graphite.conf for collectd >= 5.4' do | ||
should contain_concat__fragment( | ||
'collectd_plugin_write_graphite_conf_localhost_2003' | ||
).with_content(/.*Protocol \"udp\".*/) | ||
end | ||
end | ||
|
||
context 'default configuration' do | ||
|
||
it 'includes carbon configuration' do | ||
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({ | ||
:content => /<Carbon>/, | ||
:target => '/etc/collectd/conf.d/write_graphite-config.conf', | ||
}) | ||
|
||
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({ | ||
:content => /Host "localhost"/, | ||
}) | ||
|
||
should contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_tcp').with({ | ||
:content => /Port "2003"/, | ||
}) | ||
end | ||
|
||
end | ||
|
||
end |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
<Carbon> | ||
Host "<%= @graphitehost %>" | ||
Port "<%= @graphiteport %>" | ||
Prefix "<%= @graphiteprefix %>" | ||
<% if @graphitepostfix -%> | ||
Postfix "<%= @graphitepostfix %>" | ||
<% end -%> | ||
EscapeCharacter "<%= @escapecharacter %>" | ||
StoreRates <%= @storerates %> | ||
AlwaysAppendDS <%= @alwaysappendds %> | ||
SeparateInstances <%= @separateinstances %> | ||
<% if @collectd_version and (scope.function_versioncmp([@collectd_version, '5.4']) >= 0) -%> | ||
LogSendErrors <%= @logsenderrors %> | ||
Protocol "<%= @protocol %>" | ||
<% end -%> | ||
</Carbon> |