]> arthur.barton.de Git - netdata.git/blob - python.d/postfix.chart.py
postfix.chart.py
[netdata.git] / python.d / postfix.chart.py
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