bundles/wireguard: health checks for everyone

This commit is contained in:
Franzi 2023-09-11 09:09:09 +02:00
parent 15eaa94397
commit 4f260932c3
Signed by: kunsi
GPG key ID: 12E3D2136B818350
5 changed files with 45 additions and 22 deletions

View file

@ -244,3 +244,37 @@ def snat(metadata):
},
},
}
@metadata_reactor.provides(
'wireguard/health_checks',
'systemd-timers/timers/wg-health-check',
)
def health_checks(metadata):
checks = {}
for peer, config in metadata.get('wireguard/peers', {}).items():
if (
config.get('exclude_from_monitoring', False)
or 'endpoint' not in config
):
continue
checks[peer] = config['their_ip']
if not checks:
return {}
return {
'systemd-timers': {
'timers': {
'wg-health-check': {
'command': '/usr/local/bin/wg_health_check',
'when': 'minutely',
},
},
},
'wireguard': {
'health_checks': checks,
},
}