From b7d0cab99e8be9d75cea258fdb72a9e2d8ecee75 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 31 Jan 2018 10:04:13 +0100 Subject: [PATCH] mgr/zabbix: Implement health checks in Zabbix module Should make it easier for users to see why the module is failing. Signed-off-by: Wido den Hollander --- qa/suites/rados/mgr/tasks/module_selftest.yaml | 1 + src/pybind/mgr/zabbix/module.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/qa/suites/rados/mgr/tasks/module_selftest.yaml b/qa/suites/rados/mgr/tasks/module_selftest.yaml index 6c7ce49a68149..9e2861feb23fe 100644 --- a/qa/suites/rados/mgr/tasks/module_selftest.yaml +++ b/qa/suites/rados/mgr/tasks/module_selftest.yaml @@ -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 diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index bd0ee1845e793..84631cdc67b82 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -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 ') + 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 -- 2.39.5