Skip to content

Commit 8fa5ab6

Browse files
authored
Merge pull request #1014 from gerases/modify-write-graphite-plugin
Add write_graphite options introduced in collectd 5.7.0
2 parents d70e4b6 + 87e9c02 commit 8fa5ab6

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,17 +2000,22 @@ backend should have unique title:
20002000

20012001
```puppet
20022002
collectd::plugin::write_graphite::carbon {'secondary_graphite':
2003-
graphitehost => 'graphite.example.org',
2004-
graphiteport => 2004,
2005-
graphiteprefix => '',
2006-
protocol => 'udp',
2007-
escapecharacter => '_',
2008-
alwaysappendds => true,
2009-
storerates => true,
2010-
separateinstances => false,
2011-
logsenderrors => true
2012-
}
2013-
```
2003+
graphitehost => 'graphite.example.org',
2004+
graphiteport => 2004,
2005+
graphiteprefix => '',
2006+
protocol => 'udp',
2007+
escapecharacter => '_',
2008+
alwaysappendds => true,
2009+
storerates => true,
2010+
separateinstances => false,
2011+
logsenderrors => true
2012+
preserveseparator => false,
2013+
dropduplicatefields => false,
2014+
}
2015+
```
2016+
2017+
The `preserveseparator` and `dropduplicatefields` fields are supported as of
2018+
collectd version >= 5.7.
20142019

20152020
#### Class: `collectd::plugin::write_http`
20162021

manifests/plugin/write_graphite/carbon.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
Boolean $logsenderrors = true,
1515
Integer $reconnectinterval = 0,
1616
Boolean $reversehost = false,
17+
Boolean $preserveseparator = false,
18+
Boolean $dropduplicatefields = false,
1719
) {
1820
include collectd
1921
include collectd::plugin::write_graphite

spec/defines/collectd_plugin_write_graphite_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,34 @@
6969
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{Port "2003"}) }
7070
end
7171
end
72+
73+
context 'starting with version 5.7 the preserveseparator and dropduplicatefields options should be supported' do
74+
let(:title) { 'graphite_default' }
75+
76+
let :params do
77+
{
78+
preserveseparator: true,
79+
dropduplicatefields: true,
80+
}
81+
end
82+
83+
context 'version 5.6' do
84+
let :facts do
85+
facts.merge(collectd_version: '5.6')
86+
end
87+
88+
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').without(content: %r{PreserveSeparator}) }
89+
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').without(content: %r{DropDuplicateFields}) }
90+
end
91+
92+
context 'version 5.7' do
93+
let :facts do
94+
facts.merge(collectd_version: '5.7')
95+
end
96+
97+
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{PreserveSeparator true}) }
98+
it { is_expected.to contain_concat__fragment('collectd_plugin_write_graphite_conf_graphite_default_tcp_2003').with(content: %r{DropDuplicateFields true}) }
99+
end
100+
end
72101
end
73102
end

templates/plugin/write_graphite/carbon.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<%- if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.9']) >= 0) -%>
2424
ReverseHost <%= @reversehost %>
2525
<%- end -%>
26+
<%- if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.7']) >= 0) -%>
27+
PreserveSeparator <%= @preserveseparator %>
28+
DropDuplicateFields <%= @dropduplicatefields %>
29+
<%- end -%>
2630
<%- if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '5.3']) >= 0) -%>
2731
</Node>
2832
<%- else -%>

0 commit comments

Comments
 (0)