bundlewrap/bundles/icinga2/files/icinga_statusmonitor.py

31 lines
680 B
Python
Raw Normal View History

#!/usr/bin/env python3
from subprocess import check_output
2021-02-12 19:37:36 +00:00
from flask import Flask
app = Flask(__name__)
@app.route('/status')
def statuspage():
everything_fine = True
try:
check_output(['/usr/local/share/icinga/plugins/check_mounts'])
except:
everything_fine = False
try:
check_output(['/usr/lib/nagios/plugins/check_procs', '-C', 'icinga2', '-c', '1:'])
except:
everything_fine = False
try:
check_output(['/usr/lib/nagios/plugins/check_procs', '-C', 'postgres', '-c', '1:'])
except:
everything_fine = False
if everything_fine:
return 'OK', 200
2021-02-12 19:37:36 +00:00
return 'Something is wrong!', 500