]> arthur.barton.de Git - netdata.git/commitdiff
dovecot support
authorpaulfantom <paulfantom@gmail.com>
Wed, 3 Aug 2016 18:08:41 +0000 (20:08 +0200)
committerpaulfantom <paulfantom@gmail.com>
Wed, 3 Aug 2016 18:08:41 +0000 (20:08 +0200)
conf.d/Makefile.am
conf.d/python.d/dovecot.conf [new file with mode: 0644]
python.d/Makefile.am
python.d/dovecot.chart.py [new file with mode: 0644]

index 84b6c47a1ab1a06601352661b05ded1e53fd7b27..30ca61fb9fa2a45ab21d914fdd959ae227c8faba 100644 (file)
@@ -22,6 +22,7 @@ dist_pythonconfig_DATA = \
        python.d/apache.conf \
        python.d/apache_cache.conf \
        python.d/cpufreq.conf \
+       python.d/dovecot.conf \
        python.d/example.conf \
        python.d/exim.conf \
        python.d/hddtemp.conf \
diff --git a/conf.d/python.d/dovecot.conf b/conf.d/python.d/dovecot.conf
new file mode 100644 (file)
index 0000000..917c527
--- /dev/null
@@ -0,0 +1,89 @@
+# netdata python.d.plugin configuration for dovecot
+#
+# This file is in YaML format. Generally the format is:
+#
+# name: value
+#
+# There are 2 sections:
+#  - global variables
+#  - one or more JOBS
+#
+# JOBS allow you to collect values from multiple sources.
+# Each source will have its own set of charts.
+#
+# JOB parameters have to be indented (using spaces only, example below).
+
+# ----------------------------------------------------------------------
+# Global Variables
+# These variables set the defaults for all JOBs, however each JOB
+# may define its own, overriding the defaults.
+
+# update_every sets the default data collection frequency.
+# If unset, the python.d.plugin default is used.
+# update_every: 1
+
+# priority controls the order of charts at the netdata dashboard.
+# Lower numbers move the charts towards the top of the page.
+# If unset, the default for python.d.plugin is used.
+# priority: 60000
+
+# retries sets the number of retries to be made in case of failures.
+# If unset, the default for python.d.plugin is used.
+# Attempts to restore the service are made once every update_every
+# and only if the module has collected values in the past.
+# retries: 5
+
+# ----------------------------------------------------------------------
+# JOBS (data collection sources)
+#
+# The default JOBS share the same *name*. JOBS with the same name
+# are mutually exclusive. Only one of them will be allowed running at
+# any time. This allows autodetection to try several alternatives and
+# pick the one that works.
+#
+# Any number of jobs is supported.
+#
+# All python.d.plugin JOBS (for all its modules) support a set of
+# predefined parameters. These are:
+#
+# job_name:
+#     name: myname     # the JOB's name as it will appear at the
+#                      # dashboard (by default is the job_name)
+#                      # JOBs sharing a name are mutually exclusive
+#     update_every: 1  # the JOB's data collection frequency
+#     priority: 60000  # the JOB's order on the dashboard
+#     retries: 5       # the JOB's number of restoration attempts
+#
+# Additionally to the above, dovecot also supports the following:
+#
+#     socket: 'path/to/dovecot/stats'
+#
+#  or
+#     host: 'IP or HOSTNAME' # the host to connect to
+#     port: PORT             # the port to connect to
+#
+#
+
+# ----------------------------------------------------------------------
+# AUTO-DETECTION JOBS
+# only one of them will run (they have the same name)
+
+localhost:
+  name     : 'local'
+  host     : 'localhost'
+  port     : 24242
+
+localipv4:
+  name     : 'local'
+  host     : '127.0.0.1'
+  port     : 24242
+
+localipv6:
+  name     : 'local'
+  host     : '::1'
+  port     : 24242
+
+localsocket:
+  name     : 'local'
+  socket   : '/var/run/dovecot/stats'
+
index 51ebad096cbc181bcd5837edfd69452fdee0549b..6abb698ba52871f19fcf92c0d0d2b05befb8f71d 100644 (file)
@@ -11,6 +11,7 @@ dist_python_SCRIPTS = \
        apache.chart.py \
        apache_cache.chart.py \
        cpufreq.chart.py \
+       dovecot.chart.py \
        example.chart.py \
        exim.chart.py \
        hddtemp.chart.py \
