2021-01-17 07:07:21 +00:00
|
|
|
defaults = {
|
2021-05-13 07:10:33 +00:00
|
|
|
'apt': {
|
2022-01-23 04:47:42 +00:00
|
|
|
'unattended-upgrades': {
|
2021-05-13 07:10:33 +00:00
|
|
|
'day': 5,
|
|
|
|
'hour': 21,
|
|
|
|
},
|
|
|
|
},
|
2021-01-17 07:07:21 +00:00
|
|
|
'icinga2_api': {
|
2021-01-17 17:43:30 +00:00
|
|
|
'apt': {
|
|
|
|
'services': {
|
|
|
|
'UNATTENDED UPGRADES': {
|
|
|
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_unattended_upgrades',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-01-17 07:07:21 +00:00
|
|
|
'nginx': {
|
|
|
|
'services': {
|
|
|
|
'NGINX PROCESS': {
|
|
|
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit nginx',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-19 12:34:23 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'cron/upgrade-and-reboot'
|
|
|
|
)
|
|
|
|
def patchday(metadata):
|
2022-01-23 04:47:42 +00:00
|
|
|
day = metadata.get('apt/unattended-upgrades/day')
|
|
|
|
hour = metadata.get('apt/unattended-upgrades/hour')
|
2021-01-19 12:34:23 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
'cron': {
|
2021-02-12 17:53:25 +00:00
|
|
|
'upgrade-and-reboot': '{minute} {hour} * * {day} root /usr/local/sbin/upgrade-and-reboot'.format(
|
2021-01-19 12:34:23 +00:00
|
|
|
minute=node.magic_number % 30,
|
2021-02-12 17:53:25 +00:00
|
|
|
hour=hour,
|
2021-01-19 12:34:23 +00:00
|
|
|
day=day,
|
|
|
|
),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-17 07:07:21 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'icinga2_api/nginx/services',
|
|
|
|
)
|
|
|
|
def monitoring(metadata):
|
|
|
|
services = {}
|
|
|
|
|
|
|
|
for vname, vconfig in metadata.get('nginx/vhosts', {}).items():
|
|
|
|
domain = vconfig.get('domain', vname)
|
|
|
|
|
|
|
|
if 'website_check_path' in vconfig and 'website_check_string' in vconfig:
|
|
|
|
services['NGINX VHOST {} CONTENT'.format(vname)] = {
|
|
|
|
'check_command': 'check_http_wget',
|
|
|
|
'vars.http_wget_contains': vconfig['website_check_string'],
|
|
|
|
'vars.http_wget_url': 'https://{}{}'.format(domain, vconfig['website_check_path']),
|
2021-04-10 13:04:34 +00:00
|
|
|
'vars.notification.sms': True,
|
2021-01-17 07:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if vconfig.get('check_ssl', True):
|
|
|
|
services['NGINX VHOST {} CERTIFICATE'.format(vname)] = {
|
|
|
|
'check_command': 'check_https_cert_at_url',
|
|
|
|
'vars.domain': domain,
|
|
|
|
'vars.notification.mail': True,
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'icinga2_api': {
|
|
|
|
'nginx': {
|
|
|
|
'services': services,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|