From 661fa646915907c0f909b8e79c51fbb2f455007b Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Wed, 23 Aug 2023 09:32:43 +0000 Subject: T5448: Add configuration host-name for zabbix-agent Ability to configure host-name for zabbix-agent set service monitoring zabbix-agent host-name 'r-vyos' --- data/templates/zabbix-agent/zabbix-agent.conf.j2 | 6 +++++- interface-definitions/service-monitoring-zabbix-agent.xml.in | 9 +++++++++ smoketest/scripts/cli/test_service_monitoring_zabbix-agent.py | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) 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 @@ + + + Zabbix agent hostname + + #include + + Host-name must be alphanumeric and can contain hyphens + + Limit settings 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__': -- cgit v1.2.3