2020-11-29 11:07:27 +00:00
|
|
|
defaults = {
|
|
|
|
'apt': {
|
|
|
|
'packages': {
|
|
|
|
'smartmontools': {},
|
2021-04-24 09:45:58 +00:00
|
|
|
'nvme-cli': {},
|
2020-11-29 11:07:27 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
'icinga2_api': {
|
|
|
|
'smartd': {
|
|
|
|
'services': {
|
|
|
|
'SMARTD PROCESS': {
|
|
|
|
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit smartd',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'smartd/disks',
|
|
|
|
)
|
2020-11-29 11:07:27 +00:00
|
|
|
def zfs_disks_to_metadata(metadata):
|
|
|
|
disks = set()
|
|
|
|
|
2021-02-12 19:37:36 +00:00
|
|
|
for _, config in metadata.get('zfs/pools', {}).items():
|
2020-11-29 11:07:27 +00:00
|
|
|
if 'device' in config:
|
|
|
|
disks.add(config['device'])
|
|
|
|
else:
|
|
|
|
for t in {'mirror', 'raidz', 'raidz2', 'raidz3'}:
|
|
|
|
for device in config.get(t, set()):
|
|
|
|
disks.add(device)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'smartd': {
|
|
|
|
'disks': disks,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'icinga2_api/smartd/services',
|
|
|
|
)
|
2020-11-29 11:07:27 +00:00
|
|
|
def icinga(metadata):
|
|
|
|
services = {}
|
|
|
|
|
|
|
|
for disk in metadata.get('smartd/disks', set()):
|
|
|
|
services[f'SMART STATUS {disk}'] = {
|
|
|
|
'command_on_monitored_host': f'sudo /usr/local/share/icinga/plugins/check_smart -d {disk} -i auto',
|
|
|
|
'vars.notification.mail': True,
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'icinga2_api': {
|
|
|
|
'smartd': {
|
|
|
|
'services': services,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2021-04-23 17:31:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor.provides(
|
|
|
|
'telegraf/input_plugins/builtin/smart',
|
|
|
|
)
|
|
|
|
def telegraf(metadata):
|
|
|
|
if not node.has_bundle('telegraf'):
|
|
|
|
raise DoNotRunAgain
|
|
|
|
|
|
|
|
if metadata.get('smartd/disks', {}):
|
|
|
|
return {
|
|
|
|
'telegraf': {
|
|
|
|
'input_plugins': {
|
|
|
|
'builtin': {
|
|
|
|
'smart': [{
|
|
|
|
'devices': list(sorted(metadata.get('smartd/disks'))),
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return {}
|