bundles/smartd: add cronjob to schedule a monthly long test
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit

This commit is contained in:
Franzi 2021-08-15 16:22:34 +02:00
parent bd10dc578f
commit 25ea5af2db
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -66,7 +66,7 @@ def telegraf(metadata):
if not node.has_bundle('telegraf'):
raise DoNotRunAgain
if metadata.get('smartd/disks', {}):
if metadata.get('smartd/disks', set()):
return {
'telegraf': {
'input_plugins': {
@ -80,3 +80,22 @@ def telegraf(metadata):
}
return {}
@metadata_reactor.provides(
'cron/smartd',
)
def monthly_long_test(metadata):
lines = set()
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,
))
return {
'cron': {
'smartd': '\n'.join(sorted(lines)),
},
}