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