From: Wido den Hollander Date: Wed, 31 Jan 2018 09:04:13 +0000 (+0100) Subject: mgr/zabbix: Implement health checks in Zabbix module X-Git-Tag: v13.0.2~292^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b7d0cab99e8be9d75cea258fdb72a9e2d8ecee75;p=ceph.git 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 --- diff --git a/qa/suites/rados/mgr/tasks/module_selftest.yaml b/qa/suites/rados/mgr/tasks/module_selftest.yaml index 6c7ce49a6814..9e2861feb23f 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 bd0ee1845e79..84631cdc67b8 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