bundlewrap/bundles/smartctl/items.py
2021-10-30 18:57:06 +02:00

25 lines
839 B
Python

files = {
'/usr/local/share/icinga/plugins/hdd_temp': {
'content_type': 'mako',
'mode': '0755',
},
}
previous_action = []
for device, conf in node.metadata.get('smartctl').items():
for option, value in conf.items():
if option == 'apm':
action_name = f'smartctl_apm_{device}'
actions[action_name] = {
'command': f'smartctl --set apm,{value} "{device}"',
'unless': f'smartctl --get apm "{device}" --json=c | jq .ata_apm.level | grep -q "^{value}$"',
'needs': [
'pkg_apt:smartmontools',
*previous_action,
],
}
else:
raise ValueError(f'{node.name}: unkown smartctl option: {option}')
previous_action = [f'action:{action_name}']