Skip to content

Commit

Permalink
mgr/zabbix: Implement health checks in Zabbix module
Browse files Browse the repository at this point in the history
Should make it easier for users to see why the module is failing.

Signed-off-by: Wido den Hollander <[email protected]>
  • Loading branch information
wido committed Feb 9, 2018
1 parent 01d350f commit b7d0cab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions qa/suites/rados/mgr/tasks/module_selftest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions src/pybind/mgr/zabbix/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def send(self, hostname, data):
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():
Expand Down Expand Up @@ -218,6 +220,13 @@ def send(self):
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:
Expand All @@ -231,9 +240,17 @@ def send(self):
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

Expand Down

0 comments on commit b7d0cab

Please sign in to comment.