From 3936e642271f70b08bf7e7c78e53d9c527b97b9f Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Thu, 13 Jul 2023 21:31:11 +0200 Subject: [PATCH] bundles/smartd: use systemd-timers --- bundles/smartd/metadata.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/bundles/smartd/metadata.py b/bundles/smartd/metadata.py index 3ccd720..e444c35 100644 --- a/bundles/smartd/metadata.py +++ b/bundles/smartd/metadata.py @@ -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, }, }