From 11e1dfc5656b2cd495d2f53049bf8c58aedb9614 Mon Sep 17 00:00:00 2001 From: Alvaro Uria Date: Thu, 9 Aug 2018 13:22:49 +0200 Subject: [PATCH] Support systemd nrpe check for ceph-osd@N units ceph-osd<->nrpe relation adds a single check that parses the service status of all the ceph-osd processes. The check supported sysv and upstart environments, but not systemd, which has been added. add_init_service_checks does support systemd but it would create a nrpe check per OSD (vs a single check for all OSDs) Change-Id: I34fc01365de6994c93a273f01a1e2278016d21ef Closes-Bug: 1804247 Signed-off-by: Alvaro Uria --- hooks/ceph_hooks.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index d1b82d42..11ed35ff 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -56,6 +56,7 @@ from charmhelpers.core.host import ( restart_on_change, write_file, is_container, + init_is_systemd, ) from charmhelpers.fetch import ( add_source, @@ -636,12 +637,21 @@ def update_nrpe_config(): apt_install('python3-dbus') hostname = nrpe.get_nagios_hostname() current_unit = nrpe.get_nagios_unit_name() + + # create systemd or upstart check + cmd = '/bin/cat /var/lib/ceph/osd/ceph-*/whoami |' + if init_is_systemd(): + cmd += 'xargs -I_@ /usr/local/lib/nagios/plugins/check_systemd.py' + cmd += ' ceph-osd@_@' + else: + cmd += 'xargs -I@ status ceph-osd id=@' + cmd += ' && exit 0 || exit 2' + nrpe_setup = nrpe.NRPE(hostname=hostname) nrpe_setup.add_check( shortname='ceph-osd', description='process check {%s}' % current_unit, - check_cmd=('/bin/cat /var/lib/ceph/osd/ceph-*/whoami |' - 'xargs -I@ status ceph-osd id=@ && exit 0 || exit 2') + check_cmd=cmd ) nrpe_setup.write()