]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/zabbix: Adds possibility to send data to multiple zabbix servers.
authorslivik <jakub.sliva@gmail.com>
Wed, 20 Feb 2019 17:27:53 +0000 (18:27 +0100)
committerNathan Cutler <ncutler@suse.com>
Thu, 29 Aug 2019 13:45:52 +0000 (15:45 +0200)
Signed-off-by: Jakub Sliva <jakub.sliva@gmail.com>
(cherry picked from commit c02fc4c14870edbee29b71fa3707ab839f31ef77)

src/pybind/mgr/zabbix/module.py

index 6b428dc0acca57016f2b06b51ac1aea22ab0b241..7a2beff7098e91ae92fee15683f04539562b309c 100644 (file)
@@ -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':