bundles/smartd: use systemd-timers

This commit is contained in:
Franzi 2023-07-13 21:31:11 +02:00
parent bbfa985e1d
commit 3936e64227
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -89,21 +89,19 @@ def icinga(metadata):
@metadata_reactor.provides( @metadata_reactor.provides(
'cron/jobs/smartd', 'systemd-timers/timers',
) )
def monthly_long_test(metadata): def monthly_long_test(metadata):
lines = set() timers = {}
for number, disk in enumerate(sorted(metadata.get('smartd/disks', set()))): for day, disk in enumerate(sorted(metadata.get('smartd/disks', set())), start=1):
lines.add('0 3 {} * * root /usr/sbin/smartctl --test=long {} >/dev/null'.format( timers[f'smartd{disk.replace("/", "-")}'] = {
number+1, # enumerate() starts at 0 'command': f'/usr/sbin/smartctl --test=long {disk}',
disk, 'when': f'*-*-{day} 03:00:00 UTC',
)) }
return { return {
'cron': { 'systemd-timers': {
'jobs': { 'timers': timers,
'smartd': '\n'.join(sorted(lines)),
},
}, },
} }