Check for the existence of /usr/bin/systemctl first
This commit is contained in:
parent
2517607b25
commit
65e7c46b6e
1 changed files with 8 additions and 1 deletions
|
@ -2,11 +2,18 @@
|
|||
# Nagios plugin to check the system state according to systemd.
|
||||
|
||||
from __future__ import division, print_function
|
||||
import posixpath
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
systemctl = '/usr/bin/systemctl'
|
||||
|
||||
if not posixpath.exists(systemctl):
|
||||
print('System WARN: systemctl not found')
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
state = subprocess.check_output(['systemctl', 'is-system-running'])
|
||||
state = subprocess.check_output([systemctl, 'is-system-running'])
|
||||
state = state.strip()
|
||||
except subprocess.CalledProcessError as e:
|
||||
state = e.output.strip()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue