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)