Initial git commit
commit
4b760a5a39
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# Nagios plugin to check the system state according to systemd.
|
||||||
|
#
|
||||||
|
# This plugin checks the system's state according to systemd, i.e.
|
||||||
|
#
|
||||||
|
# $ systemctl is-system-running
|
||||||
|
# degraded
|
||||||
|
#
|
||||||
|
# If it reports anything other than "running", be sure to check the output of
|
||||||
|
# these commands:
|
||||||
|
#
|
||||||
|
# $ systemctl list-units
|
||||||
|
# $ systemctl status
|
||||||
|
#
|
||||||
|
# License: Public Domain. Keep my name in it if you like.
|
||||||
|
# Author: Mike Gerber 2015
|
||||||
|
|
||||||
|
from __future__ import division, print_function
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
state = subprocess.check_output(['systemctl', 'is-system-running'])
|
||||||
|
state = state.strip()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
state = e.output.strip()
|
||||||
|
print('System NOT OK: {}'.format(state))
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
if state == 'running':
|
||||||
|
print('System OK: {}'.format(state))
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
print('System NOT OK: {}'.format(state))
|
||||||
|
sys.exit(0)
|
Loading…
Reference in New Issue