bundles/postfix: use own postqueue exporter
This commit is contained in:
parent
76f46ca7d5
commit
c97d9ab948
3 changed files with 30 additions and 2 deletions
17
bundles/postfix/files/postfix-telegraf-queue
Normal file
17
bundles/postfix/files/postfix-telegraf-queue
Normal 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)))
|
Loading…
Add table
Add a link
Reference in a new issue