bundlewrap/bundles/icinga2/files/icinga_statusmonitor.py
Franziska Kunsmann f52df58517
All checks were successful
bundlewrap/pipeline/head This commit looks good
bundles: code style improvements
2021-02-12 20:45:41 +01:00

30 lines
766 B
Python

#!/usr/bin/env python3
from subprocess import check_output
from flask import Flask
app = Flask(__name__)
@app.route('/status')
def statuspage():
try:
check_output(['/usr/lib/nagios/plugins/check_procs', '-C', 'icinga2', '-c', '1:'])
# check_output will raise an exception if there is a non-zero status
icinga_is_fine = True
except:
icinga_is_fine = False
try:
check_output(['/usr/lib/nagios/plugins/check_procs', '-C', 'postgres', '-c', '1:'])
# check_output will raise an exception if there is a non-zero status
postgres_is_fine = True
except:
postgres_is_fine = False
if icinga_is_fine and postgres_is_fine:
return 'OK', 200
return 'Something is wrong!', 500