bundles/postfix: use own postqueue exporter

This commit is contained in:
Franzi 2021-04-24 10:17:05 +02:00
parent 76f46ca7d5
commit c97d9ab948
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 30 additions and 2 deletions

View file

@ -0,0 +1,17 @@
#!/usr/bin/env python3
from json import loads
from subprocess import check_output
queue_counts = {}
queue_json = check_output(['sudo', '/usr/sbin/postqueue', '-j'])
for line in queue_json.splitlines():
j = loads(line.decode('UTF-8'))
queue_counts.setdefault(j['queue_name'], 0)
queue_counts[j['queue_name']] += 1
for queue in ('incoming', 'active', 'deferred', 'corrupt', 'hold'):
print('postfix_queue,status={} count={}i'.format(queue, queue_counts.get(queue, 0)))

View file

@ -54,6 +54,9 @@ files = {
'svc_systemd:postfix:restart',
},
},
'/usr/local/bin/postfix-telegraf-queue': {
'mode': '0755',
},
'/usr/local/share/icinga/plugins/check_postfix_queue': {
'mode': '0755',
},

View file

@ -53,10 +53,18 @@ else:
if node.has_bundle('telegraf'):
defaults['telegraf'] = {
'input_plugins': {
'builtin': {
'postfix': [{}],
'exec': {
'postfix': {
'commands': ['postfix-telegraf-queue'],
'interval': '15s',
'data_format': 'influx',
'timeout': '5s',
},
},
},
'sudo_commands': {
'/usr/sbin/postqueue -j',
},
}