1 # -*- coding: utf-8 -*-
2 # Description: dovecot netdata python.d module
3 # Author: Pawel Krupa (paulfantom)
5 from base import SocketService
7 # default module values (can be overridden per job in `config`)
12 # charts order (can be overridden if you want less charts, or different order)
13 ORDER = ['sessions', 'commands',
16 'disk', 'bytes', 'syscalls',
22 'options': [None, "logins and sessions", 'number', 'IMAP', 'dovecot.imap', 'line'],
24 ['num_logins', 'logins', 'absolute'],
25 ['num_connected_sessions', 'active sessions', 'absolute']
28 'options': [None, "commands", "commands", 'IMAP', 'dovecot.imap', 'line'],
30 ['num_cmds', 'commands', 'absolute']
33 'options': [None, "faults", "faults", 'Faults', 'dovecot.faults', 'line'],
35 ['min_faults', 'minor', 'absolute'],
36 ['maj_faults', 'major', 'absolute']
39 'options': [None, "context switches", '', 'Context Switches', 'dovecot.context_switches', 'line'],
41 ['vol_cs', 'volountary', 'absolute'],
42 ['invol_cs', 'involountary', 'absolute']
45 'options': [None, "disk", 'bytes/s', 'Reads and Writes', 'dovecot.read_write', 'line'],
47 ['disk_input', 'read', 'incremental'],
48 ['disk_output', 'write', 'incremental']
51 'options': [None, "bytes", 'bytes/s', 'Reads and Writes', 'dovecot.read_write', 'line'],
53 ['read_bytes', 'read', 'incremental'],
54 ['write_bytes', 'write', 'incremental']
57 'options': [None, "number of syscalls", 'syscalls/s', 'Reads and Writes', 'dovecot.read_write', 'line'],
59 ['read_count', 'read', 'incremental'],
60 ['write_count', 'write', 'incremental']
63 'options': [None, "lookups", 'number/s', 'Mail', 'dovecot.mail', 'line'],
65 ['mail_lookup_path', 'path', 'incremental'],
66 ['mail_lookup_attr', 'attr', 'incremental']
69 'options': [None, "hits", 'hits/s', 'Mail', 'dovecot.mail', 'line'],
71 ['mail_cache_hits', 'hits', 'incremental']
74 'options': [None, "attempts", 'attempts', 'Authentication', 'dovecot.auth', 'stacked'],
76 ['auth_successes', 'success', 'absolute'],
77 ['auth_failures', 'failure', 'absolute']
80 'options': [None, "cache", 'number', 'Authentication', 'dovecot.auth', 'stacked'],
82 ['auth_cache_hits', 'hit', 'absolute'],
83 ['auth_cache_misses', 'miss', 'absolute']
88 class Service(SocketService):
89 def __init__(self, configuration=None, name=None):
90 SocketService.__init__(self, configuration=configuration, name=name)
91 self.request = "EXPORT\tglobal\r\n"
92 self.host = None # localhost
93 self.port = None # 24242
94 # self._keep_alive = True
95 self.unix_socket = "/var/run/dovecot/stats"
97 self.definitions = CHARTS
101 Format data received from socket
105 raw = self._get_raw_data()
106 except (ValueError, AttributeError):
109 data = raw.split('\n')[:2]
110 desc = data[0].split('\t')
111 vals = data[1].split('\t')
112 # ret = dict(zip(desc, vals))
114 for i in range(len(desc)):
117 #if d in ('user_cpu', 'sys_cpu', 'clock_time'):
118 # val = float(vals[i])
122 ret[str(desc[i])] = int(vals[i])