17 lines
475 B
Python
17 lines
475 B
Python
#!/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 {}={}i'.format(queue, queue_counts.get(queue, 0)))
|