bundles/icinga2: add icinga statusmonitor
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2020-11-22 18:53:57 +01:00
parent 12ce8d8f6e
commit dc9e378908
Signed by: kunsi
GPG key ID: 12E3D2136B818350
6 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,29 @@
#!/usr/bin/env python3
from flask import Flask, Response
from subprocess import check_output
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
else:
return 'Something is wrong!', 500

View file

@ -0,0 +1,15 @@
[Unit]
Description=Icinga2 Statusmonitor
After=network.target
[Service]
User=nagios
Group=nagios
Environment="FLASK_APP=/etc/icinga2/icinga_statusmonitor.py"
ExecStart=/usr/bin/python3 -m flask run
WorkingDirectory=/tmp
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target