diff --git a/python.d/dovecot.chart.py b/python.d/dovecot.chart.py
new file mode 100644 (file)
index 0000000..4ec1acd
--- /dev/null
@@ -0,0 +1,127 @@
+# -*- coding: utf-8 -*-
+# Description: dovecot netdata python.d module
+# Author: Pawel Krupa (paulfantom)
+
+from base import SocketService
+
+# default module values (can be overridden per job in `config`)
+# update_every = 2
+priority = 60000
+retries = 60
+
+# charts order (can be overridden if you want less charts, or different order)
+ORDER = ['sessions', 'commands',
+         'faults',
+         'context_switches',
+         'disk', 'bytes', 'syscalls',
+         'lookup', 'cache',
+         'auth', 'auth_cache']
+
+CHARTS = {
+    'sessions': {
+        'options': [None, "logins and sessions", 'number', 'IMAP', 'dovecot.imap', 'line'],
+        'lines': [
+            ['num_logins', 'logins', 'absolute'],
+            ['num_connected_sessions', 'active sessions', 'absolute']
+        ]},
+    'commands': {
+        'options': [None, "commands", "commands", 'IMAP', 'dovecot.imap', 'line'],
+        'lines': [
+            ['num_cmds', 'commands', 'absolute']
+        ]},
+    'faults': {
+        'options': [None, "faults", "faults", 'Faults', 'dovecot.faults', 'line'],
+        'lines': [
+            ['min_faults', 'minor', 'absolute'],
+            ['maj_faults', 'major', 'absolute']
+        ]},
+    'context_switches': {
+        'options': [None, "context switches", '', 'Context Switches', 'dovecot.context_switches', 'line'],
+        'lines': [
+            ['vol_cs', 'volountary', 'absolute'],
+            ['invol_cs', 'involountary', 'absolute']
+        ]},
+    'disk': {
+        'options': [None, "disk", 'bytes/s', 'Reads and Writes', 'dovecot.read_write', 'line'],
+        'lines': [
+            ['disk_input', 'read', 'incremental'],
+            ['disk_output', 'write', 'incremental']
+        ]},
+    'bytes': {
+        'options': [None, "bytes", 'bytes/s', 'Reads and Writes', 'dovecot.read_write', 'line'],
+        'lines': [
+            ['read_bytes', 'read', 'incremental'],
+            ['write_bytes', 'write', 'incremental']
+        ]},
+    'syscalls': {
+        'options': [None, "number of syscalls", 'syscalls/s', 'Reads and Writes', 'dovecot.read_write', 'line'],
+        'lines': [
+            ['read_count', 'read', 'incremental'],
+            ['write_count', 'write', 'incremental']
+        ]},
+    'lookup': {
+        'options': [None, "lookups", 'number/s', 'Mail', 'dovecot.mail', 'line'],
+        'lines': [
+            ['mail_lookup_path', 'path', 'incremental'],
+            ['mail_lookup_attr', 'attr', 'incremental']
+        ]},
+    'cache': {
+        'options': [None, "hits", 'hits/s', 'Mail', 'dovecot.mail', 'line'],
+        'lines': [
+            ['mail_cache_hits', 'hits', 'incremental']
+        ]},
+    'auth': {
+        'options': [None, "attempts", 'attempts', 'Authentication', 'dovecot.auth', 'stacked'],
+        'lines': [
+            ['auth_successes', 'success', 'absolute'],
+            ['auth_failures', 'failure', 'absolute']
+        ]},
+    'auth_cache': {
+        'options': [None, "cache", 'number', 'Authentication', 'dovecot.auth', 'stacked'],
+        'lines': [
+            ['auth_cache_hits', 'hit', 'absolute'],
+            ['auth_cache_misses', 'miss', 'absolute']
+        ]}
+}
+
+
+class Service(SocketService):
+    def __init__(self, configuration=None, name=None):
+        SocketService.__init__(self, configuration=configuration, name=name)
+        self.request = "EXPORT\tglobal\r\n"
+        self.host = None  # localhost
+        self.port = None  # 24242
+        # self._keep_alive = True
+        self.unix_socket = "/var/run/dovecot/stats"
+        self.order = ORDER
+        self.definitions = CHARTS
+
+    def _get_data(self):
+        """
+        Format data received from socket
+        :return: dict
+        """
+        try:
+            raw = self._get_raw_data()
+        except (ValueError, AttributeError):
+            return None
+
+        data = raw.split('\n')[:2]
+        desc = data[0].split('\t')
+        vals = data[1].split('\t')
+        # ret = dict(zip(desc, vals))
+        ret = {}
+        for i in range(len(desc)):
+            try:
+                #d = str(desc[i])
+                #if d in ('user_cpu', 'sys_cpu', 'clock_time'):
+                #    val = float(vals[i])
+                #else:
+                #    val = int(vals[i])
+                #ret[d] = val
+                ret[str(desc[i])] = int(vals[i])
+            except ValueError:
+                pass
+        if len(ret) == 0:
+            return None
+        return ret