Fix NRPE check_osd

Move the result of the systemd service state to `/var/lib/nagios`

Change-Id: I83287590e279054973fdb28b374a49704626ed01
Closes-Bug: 1826594
This commit is contained in:
Nicolas Pochet 2019-04-26 20:15:36 +02:00
parent 6c7fdc3f50
commit 3b2e79a563
No known key found for this signature in database
GPG Key ID: 9F974591C74635C7
2 changed files with 4 additions and 4 deletions

View File

@ -6,9 +6,9 @@
import os
import sys
import tempfile
CRON_CHECK_TMPFILE = 'ceph-osd-checks'
NAGIOS_HOME = '/var/lib/nagios'
STATE_OK = 0
STATE_WARNING = 1
@ -25,7 +25,7 @@ def run_main():
:returns: nagios state 0,2 or 3
"""
_tmp_file = os.path.join(tempfile.gettempdir(), CRON_CHECK_TMPFILE)
_tmp_file = os.path.join(NAGIOS_HOME, CRON_CHECK_TMPFILE)
if not os.path.isfile(_tmp_file):
print("File '{}' doesn't exist".format(_tmp_file))

View File

@ -6,7 +6,6 @@
import os
import subprocess
import tempfile
# fasteners only exists in Bionic, so this will fail on xenial and trusty
try:
@ -17,6 +16,7 @@ except ImportError:
SYSTEMD_SYSTEM = '/run/systemd/system'
LOCKFILE = '/var/lock/check-osds.lock'
CRON_CHECK_TMPFILE = 'ceph-osd-checks'
NAGIOS_HOME = '/var/lib/nagios'
def init_is_systemd():
@ -67,7 +67,7 @@ def do_status():
.format(e.output.decode('utf-8')))
lines.append(output)
_tmp_file = os.path.join(tempfile.gettempdir(), CRON_CHECK_TMPFILE)
_tmp_file = os.path.join(NAGIOS_HOME, CRON_CHECK_TMPFILE)
with open(_tmp_file, 'wt') as f:
f.writelines(lines)