diff --git a/REFERENCE.md b/REFERENCE.md
index 6f1127127..b31bce376 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -8812,6 +8812,7 @@ The collectd::plugin::network::server class.
The following parameters are available in the `collectd::plugin::network::server` defined type:
+* [`hostname`](#-collectd--plugin--network--server--hostname)
* [`ensure`](#-collectd--plugin--network--server--ensure)
* [`username`](#-collectd--plugin--network--server--username)
* [`password`](#-collectd--plugin--network--server--password)
@@ -8821,6 +8822,14 @@ The following parameters are available in the `collectd::plugin::network::server
* [`forward`](#-collectd--plugin--network--server--forward)
* [`resolveinterval`](#-collectd--plugin--network--server--resolveinterval)
+##### `hostname`
+
+Data type: `String[1]`
+
+The hostname of the server to connect to
+
+Default value: `$name`
+
##### `ensure`
Data type: `Enum['present', 'absent']`
diff --git a/manifests/plugin/network/server.pp b/manifests/plugin/network/server.pp
index 8587f63fe..9c9903632 100644
--- a/manifests/plugin/network/server.pp
+++ b/manifests/plugin/network/server.pp
@@ -1,6 +1,8 @@
#
+# @param hostname The hostname of the server to connect to
define collectd::plugin::network::server (
Enum['present', 'absent'] $ensure = 'present',
+ String[1] $hostname = $name,
Optional[String] $username = undef,
Optional[String] $password = undef,
Optional[Stdlib::Port] $port = undef,
diff --git a/spec/defines/collectd_plugin_network_server_spec.rb b/spec/defines/collectd_plugin_network_server_spec.rb
index 0c330ebf9..c6e814e0e 100644
--- a/spec/defines/collectd_plugin_network_server_spec.rb
+++ b/spec/defines/collectd_plugin_network_server_spec.rb
@@ -14,6 +14,7 @@
let(:title) { 'node1' }
let :params do
{
+ hostname: 'node1.example.com',
port: 1234,
interface: 'eth0',
securitylevel: 'Encrypt',
@@ -26,7 +27,7 @@
is_expected.to contain_file("#{options[:plugin_conf_dir]}/network-server-node1.conf").with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/network-server-node1.conf",
- content: "\n \n SecurityLevel \"Encrypt\"\n Username \"foo\"\n Password \"bar\"\n Interface \"eth0\"\n\n \n\n"
+ content: "\n \n SecurityLevel \"Encrypt\"\n Username \"foo\"\n Password \"bar\"\n Interface \"eth0\"\n\n \n\n"
)
end
end
diff --git a/templates/plugin/network/server.conf.erb b/templates/plugin/network/server.conf.erb
index a11137a21..70bd05b16 100644
--- a/templates/plugin/network/server.conf.erb
+++ b/templates/plugin/network/server.conf.erb
@@ -1,6 +1,6 @@
<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '4.7']) >= 0) -%>
- " "<%= @port %>">
+ " "<%= @port %>">
<% if @securitylevel -%>
SecurityLevel "<%= @securitylevel %>"
<% end -%>