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)))
|
|
@ -54,6 +54,9 @@ files = {
|
||||||
'svc_systemd:postfix:restart',
|
'svc_systemd:postfix:restart',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'/usr/local/bin/postfix-telegraf-queue': {
|
||||||
|
'mode': '0755',
|
||||||
|
},
|
||||||
'/usr/local/share/icinga/plugins/check_postfix_queue': {
|
'/usr/local/share/icinga/plugins/check_postfix_queue': {
|
||||||
'mode': '0755',
|
'mode': '0755',
|
||||||
},
|
},
|
||||||
|
|
|
@ -53,10 +53,18 @@ else:
|
||||||
if node.has_bundle('telegraf'):
|
if node.has_bundle('telegraf'):
|
||||||
defaults['telegraf'] = {
|
defaults['telegraf'] = {
|
||||||
'input_plugins': {
|
'input_plugins': {
|
||||||
'builtin': {
|
'exec': {
|
||||||
'postfix': [{}],
|
'postfix': {
|
||||||
|
'commands': ['postfix-telegraf-queue'],
|
||||||
|
'interval': '15s',
|
||||||
|
'data_format': 'influx',
|
||||||
|
'timeout': '5s',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'sudo_commands': {
|
||||||
|
'/usr/sbin/postqueue -j',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue