From 6c0a3c75a661db452f9c5b80375434e83d7a52c7 Mon Sep 17 00:00:00 2001 From: Sergei Gerasenko Date: Sun, 29 Jan 2023 23:33:15 +0000 Subject: [PATCH 1/4] Add write_graphite options introduced in collectd 5.7.0 --- manifests/plugin/write_graphite/carbon.pp | 2 ++ templates/plugin/write_graphite/carbon.conf.erb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/manifests/plugin/write_graphite/carbon.pp b/manifests/plugin/write_graphite/carbon.pp index c6979cf3..49b337f0 100644 --- a/manifests/plugin/write_graphite/carbon.pp +++ b/manifests/plugin/write_graphite/carbon.pp @@ -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 diff --git a/templates/plugin/write_graphite/carbon.conf.erb b/templates/plugin/write_graphite/carbon.conf.erb index 87fbfa56..cbdac032 100644 --- a/templates/plugin/write_graphite/carbon.conf.erb +++ b/templates/plugin/write_graphite/carbon.conf.erb @@ -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) -%> <%- else -%> From 0ea0410f2129783df27f3b503c003adc88336462 Mon Sep 17 00:00:00 2001 From: Sergei Gerasenko Date: Sun, 29 Jan 2023 23:50:52 +0000 Subject: [PATCH 2/4] Adjust spec tests --- .../collectd_plugin_write_graphite_spec.rb | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/defines/collectd_plugin_write_graphite_spec.rb b/spec/defines/collectd_plugin_write_graphite_spec.rb index 8ecf7b42..ce947aa2 100644 --- a/spec/defines/collectd_plugin_write_graphite_spec.rb +++ b/spec/defines/collectd_plugin_write_graphite_spec.rb @@ -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 From 560e30cfb95ab0b828431498d427f25e9b99ae05 Mon Sep 17 00:00:00 2001 From: Sergei Gerasenko Date: Mon, 30 Jan 2023 16:29:54 +0000 Subject: [PATCH 3/4] Add documentation --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index fe358b4c..8f7273a4 100644 --- a/README.md +++ b/README.md @@ -2009,9 +2009,14 @@ collectd::plugin::write_graphite::carbon {'secondary_graphite': 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` The write_http plugin supports two ways of configuration, the old plugin format using urls: From 87e9c021135c5bf91b4e6cf437920caff806d9e9 Mon Sep 17 00:00:00 2001 From: Sergei Gerasenko Date: Mon, 30 Jan 2023 16:30:37 +0000 Subject: [PATCH 4/4] Fix whitespace in the documentation --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8f7273a4..fd4b3b47 100644 --- a/README.md +++ b/README.md @@ -2000,15 +2000,15 @@ 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, }