bundles/icinga2: add icinga statusmonitor
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
12ce8d8f6e
commit
dc9e378908
6 changed files with 81 additions and 0 deletions
29
bundles/icinga2/files/icinga_statusmonitor.py
Normal file
29
bundles/icinga2/files/icinga_statusmonitor.py
Normal 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
|
15
bundles/icinga2/files/icinga_statusmonitor.service
Normal file
15
bundles/icinga2/files/icinga_statusmonitor.service
Normal 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
|
|
@ -218,6 +218,19 @@ files = {
|
||||||
'mode': '0660',
|
'mode': '0660',
|
||||||
'group': 'icingaweb2',
|
'group': 'icingaweb2',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
# Statusmonitor
|
||||||
|
'/etc/icinga2/icinga_statusmonitor.py': {
|
||||||
|
'triggers': {
|
||||||
|
'svc_systemd:icinga_statusmonitor:restart',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'/etc/systemd/system/icinga_statusmonitor.service': {
|
||||||
|
'triggers': {
|
||||||
|
'action:systemd-reload',
|
||||||
|
'svc_systemd:icinga_statusmonitor:restart',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
actions = {
|
actions = {
|
||||||
|
@ -253,6 +266,13 @@ svc_systemd = {
|
||||||
'symlink:',
|
'symlink:',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'icinga_statusmonitor': {
|
||||||
|
'needs': {
|
||||||
|
'file:/etc/icinga2/icinga_statusmonitor.py',
|
||||||
|
'file:/etc/systemd/system/icinga_statusmonitor.service',
|
||||||
|
'pkg_apt:python3-flask',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ defaults = {
|
||||||
'libmonitoring-plugin-perl': {},
|
'libmonitoring-plugin-perl': {},
|
||||||
'libnet-dns-perl': {},
|
'libnet-dns-perl': {},
|
||||||
'libreadonly-perl': {},
|
'libreadonly-perl': {},
|
||||||
|
|
||||||
|
# neeeded for statusmonitor
|
||||||
|
'python3-flask': {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'icinga2': {
|
'icinga2': {
|
||||||
|
@ -38,6 +41,9 @@ defaults = {
|
||||||
'check_interval': '30m',
|
'check_interval': '30m',
|
||||||
'vars.notification.mail': True,
|
'vars.notification.mail': True,
|
||||||
},
|
},
|
||||||
|
'ICINGA STATUSMONITOR': {
|
||||||
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit icinga_statusmonitor',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,6 +16,9 @@ git IN AAAA 2a01:4f8:10b:2a5f::2
|
||||||
icinga IN A 51.195.44.8
|
icinga IN A 51.195.44.8
|
||||||
icinga IN AAAA 2001:41d0:701:1100::2618
|
icinga IN AAAA 2001:41d0:701:1100::2618
|
||||||
|
|
||||||
|
statusmonitor.icinga IN A 51.195.44.8
|
||||||
|
statusmonitor.icinga IN AAAA 2001:41d0:701:1100::2618
|
||||||
|
|
||||||
jenkins IN A 94.130.52.224
|
jenkins IN A 94.130.52.224
|
||||||
jenkins IN AAAA 2a01:4f8:10b:2a5f::2
|
jenkins IN AAAA 2a01:4f8:10b:2a5f::2
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,14 @@ nodes['ovh.icinga2'] = {
|
||||||
'webroot': '/usr/share/icingaweb2/public',
|
'webroot': '/usr/share/icingaweb2/public',
|
||||||
'extras': True,
|
'extras': True,
|
||||||
},
|
},
|
||||||
|
'icinga_statusmonitor': {
|
||||||
|
'domain': 'statusmonitor.icinga.kunsmann.eu',
|
||||||
|
'proxy': {
|
||||||
|
'/': {
|
||||||
|
'target': 'http://127.0.0.1:5000/',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'php': {
|
'php': {
|
||||||
|
|
Loading…
Reference in a new issue