Skip to content

Commit

Permalink
Merge pull request #1014 from gerases/modify-write-graphite-plugin
Browse files Browse the repository at this point in the history
Add write_graphite options introduced in collectd 5.7.0
  • Loading branch information
smortex authored Feb 6, 2023
2 parents d70e4b6 + 87e9c02 commit 8fa5ab6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2000,17 +2000,22 @@ backend should have unique title:

```puppet
collectd::plugin::write_graphite::carbon {'secondary_graphite':
graphitehost => 'graphite.example.org',
graphiteport => 2004,
graphiteprefix => '',
protocol => 'udp',
escapecharacter => '_',
alwaysappendds => true,
storerates => true,
separateinstances => false,
logsenderrors => true
}
```
graphitehost => 'graphite.example.org',
graphiteport => 2004,
graphiteprefix => '',
protocol => 'udp',
escapecharacter => '_',
alwaysappendds => true,
storerates => true,
separateinstances => false,
logsenderrors => true
preserveseparator => false,
dropduplicatefields => false,
}
```

The `preserveseparator` and `dropduplicatefields` fields are supported as of
collectd version >= 5.7.

#### Class: `collectd::plugin::write_http`

Expand Down
2 changes: 2 additions & 0 deletions manifests/plugin/write_graphite/carbon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Boolean $logsenderrors = true,
Integer $reconnectinterval = 0,
Boolean $reversehost = false,
Boolean $preserveseparator = false,
Boolean $dropduplicatefields = false,
) {
include collectd
include collectd::plugin::write_graphite
Expand Down
29 changes: 29 additions & 0 deletions spec/defines/collectd_plugin_write_graphite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,34 @@
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{Port "2003"}) }
end
end

context 'starting with version 5.7 the preserveseparator and dropduplicatefields options should be supported' do
let(:title) { 'graphite_default' }

let :params do
{
preserveseparator: true,
dropduplicatefields: true,
}
end

context 'version 5.6' do
let :facts do
facts.merge(collectd_version: '5.6')
end

it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').without(content: %r{PreserveSeparator}) }
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').without(content: %r{DropDuplicateFields}) }
end

context 'version 5.7' do
let :facts do
facts.merge(collectd_version: '5.7')
end

it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{PreserveSeparator true}) }
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{DropDuplicateFields true}) }
end
end
end
end
4 changes: 4 additions & 0 deletions templates/plugin/write_graphite/carbon.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<%- if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.9']) >= 0) -%>
ReverseHost <%= @reversehost %>
<%- end -%>
<%- if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.7']) >= 0) -%>
PreserveSeparator <%= @preserveseparator %>
DropDuplicateFields <%= @dropduplicatefields %>
<%- end -%>
<%- if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.3']) >= 0) -%>
</Node>
<%- else -%>
Expand Down

0 comments on commit 8fa5ab6

Please sign in to comment.