Skip to content

Commit

Permalink
Merge pull request #944 from paramite/write_http
Browse files Browse the repository at this point in the history
Add support for Header and Metrics configuration for write_http plugin
  • Loading branch information
ghoneycutt authored May 28, 2020
2 parents d73d5f4 + a418545 commit 5d466cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/classes/collectd_plugin_write_http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@
end
end

context ':ensure => present and :nodes => { \'collectd\' => { \'url\' => \'collectd.org.1\', \'metrics\' => \'true\', \'header\' => \'foobar\'}}' do
let :params do
{
nodes:
{
'collectd' =>
{
'url' => 'collectd.org.1',
'metrics' => true,
'header' => 'foobar'
}
}
}
end

it 'Will create 10-write_http.conf' do
is_expected.to contain_file('write_http.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-write_http.conf",
content: "#\ Generated by Puppet\n<LoadPlugin write_http>\n Globals false\n</LoadPlugin>\n\n<Plugin \"write_http\">\n <Node \"collectd\">\n URL \"collectd.org.1\"\n\n Header \"foobar\"\n Metrics true\n </Node>\n\n</Plugin>\n\n"
)
end
end

context ':ensure => absent' do
let :params do
{ ensure: 'absent' }
Expand Down
6 changes: 6 additions & 0 deletions templates/plugin/write_http.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
<% if $values['storerates'] { -%>
StoreRates <%= $values['storerates'] %>
<% } -%>
<% if $values['header'] { -%>
Header "<%= $values['header'] %>"
<% } -%>
<% if $values['metrics'] { -%>
Metrics <%= $values['metrics'] %>
<% } -%>
<% if $values['url'] { -%>
</Node>
<% } else { -%>
Expand Down

0 comments on commit 5d466cf

Please sign in to comment.