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 'io', 'net', 'syscalls',
22 'options': [None, "Dovecot Active Sessions", 'number', 'sessions', 'dovecot.sessions', 'line'],
24 ['num_connected_sessions', 'active sessions', 'absolute']
27 'options': [None, "Dovecot Logins", 'number', 'logins', 'dovecot.logins', 'line'],
29 ['num_logins', 'logins', 'absolute']
32 'options': [None, "Dovecot Commands", "commands", 'commands', 'dovecot.commands', 'line'],
34 ['num_cmds', 'commands', 'absolute']
37 'options': [None, "Dovecot Page Faults", "faults", 'page faults', 'dovecot.faults', 'line'],
39 ['min_faults', 'minor', 'absolute'],
40 ['maj_faults', 'major', 'absolute']
43 'options': [None, "Dovecot Context Switches", '', 'context switches', 'dovecot.context_switches', 'line'],
45 ['vol_cs', 'volountary', 'absolute'],
46 ['invol_cs', 'involountary', 'absolute']
49 'options': [None, "Dovecot Disk I/O", 'kilobytes/s', 'disk', 'dovecot.io', 'area'],
51 ['disk_input', 'read', 'incremental', 1, 1024],
52 ['disk_output', 'write', 'incremental', -1, 1024]
55 'options': [None, "Dovecot Network Bandwidth", 'kilobits/s', 'network', 'dovecot.net', 'area'],
57 ['read_bytes', 'read', 'incremental', 8, 1024],
58 ['write_bytes', 'write', 'incremental', -8, 1024]
61 'options': [None, "Dovecot Number of SysCalls", 'syscalls/s', 'system', 'dovecot.syscalls', 'line'],
63 ['read_count', 'read', 'incremental'],
64 ['write_count', 'write', 'incremental']
67 'options': [None, "Dovecot Lookups", 'number/s', 'lookups', 'dovecot.lookup', 'stacked'],
69 ['mail_lookup_path', 'path', 'incremental'],
70 ['mail_lookup_attr', 'attr', 'incremental']
73 'options': [None, "Dovecot Cache Hits", 'hits/s', 'cache', 'dovecot.cache', 'line'],
75 ['mail_cache_hits', 'hits', 'incremental']
78 'options': [None, "Dovecot Authentications", 'attempts', 'logins', 'dovecot.auth', 'stacked'],
80 ['auth_successes', 'ok', 'absolute'],
81 ['auth_failures', 'failed', 'absolute']
84 'options': [None, "Dovecot Authentication Cache", 'number', 'cache', '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):
114 self.debug("dovecot returned no data")
117 data = raw.split('\n')[:2]
118 desc = data[0].split('\t')
119 vals = data[1].split('\t')
120 # ret = dict(zip(desc, vals))
122 for i in range(len(desc)):
125 #if d in ('user_cpu', 'sys_cpu', 'clock_time'):
126 # val = float(vals[i])
130 ret[str(desc[i])] = int(vals[i])