Skip to content

Commit bec06c0

Browse files
committed
add server parameter on collectd::plugin::network::server
This feature include the possibility to add a specific title on `collectd::plugin::network::server` for the configuration file name. The server should be define with the `server` option.
1 parent 12791f3 commit bec06c0

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

manifests/plugin/network/server.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Optional[String] $interface = undef,
99
Optional[Boolean] $forward = undef,
1010
Optional[Integer[1]] $resolveinterval = undef,
11+
String $server = $name,
1112
) {
1213
include collectd
1314
include collectd::plugin::network

spec/defines/collectd_plugin_network_server_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@
4141
is_expected.to contain_file("#{options[:plugin_conf_dir]}/network-server-node1.conf").with(ensure: 'absent')
4242
end
4343
end
44+
45+
context 'with specifique title' do
46+
let(:title) { 'eatapples' }
47+
let :params do
48+
{ servers: '1.1.1.1' }
49+
it do
50+
is_expected.to contain_file(
51+
"#{options[:plugin_conf_dir]}/network-server-eatapples.conf"
52+
)
53+
end
54+
end
55+
end
4456
end
4557
end
4658
end

templates/plugin/network/server.conf.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Plugin network>
22
<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '4.7']) >= 0) -%>
3-
<Server "<%= @name %>" "<%= @port %>">
3+
<Server "<%= @server %>" "<%= @port %>">
44
<% if @securitylevel -%>
55
SecurityLevel "<%= @securitylevel %>"
66
<% end -%>
@@ -18,7 +18,7 @@
1818
<% end %>
1919
</Server>
2020
<% else -%>
21-
Server "<%= @name %>" "<%= @port %>"
21+
Server "<%= @server %>" "<%= @port %>"
2222
<% end -%>
2323
<% if ! @forward.nil? -%>
2424
Forward <%= @forward %>

0 commit comments

Comments
 (0)