bundlewrap/bundles/netdata/metadata.py
2021-02-15 14:16:35 +01:00

41 lines
1 KiB
Python

defaults = {
'apt': {
'packages': {
'netdata': {},
},
},
'icinga2_api': {
'netdata': {
'services': {
'NETDATA PROCESS': {
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C netdata -c 1:',
},
},
},
},
}
@metadata_reactor.provides(
'iptables/bundle_rules/netdata',
)
def iptables(metadata):
identifiers = metadata.get('netdata/restrict-to', set())
rules = set()
if identifiers:
for identifier in sorted(identifiers):
resolved = repo.libs.tools.resolve_identifier(repo, identifier)
for address in resolved['ipv4']:
rules.add(f'iptables -A INPUT -p tcp -s {address} --dport 19999 -j ACCEPT')
else:
rules.add('iptables -A INPUT -p tcp --dport 19999 -j ACCEPT')
return {
'iptables': {
'bundle_rules': {
'netdata': list(sorted(rules)),
},
},
}