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', 'logins', 'commands',
16 'disk', 'bytes', 'syscalls',
22 'options': [None, "active sessions", 'number', 'IMAP', 'dovecot.sessions', 'line'],
24 ['num_connected_sessions', 'active sessions', 'absolute']
27 'options': [None, "logins", 'number', 'IMAP', 'dovecot.logins', 'line'],
29 ['num_logins', 'logins', 'absolute']
32 'options': [None, "commands", "commands", 'IMAP', 'dovecot.commands', 'line'],
34 ['num_cmds', 'commands', 'absolute']
37 'options': [None, "faults", "faults", 'Faults', 'dovecot.faults', 'line'],
39 ['min_faults', 'minor', 'absolute'],
40 ['maj_faults', 'major', 'absolute']
43 'options': [None, "context switches", '', 'Context Switches', 'dovecot.context_switches', 'line'],
45 ['vol_cs', 'volountary', 'absolute'],
46 ['invol_cs', 'involountary', 'absolute']
49 'options': [None, "disk", 'bytes/s', 'Reads and Writes', 'dovecot.disk', 'line'],
51 ['disk_input', 'read', 'incremental'],
52 ['disk_output', 'write', 'incremental']
55 'options': [None, "bytes", 'bytes/s', 'Reads and Writes', 'dovecot.bytes', 'line'],
57 ['read_bytes', 'read', 'incremental'],
58 ['write_bytes', 'write', 'incremental']
61 'options': [None, "number of syscalls", 'syscalls/s', 'Reads and Writes', 'dovecot.syscalls', 'line'],
63 ['read_count', 'read', 'incremental'],
64 ['write_count', 'write', 'incremental']
67 'options': [None, "lookups", 'number/s', 'Mail', 'dovecot.lookup', 'line'],
69 ['mail_lookup_path', 'path', 'incremental'],
70 ['mail_lookup_attr', 'attr', 'incremental']
73 'options': [None, "hits", 'hits/s', 'Mail', 'dovecot.cache', 'line'],
75 ['mail_cache_hits', 'hits', 'incremental']
78 'options': [None, "attempts", 'attempts', 'Authentication', 'dovecot.auth', 'stacked'],
80 ['auth_successes', 'success', 'absolute'],
81 ['auth_failures', 'failure', 'absolute']
84 'options': [None, "cache", 'number', 'Authentication', 'dovecot.auth_cache', 'stacked'],
86 ['auth_cache_hits', 'hit', 'absolute'],
87 ['auth_cache_misses', 'miss', 'absolute']
92 class Service(SocketService):
93 def __init__(self, configuration=None, name=None):
94 SocketService.__init__(self, configuration=configuration, name=name)
95 self.request = "EXPORT\tglobal\r\n"
96 self.host = None # localhost
97 self.port = None # 24242
98 # self._keep_alive = True
99 self.unix_socket = "/var/run/dovecot/stats"
101 self.definitions = CHARTS
105 Format data received from socket
109 raw = self._get_raw_data()
110 except (ValueError, AttributeError):
113 data = raw.split('\n')[:2]
114 desc = data[0].split('\t')
115 vals = data[1].split('\t')
116 # ret = dict(zip(desc, vals))
118 for i in range(len(desc)):
121 #if d in ('user_cpu', 'sys_cpu', 'clock_time'):
122 # val = float(vals[i])
126 ret[str(desc[i])] = int(vals[i])