diff options
3 files changed, 17 insertions, 1 deletions
diff --git a/data/templates/zabbix-agent/zabbix-agent.conf.j2 b/data/templates/zabbix-agent/zabbix-agent.conf.j2 index 77f57f32f..e6dcef872 100644 --- a/data/templates/zabbix-agent/zabbix-agent.conf.j2 +++ b/data/templates/zabbix-agent/zabbix-agent.conf.j2 @@ -1,4 +1,4 @@ -# Generated by ${vyos_conf_scripts_dir}/service_zabbix_agent.py +# Generated by ${vyos_conf_scripts_dir}/service_monitoring_zabbix-agent.py PidFile=/run/zabbix/zabbix_agent2.pid LogFile=/var/log/zabbix/zabbix_agent2.log @@ -45,6 +45,10 @@ Server={{ server | bracketize_ipv6 | join(',') }} ServerActive={{ servers | join(',') }} {% endif %} +{% if host_name is vyos_defined %} +Hostname={{ host_name }} +{% endif %} + {% if port is vyos_defined %} ListenPort={{ port }} {% endif %} diff --git a/interface-definitions/service-monitoring-zabbix-agent.xml.in b/interface-definitions/service-monitoring-zabbix-agent.xml.in index cfeb02ce0..40f2df642 100644 --- a/interface-definitions/service-monitoring-zabbix-agent.xml.in +++ b/interface-definitions/service-monitoring-zabbix-agent.xml.in @@ -17,6 +17,15 @@ </constraint> </properties> </leafNode> + <leafNode name="host-name"> + <properties> + <help>Zabbix agent hostname</help> + <constraint> + #include <include/constraint/host-name.xml.i> + </constraint> + <constraintErrorMessage>Host-name must be alphanumeric and can contain hyphens</constraintErrorMessage> + </properties> + </leafNode> <node name="limits"> <properties> <help>Limit settings</help> diff --git a/smoketest/scripts/cli/test_service_monitoring_zabbix-agent.py b/smoketest/scripts/cli/test_service_monitoring_zabbix-agent.py index 7cc661688..cb5f84406 100755 --- a/smoketest/scripts/cli/test_service_monitoring_zabbix-agent.py +++ b/smoketest/scripts/cli/test_service_monitoring_zabbix-agent.py @@ -50,6 +50,7 @@ class TestZabbixAgent(VyOSUnitTestSHIM.TestCase): port = '10050' timeout = '5' listen_ip = '0.0.0.0' + hostname = 'r-vyos' self.cli_set(base_path + ['directory', directory]) self.cli_set(base_path + ['limits', 'buffer-flush-interval', buffer_send]) @@ -61,6 +62,7 @@ class TestZabbixAgent(VyOSUnitTestSHIM.TestCase): for server_active, server_config in servers_active.items(): self.cli_set(base_path + ['server-active', server_active, 'port', server_config['port']]) self.cli_set(base_path + ['timeout', timeout]) + self.cli_set(base_path + ['host-name', hostname]) # commit changes self.cli_commit() @@ -80,6 +82,7 @@ class TestZabbixAgent(VyOSUnitTestSHIM.TestCase): self.assertIn(f'BufferSize={buffer_size}', config) self.assertIn(f'Include={directory}/*.conf', config) self.assertIn(f'Timeout={timeout}', config) + self.assertIn(f'Hostname={hostname}', config) if __name__ == '__main__': |