Merge "Support systemd nrpe check for ceph-osd@N units"

This commit is contained in:
Zuul 2018-12-04 14:56:43 +00:00 committed by Gerrit Code Review
commit 4dea0d6f29
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,
@ -634,12 +635,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()