bundles/rspamd: add telegraf metrics
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit

This commit is contained in:
Franzi 2021-08-23 22:19:31 +02:00
parent ad159cc29a
commit 2940bfd3d8
Signed by: kunsi
GPG key ID: 12E3D2136B818350
5 changed files with 361 additions and 2 deletions

View file

@ -0,0 +1,43 @@
#!/usr/bin/env python3
from requests import get
from sys import argv, stderr
try:
r = get('http://127.0.0.1:11334/stat')
r.raise_for_status()
json = r.json()
actions = set()
for k, v in json['actions'].items():
actions.add('{}={}i'.format(k.replace(' ', '_'), v))
print('rspamd_actions {}'.format(','.join(sorted(actions))))
stats = set()
for i in {
'scanned',
'learned',
'spam_count',
'ham_count',
'connections',
'control_connections',
'pools_allocated',
'pools_freed',
'bytes_allocated',
'chunks_allocated',
'shared_chunks_allocated',
'chunks_freed',
'chunks_oversized',
'fragmented',
'total_learns',
}:
stats.add('{}={}i'.format(i, json[i]))
print('rspamd_stats {}'.format(','.join(sorted(stats))))
for domain, value in json['fuzzy_hashes'].items():
print('rspamd_fuzzy,domain={} value={}i'.format(domain, value))
except Exception as e:
print(repr(e), file=stderr)

View file

@ -55,6 +55,9 @@ files = {
'/etc/rspamd/local.d/ip_whitelist.map': {
'content_type': 'mako',
},
'/usr/local/bin/telegraf-rspamd-plugin': {
'mode': '0755',
},
}
@ -92,7 +95,7 @@ if 'dkim' in node.metadata.get('rspamd', {}):
},
}
if 'password' in node.metadata.get('rspamd', {}):
if node.metadata.get('rspamd/password', None):
files['/etc/rspamd/local.d/worker-controller.inc'] = {
'content_type': 'mako',
'triggers': {

View file

@ -55,7 +55,20 @@ defaults = {
},
},
'rspamd': {
'dkim': repo.vault.password_for(node.name + ' rspamd dkim key'),
'dkim': repo.vault.password_for(f'{node.name} rspamd dkim key'),
},
'telegraf': {
'input_plugins': {
'exec': {
'rspamd': {
'commands': [
'/usr/local/bin/telegraf-rspamd-plugin',
],
'data_format': 'influx',
'timeout': '5s',
},
},
},
},
'zfs': {
'datasets': {