bundlewrap/bundles/c3voc-addons/metadata.py

67 lines
1.9 KiB
Python
Raw Normal View History

defaults = {
'icinga2_api': {
'apt': {
'services': {
'UNATTENDED UPGRADES': {
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_unattended_upgrades',
},
},
},
'nginx': {
'services': {
'NGINX PROCESS': {
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit nginx',
},
},
},
},
}
@metadata_reactor.provides(
'cron/upgrade-and-reboot'
)
def patchday(metadata):
day = metadata.get('apt/unattended_upgrades/day', 5)
return {
'cron': {
'upgrade-and-reboot': '{minute} 1 * * {day} root /usr/local/sbin/upgrade-and-reboot'.format(
minute=node.magic_number % 30,
day=day,
),
},
}
@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']),
}
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,
},
},
}