bundlewrap/bundles/transmission/metadata.py

85 lines
2.4 KiB
Python
Raw Normal View History

2021-03-21 09:30:04 +00:00
from bundlewrap.metadata import atomic
defaults = {
'apt': {
'packages': {
'transmission-daemon': {},
'transmission-remote-cli': {},
},
},
'icinga2_api': {
'transmission': {
'services': {
'TRANSMISSION PROCESS': {
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -a transmission-daemon -c 1:',
},
},
},
},
'transmission': {
'config': {
'message-level': 2,
'peer-port': 51413,
'port-forwarding-enabled': False,
'rename-partial-files': True,
'rpc-authentication-required': False,
'rpc-bind-address': '0.0.0.0',
'rpc-enabled': True,
'rpc-host-whitelist-enabled': False,
'rpc-port': 9091,
'rpc-url': '/transmission/',
'rpc-whitelist-enabled': False,
'start-added-torrents': True,
},
},
}
if node.has_bundle('telegraf'):
defaults['telegraf'] = {
'input_plugins': {
'exec': {
'transmission': {
'commands': ['telegraf-transmission-plugin'],
'interval': '10s',
'data_format': 'influx',
'timeout': '5s',
},
},
},
}
@metadata_reactor.provides(
2021-03-21 09:30:04 +00:00
'iptables/port_rules',
)
def iptables(metadata):
return {
'iptables': {
2021-03-21 09:30:04 +00:00
'port_rules': {
2021-04-04 08:34:55 +00:00
str(metadata.get('transmission/config/peer-port')): atomic({'*'}),
str(metadata.get('transmission/config/peer-port')) + '/udp': atomic({'*'}),
str(metadata.get('transmission/config/rpc-port')): atomic(metadata.get('transmission/restrict-to', {'*'})),
},
},
}
@metadata_reactor.provides(
'icinga2_api/transmission/services',
)
def icinga_web(metadata):
port = metadata.get('transmission/config/rpc-port')
path = metadata.get('transmission/config/rpc-url')
return {
'icinga2_api': {
'transmission': {
'services': {
'TRANSMISSION WEB INTERFACE': {
'command_on_monitored_host': f'/usr/local/share/icinga/plugins/check_http_url_for_string http://127.0.0.1:{port}{path} "Transmission"',
},
},
},
},
}