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 <alvaro.uria@canonical.com>
This commit is contained in:
Alvaro Uria 2018-08-09 13:22:49 +02:00
parent 17c64df681
commit 11e1dfc565
1 changed files with 12 additions and 2 deletions

View File

@ -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()