]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/zabbix: Implement health checks in Zabbix module 20198/head
authorWido den Hollander <wido@42on.com>
Wed, 31 Jan 2018 09:04:13 +0000 (10:04 +0100)
committerWido den Hollander <wido@42on.com>
Fri, 9 Feb 2018 08:57:41 +0000 (09:57 +0100)
Should make it easier for users to see why the module is failing.

Signed-off-by: Wido den Hollander <wido@42on.com>
qa/suites/rados/mgr/tasks/module_selftest.yaml
src/pybind/mgr/zabbix/module.py

index 6c7ce49a6814985b7083ef7ad08172e662043ca1..9e2861feb23feff3b37956df98af19d0d8ee28e7 100644 (file)
@@ -16,6 +16,7 @@ tasks:
         - objects misplaced
         - Synthetic exception in serve
         - influxdb python module not found
+        - \(MGR_ZABBIX_
   - cephfs_test_runner:
       modules:
         - tasks.mgr.test_module_selftest
index bd0ee1845e793d76ef7d973207e4a529ea147c62..84631cdc67b82544e744d127750bce98add34847 100644 (file)
@@ -32,6 +32,8 @@ class ZabbixSender(object):
         cmd = [self.sender, '-z', self.host, '-p', str(self.port), '-s',
                hostname, '-vv', '-i', '-']
 
+        self.log.debug('Executing: %s', cmd)
+
         proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
 
         for key, value in data.items():
@@ -218,6 +220,13 @@ class Module(MgrModule):
         if not self.config['zabbix_host']:
             self.log.error('Zabbix server not set, please configure using: '
                            'ceph zabbix config-set zabbix_host <zabbix_host>')
+            self.set_health_checks({
+                'MGR_ZABBIX_NO_SERVER': {
+                    'severity': 'warning',
+                    'summary': 'No Zabbix server not configured',
+                    'detail': ['Configuration value zabbix_host not configured']
+                }
+            })
             return
 
         try:
@@ -231,9 +240,17 @@ class Module(MgrModule):
                                   self.config['zabbix_port'], self.log)
 
             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)]
+                }
+            })
 
         return False