bundles/smartd: introduce, add to hosts where *we* need to keep track of disk health
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
8456ac43c6
commit
295ff72b4b
7 changed files with 878 additions and 0 deletions
54
bundles/smartd/metadata.py
Normal file
54
bundles/smartd/metadata.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
defaults = {
|
||||
'apt': {
|
||||
'packages': {
|
||||
'smartmontools': {},
|
||||
},
|
||||
},
|
||||
'icinga2_api': {
|
||||
'smartd': {
|
||||
'services': {
|
||||
'SMARTD PROCESS': {
|
||||
'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_systemd_unit smartd',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
def zfs_disks_to_metadata(metadata):
|
||||
disks = set()
|
||||
|
||||
for pool, config in metadata.get('zfs/pools', {}).items():
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor
|
||||
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,
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue