From: slivik Date: Wed, 20 Feb 2019 17:27:53 +0000 (+0100) Subject: mgr/zabbix: Adds possibility to send data to multiple zabbix servers. X-Git-Tag: v14.2.8~20^2~52^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d2f25f937ac40e2c579bfbe66a0b001aab175d36;p=ceph.git mgr/zabbix: Adds possibility to send data to multiple zabbix servers. Signed-off-by: Jakub Sliva (cherry picked from commit c02fc4c14870edbee29b71fa3707ab839f31ef77) --- diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index 6b428dc0acca..7a2beff7098e 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -269,30 +269,35 @@ class Module(MgrModule): }) return - try: - self.log.info( - 'Sending data to Zabbix server %s as host/identifier %s', - self.config['zabbix_host'], identifier) - self.log.debug(data) + servers = self.config['zabbix_host'].split(",") + result = True - zabbix = ZabbixSender(self.config['zabbix_sender'], - self.config['zabbix_host'], - self.config['zabbix_port'], self.log) + for server in servers: + zabbix_host, sep, zabbix_port = server.partition(':') + zabbix_port = zabbix_port if sep == ':' else self.config['zabbix_port'] - zabbix.send(identifier, data) - self.set_health_checks(dict()) - return True - except Exception as exc: - self.log.error('Exception when sending: %s', exc) - self.set_health_checks({ - 'MGR_ZABBIX_SEND_FAILED': { - 'severity': 'warning', - 'summary': 'Failed to send data to Zabbix', - 'detail': [str(exc)] - } - }) + self.log.info( + 'Sending data to Zabbix server %s, port %s as host/identifier %s', + zabbix_host, zabbix_port, identifier) + self.log.debug(data) - return False + try: + zabbix = ZabbixSender(self.config['zabbix_sender'], + zabbix_host, + zabbix_port, self.log) + zabbix.send(identifier, data) + except Exception as exc: + self.log.error('Exception when sending: %s', exc) + self.set_health_checks({ + 'MGR_ZABBIX_SEND_FAILED': { + 'severity': 'warning', + 'summary': 'Failed to send data to Zabbix', + 'detail': [str(exc)] + } + }) + + self.set_health_checks(dict()) + return result def handle_command(self, inbuf, command): if command['prefix'] == 'zabbix config-show':