monit: add bundle with base config

This commit is contained in:
Rico 2022-01-04 11:17:00 +01:00
parent ee7d8b491b
commit edb49b9a09
Signed by: stillbeben
GPG Key ID: AE1066B5BD0B5041
3 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,45 @@
set daemon 30
with start delay 30
set log syslog
set mailserver localhost
set mail-format { from: ${monit['from_address']} }
% for alert_address in monit['alert_addresses']:
set alert ${alert_address}
% endfor
set httpd unixsocket /var/run/monit.sock
use address 127.0.0.1
allow 127.0.0.1
check system $HOST
if cpu usage > 95% for 10 cycles then alert
if memory usage > 80% then alert
if swap usage > 25% then alert
check filesystem rootfs with path /
if space usage > 80% for 5 times within 15 cycles then alert
if space usage > 90% then alert
if inode usage > 90% then alert
check process cron matching "/usr/sbin/cron"
start program = "/usr/bin/systemctl start cron.service"
stop program = "/usr/bin/systemctl stop cron.service"
% for systemd_service in ('systemd-timesyncd', 'systemd-networkd', 'systemd-journald'):
check process ${systemd_service} matching "/lib/systemd/${systemd_service}"
start program = "/usr/bin/systemctl start ${systemd_service}.service"
stop program = "/usr/bin/systemctl stop ${systemd_service}.service"
% endfor
check process sshd matching "/usr/sbin/sshd"
start program = "/bin/systemctl start sshd.service"
stop program = "/bin/systemctl stop sshd.service"
if failed port 22 for 2 cycles then restart
if 3 restarts within 5 cycles then alert
check process postfix matching "/usr/lib/postfix/sbin/master"
start program = "/bin/systemctl start postfix.service"
stop program = "/bin/systemctl stop postfix.service"
if failed port 25 protocol smtp for 5 cycles then restart

38
bundles/monit/items.py Normal file
View File

@ -0,0 +1,38 @@
svc_systemd = {
'monit': {
'needs': [
'pkg_apt:monit',
],
},
}
files = {
'/etc/monit/monitrc': {
'mode': '0400',
'content_type': 'mako',
'needs': [
'pkg_apt:monit',
],
'triggers': [
'svc_systemd:monit:restart',
],
'context': {
'monit': node.metadata['monit'],
},
},
}
directories = {
'/etc/monit/conf-enabled': {
'purge': True,
},
'/etc/monit/conf-available': {
'purge': True,
},
'/etc/monit/conf.d': {
'purge': True,
},
'/etc/monit/templates': {
'purge': True,
},
}

View File

@ -0,0 +1,7 @@
defaults = {
'apt': {
'packages': {
'monit': {},
},
},
}