bundles/telegraf: introduce

This commit is contained in:
Franzi 2021-04-23 19:27:20 +02:00
parent 433754590d
commit 5e0541aef8
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,4 @@
<%
from tomlkit import dumps as toml_dumps
from bundlewrap.utils.text import toml_clean
%>${toml_clean(toml_dumps(repo.libs.toml.dict_to_toml(config)))}

73
bundles/telegraf/items.py Normal file
View file

@ -0,0 +1,73 @@
metadata = node.metadata['telegraf']
telegraf_config = {
'agent': {
'collection_jitter': '5s',
'debug': False,
'flush_buffer_when_full': True,
'flush_interval': '10s',
'flush_jitter': '5s',
'hostname': node.name,
'interval': '60s',
'metric_buffer_limit': 1_000_000,
'quiet': False,
'round_interval': False,
},
'inputs': {
'cpu': [{
'percpu': False,
'totalcpu': True,
'fielddrop': [
'time_*',
],
}],
'disk': [{
'ignore_fs': [
'aufs',
'devtmpfs',
'nsfs',
'tmpfs',
],
}],
'diskio': [{
'skip_serial_number': True,
}],
'kernel': [{}],
'mem': [{}],
'net': [{
'interfaces': [
'en*',
'eth*',
'wg*',
'wlp*',
],
}],
'nstat': [{}],
'processes': [{}],
'system': [{}],
**metadata.get('input_plugins', {}).get('builtin', {}),
},
'outputs': {
'influxdb_v2': [{
'urls': [metadata['influxdb_url']],
'token': metadata['influxdb_token'],
'organization': metadata['influxdb_org'],
'bucket': metadata['influxdb_bucket'],
}],
},
}
for config in metadata.get('input_plugins', {}).get('exec', {}).values():
if 'exec' not in telegraf_config['inputs']:
telegraf_config['inputs']['exec'] = []
telegraf_config['inputs']['exec'].append(config)
files = {
'/etc/telegraf/telegraf.conf': {
'content_type': 'mako',
'context': {
'config': telegraf_config,
},
},
}

View file

@ -0,0 +1,23 @@
defaults = {
'apt': {
'packages': {
'telegraf': {},
},
'repos': {
'influxdb': {
'items': {
'deb https://repos.influxdata.com/{os} {os_release} stable',
},
},
},
},
'icinga2_api': {
'telegraf': {
'services': {
'TELEGRAF PROCESS': {
'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -C telegraf -c 1:',
},
},
},
},
}

View file

@ -29,6 +29,7 @@ groups['linux'] = {
'sudo', 'sudo',
'systemd', 'systemd',
'systemd-networkd', 'systemd-networkd',
'telegraf',
'users', 'users',
}, },
'metadata': { 'metadata': {
@ -50,6 +51,12 @@ groups['linux'] = {
}, },
}, },
}, },
'telegraf': {
'influxdb_url': '',
'influxdb_token': '',
'influxdb_org': '',
'influxdb_bucket': '',
},
}, },
'pip_command': 'pip3', 'pip_command': 'pip3',
} }