@cryptotaxi247 / netdata-1 / commits / 1b9e8aa58

postfix.chart.py

paulfantom committed Jul 7, 2016 at 12:18 UTC 1b9e8aa58089dd4b5b4ab929fbfbb2fa2a528e99
2 files changed +55 -1
python.d/postfix.chart.py new
+54
@@ -0,0 +1,54 @@
1 +# -*- coding: utf-8 -*-
2 +# Description: postfix netdata python.d plugin
3 +# Author: Pawel Krupa (paulfantom)
4 +
5 +from base import ExecutableService
6 +
7 +# default module values (can be overridden per job in `config`)
8 +# update_every = 2
9 +priority = 60000
10 +retries = 5
11 +
12 +# default job configuration (overridden by python.d.plugin)
13 +# config = {'local': {
14 +# 'update_every': update_every,
15 +# 'retries': retries,
16 +# 'priority': priority,
17 +# 'url': 'http://localhost/stub_status'
18 +# }}
19 +
20 +# charts order (can be overridden if you want less charts, or different order)
21 +ORDER = ['qemails', 'qsize']
22 +
23 +CHARTS = {
24 + 'qemails': {
25 + 'options': [None, "Postfix Queue Emails", "emails", 'queue', 'postfix.queued.emails', 'line'],
26 + 'lines': [
27 + ['emails', None, 'absolute']
28 + ]},
29 + 'qsize': {
30 + 'options': [None, "Postfix Queue Emails Size", "emails size in KB", 'queue', 'postfix.queued.size', 'area'],
31 + 'lines': [
32 + ["size", None, 'absolute']
33 + ]}
34 +}
35 +
36 +
37 +class Service(ExecutableService):
38 + def __init__(self, configuration=None, name=None):
39 + ExecutableService.__init__(self, configuration=configuration, name=name)
40 + self.command = "postqueue -p"
41 + self.order = ORDER
42 + self.definitions = CHARTS
43 +
44 + def _get_data(self):
45 + """
46 + Format data received from shell command
47 + :return: dict
48 + """
49 + try:
50 + raw = self._get_raw_data()[-1].split(' ')
51 + return {'emails': raw[4],
52 + 'size': raw[1]}
53 + except (ValueError, AttributeError):
54 + return None
python.d/python_modules/base.py
+1 -1
@@ -564,7 +564,7 @@ class LogService(SimpleService):
564
565
566 class ExecutableService(SimpleService):
567 - command_whitelist = ['exim']
567 + command_whitelist = ['exim', 'postqueue']
568
569 def __init__(self, configuration=None, name=None):
570 self.command = ""