bundles/smartd: add cronjob to schedule a monthly long test
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit
This commit is contained in:
parent
bd10dc578f
commit
25ea5af2db
1 changed files with 20 additions and 1 deletions
|
@ -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)),
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue