2021-02-12 19:37:36 +00:00
|
|
|
#import re
|
2020-08-29 19:10:59 +00:00
|
|
|
|
|
|
|
defaults = {
|
2020-10-25 15:39:35 +00:00
|
|
|
'apt': {
|
|
|
|
'packages': {
|
|
|
|
'linux-headers-amd64': {
|
2020-10-31 09:11:15 +00:00
|
|
|
'needed_by': {
|
|
|
|
'pkg_apt:zfs-dkms',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'zfs-dkms': {
|
2020-10-25 15:39:35 +00:00
|
|
|
'needed_by': {
|
|
|
|
'pkg_apt:zfs-zed',
|
|
|
|
'pkg_apt:zfsutils-linux',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'zfs-zed': {
|
|
|
|
'needed_by': {
|
|
|
|
'zfs_dataset:',
|
|
|
|
'zfs_pool:',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'zfsutils-linux': {
|
|
|
|
'needed_by': {
|
|
|
|
'pkg_apt:zfs-zed',
|
|
|
|
'zfs_dataset:',
|
|
|
|
'zfs_pool:',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'parted': {
|
|
|
|
'needed_by': {
|
|
|
|
'zfs_pool:',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'repos': {
|
|
|
|
'backports': {
|
|
|
|
'install_gpg_key': False, # default debian signing key
|
|
|
|
'items': [
|
|
|
|
'deb http://deb.debian.org/debian {os_release}-backports main',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-08-29 19:10:59 +00:00
|
|
|
'cron': {
|
|
|
|
'zfs-auto-snapshot-daily': '0 0 * * * root /usr/local/sbin/zfs-auto-snapshot daily',
|
|
|
|
'zfs-auto-snapshot-hourly': '0 * * * * root /usr/local/sbin/zfs-auto-snapshot hourly',
|
|
|
|
'zfs-auto-snapshot-monthly': '0 0 1 * * root /usr/local/sbin/zfs-auto-snapshot monthly',
|
|
|
|
'zfs-auto-snapshot-weekly': '0 0 * * 7 root /usr/local/sbin/zfs-auto-snapshot weekly',
|
|
|
|
},
|
2021-02-13 07:37:00 +00:00
|
|
|
'icinga2_api': {
|
|
|
|
'zfs': {
|
|
|
|
'services': {
|
|
|
|
'ZFS AUTO SNAPSHOT': {
|
|
|
|
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zfs_auto_snapshot',
|
|
|
|
},
|
|
|
|
'ZFS MOUNTED VOLUMES': {
|
|
|
|
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zfs_volumes',
|
|
|
|
'vars.notification.mail': True,
|
|
|
|
},
|
|
|
|
'ZFS OLD SNAPSHOTS': {
|
|
|
|
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zfs_old_snapshots',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-08-29 19:10:59 +00:00
|
|
|
'zfs': {
|
|
|
|
'datasets': {},
|
|
|
|
'pools': {},
|
|
|
|
'snapshots': {
|
|
|
|
'retain_defaults': {
|
|
|
|
'hourly': 24,
|
|
|
|
'daily': 7,
|
|
|
|
'weekly': 2,
|
|
|
|
'monthly': 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-04-23 17:31:28 +00:00
|
|
|
if node.has_bundle('telegraf'):
|
|
|
|
defaults['telegraf'] = {
|
|
|
|
'input_plugins': {
|
|
|
|
'builtin': {
|
|
|
|
'zfs': [{
|
|
|
|
'poolMetrics': True,
|
|
|
|
'datasetMetrics': True,
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-29 19:10:59 +00:00
|
|
|
|
2021-01-07 17:44:38 +00:00
|
|
|
@metadata_reactor.provides(
|
|
|
|
'cron/zfs-scrub',
|
|
|
|
)
|
2020-08-29 19:10:59 +00:00
|
|
|
def zfs_scrub_cronjob(metadata):
|
|
|
|
when = metadata.get('zfs/scrub/cron', '{} 0 * * sun'.format((node.magic_number % 60)))
|
|
|
|
return {
|
|
|
|
'cron': {
|
|
|
|
'zfs-scrub': '{} root /usr/lib/zfs-linux/scrub'.format(when),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@metadata_reactor
|
|
|
|
def monitoring(metadata):
|
|
|
|
if not node.has_bundle('sshmon'):
|
|
|
|
raise DoNotRunAgain
|
|
|
|
|
|
|
|
services = {}
|
|
|
|
|
2021-02-12 19:37:36 +00:00
|
|
|
for poolname, _ in metadata.get('zfs/pools').items():
|
2020-08-29 19:10:59 +00:00
|
|
|
services['ZFS ZPOOL ONLINE {}'.format(poolname)] = {
|
2020-11-10 09:35:01 +00:00
|
|
|
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zpool_online {}'.format(poolname),
|
2020-11-22 07:24:44 +00:00
|
|
|
'vars.notification.mail': True,
|
2020-08-29 19:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
services['ZFS ZPOOL SPACE ' + poolname] = {
|
2020-11-22 07:24:44 +00:00
|
|
|
'command_on_monitored_host': 'sudo /usr/local/share/icinga/plugins/check_zpool_space {} 90'.format(poolname),
|
|
|
|
'vars.notification.mail': True,
|
2020-08-29 19:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
'icinga2_api': {
|
|
|
|
'zfs': {
|
|
|
|
'services': services,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|