53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
|
from bundlewrap.metadata import atomic
|
||
|
|
||
|
|
||
|
@metadata_processor
|
||
|
def backups(metadata):
|
||
|
if metadata.get('bind', {}).get('zones_primary_dynamic', {}):
|
||
|
metadata.setdefault('backups', {}).setdefault('paths', set()).add(
|
||
|
'/var/lib/bind/primary.dynamic',
|
||
|
)
|
||
|
return metadata, RUN_ME_AGAIN
|
||
|
|
||
|
|
||
|
@metadata_processor
|
||
|
def monitoring(metadata):
|
||
|
icinga2_api = metadata.setdefault('icinga2_api', {})
|
||
|
node_metadata = icinga2_api.setdefault('bind', {})
|
||
|
|
||
|
services = node_metadata.setdefault('services', {})
|
||
|
services.setdefault('BIND PROCESS', {}).update({
|
||
|
'check_command': 'nrpe',
|
||
|
'vars.nrpe_command': 'check_bind_procs',
|
||
|
})
|
||
|
for interface in metadata.get('bind', {}).get('listen', []):
|
||
|
services.setdefault('BIND PORT {}'.format(interface), {}).update({
|
||
|
'check_command': 'tcp',
|
||
|
'vars.tcp_address': metadata['interfaces'][interface]['ip_addresses'][0],
|
||
|
'vars.tcp_port': 53,
|
||
|
})
|
||
|
|
||
|
nrpe_checks = metadata.setdefault('nrpe', {}).setdefault('custom_nrpe_checks', {})
|
||
|
nrpe_checks['check_bind_procs'] = '/usr/lib/nagios/plugins/check_procs -C named -c 1:1'
|
||
|
|
||
|
return metadata, DONE
|
||
|
|
||
|
|
||
|
@metadata_processor
|
||
|
def sperrfix(metadata):
|
||
|
per_bundle = metadata.get('bind', {}).get('sperrfix', {})
|
||
|
|
||
|
if per_bundle.get('ignore'):
|
||
|
return metadata, DONE
|
||
|
|
||
|
sources = per_bundle.get('sources', {'*'})
|
||
|
|
||
|
return {
|
||
|
'sperrfix': {
|
||
|
'bundle_rules': {
|
||
|
'53': atomic({'sources': sources}),
|
||
|
'53/udp': atomic({'sources': sources}),
|
||
|
},
|
||
|
},
|
||
|
}, OVERWRITE, RUN_ME_AGAIN
|