nsd plugin
new file: conf.d/python.d/nsd.conf new file: python.d/nsd.chart.py
383c57 committed
Mar 6, 2017 at 21:34 UTC
cedd8e0e1f07d7ac4c299889d9a40cf45ad0b626
4 files changed
+180
conf.d/Makefile.am
+1
@@ -43,6 +43,7 @@ dist_pythonconfig_DATA = \
43
python.d/mongodb.conf \
44
python.d/mysql.conf \
45
python.d/nginx.conf \
46
+ python.d/nsd.conf \
47
python.d/ovpn_status_log.conf \
48
python.d/phpfpm.conf \
49
python.d/postfix.conf \
conf.d/python.d/nsd.conf
new
+86
@@ -0,0 +1,86 @@
1
+# netdata python.d.plugin configuration for nsd
2
+#
3
+# This file is in YaML format. Generally the format is:
4
+#
5
+# name: value
6
+#
7
+# There are 2 sections:
8
+# - global variables
9
+# - one or more JOBS
10
+#
11
+# JOBS allow you to collect values from multiple sources.
12
+# Each source will have its own set of charts.
13
+#
14
+# JOB parameters have to be indented (using spaces only, example below).
15
+
16
+# ----------------------------------------------------------------------
17
+# Global Variables
18
+# These variables set the defaults for all JOBs, however each JOB
19
+# may define its own, overriding the defaults.
20
+
21
+# update_every sets the default data collection frequency.
22
+# If unset, the python.d.plugin default is used.
23
+# nsd-control is slow, so once every 30 seconds
24
+# update_every: 30
25
+
26
+# priority controls the order of charts at the netdata dashboard.
27
+# Lower numbers move the charts towards the top of the page.
28
+# If unset, the default for python.d.plugin is used.
29
+# priority: 60000
30
+
31
+# retries sets the number of retries to be made in case of failures.
32
+# If unset, the default for python.d.plugin is used.
33
+# Attempts to restore the service are made once every update_every
34
+# and only if the module has collected values in the past.
35
+# retries: 5
36
+
37
+# ----------------------------------------------------------------------
38
+# JOBS (data collection sources)
39
+#
40
+# The default JOBS share the same *name*. JOBS with the same name
41
+# are mutually exclusive. Only one of them will be allowed running at
42
+# any time. This allows autodetection to try several alternatives and
43
+# pick the one that works.
44
+#
45
+# Any number of jobs is supported.
46
+#
47
+# All python.d.plugin JOBS (for all its modules) support a set of
48
+# predefined parameters. These are:
49
+#
50
+# job_name:
51
+# name: myname # the JOB's name as it will appear at the
52
+# # dashboard (by default is the job_name)
53
+# # JOBs sharing a name are mutually exclusive
54
+# update_every: 1 # the JOB's data collection frequency
55
+# priority: 60000 # the JOB's order on the dashboard
56
+# retries: 5 # the JOB's number of restoration attempts
57
+#
58
+# Additionally to the above, nsd also supports the following:
59
+#
60
+# command: 'nsd-control stats_noreset' # the command to run
61
+#
62
+
63
+# ----------------------------------------------------------------------
64
+# IMPORTANT Information
65
+#
66
+# Netdata must have permissions to run `nsd-control stats_noreset` command
67
+#
68
+# - Example-1 (use "sudo")
69
+# 1. sudoers (e.g. visudo -f /etc/sudoers.d/netdata)
70
+# Defaults:netdata !requiretty
71
+# netdata ALL=(ALL) NOPASSWD: /usr/sbin/nsd-control stats_noreset
72
+# 2. etc/netdata/python.d/nsd.conf
73
+# local:
74
+# update_every: 30
75
+# command: 'sudo /usr/sbin/nsd-control stats_noreset'
76
+#
77
+# - Example-2 (add "netdata" user to "nsd" group)
78
+# usermod -aG nsd netdata
79
+#
80
+
81
+# ----------------------------------------------------------------------
82
+# AUTO-DETECTION JOBS
83
+
84
+local:
85
+ update_every: 30
86
+ command: 'nsd-control stats_noreset'
python.d/Makefile.am
+1
@@ -33,6 +33,7 @@ dist_python_DATA = \
33
mongodb.chart.py \
34
mysql.chart.py \
35
nginx.chart.py \
36
+ nsd.chart.py \
37
ovpn_status_log.chart.py \
38
phpfpm.chart.py \
39
postfix.chart.py \
python.d/nsd.chart.py
new
+92
@@ -0,0 +1,92 @@
1
+# -*- coding: utf-8 -*-
2
+# Description: NSD `nsd-control stats_noreset` netdata python.d module
3
+# Author: <383c57 at gmail.com>
4
+
5
+
6
+from base import ExecutableService
7
+import re
8
+
9
+# default module values (can be overridden per job in `config`)
10
+priority = 60000
11
+retries = 5
12
+update_every = 30
13
+
14
+# charts order (can be overridden if you want less charts, or different order)
15
+ORDER = ['queries', 'zones', 'protocol', 'type', 'transfer', 'rcode']
16
+
17
+CHARTS = {
18
+ 'queries': {
19
+ 'options': [
20
+ None, "queries", 'queries/s', 'queries', 'nsd.queries', 'line'],
21
+ 'lines': [
22
+ ['num.queries', 'queries', 'incremental'],]},
23
+ 'zones': {
24
+ 'options': [
25
+ None, "zones", 'zones', 'zones', 'nsd.zones', 'stacked'],
26
+ 'lines': [
27
+ ['zone.master', 'master', 'absolute'],
28
+ ['zone.slave', 'slave', 'absolute'],]},
29
+ 'protocol': {
30
+ 'options': [
31
+ None, "protocol", 'queries/s', 'protocol', 'nsd.protocols', 'stacked'],
32
+ 'lines': [
33
+ ['num.udp', 'udp', 'incremental'],
34
+ ['num.udp6', 'udp6', 'incremental'],
35
+ ['num.tcp', 'tcp', 'incremental'],
36
+ ['num.tcp6', 'tcp6', 'incremental'],]},
37
+ 'type': {
38
+ 'options': [
39
+ None, "query type", 'queries/s', 'query type', 'nsd.type', 'stacked'],
40
+ 'lines': [
41
+ ['num.type.A', 'A', 'incremental'],
42
+ ['num.type.NS', 'NS', 'incremental'],
43
+ ['num.type.CNAME', 'CNAME', 'incremental'],
44
+ ['num.type.SOA', 'SOA', 'incremental'],
45
+ ['num.type.PTR', 'PTR', 'incremental'],
46
+ ['num.type,HINFO', 'HINFO', 'incremental'],
47
+ ['num.type.MX', 'MX', 'incremental'],
48
+ ['num.type.NAPTR', 'NAPTR', 'incremental'],
49
+ ['num.type.TXT', 'TXT', 'incremental'],
50
+ ['num.type.AAAA', 'AAAA', 'incremental'],
51
+ ['num.type.SRV', 'SRV', 'incremental'],
52
+ ['num.type.TYPE255', 'ANY', 'incremental'],]},
53
+ 'transfer': {
54
+ 'options': [
55
+ None, "transfer", 'queries/s', 'transfer', 'nsd.transfer', 'stacked'],
56
+ 'lines': [
57
+ ['num.opcode.NOTIFY', 'NOTIFY', 'incremental'],
58
+ ['num.type.TYPE252', 'AXFR', 'incremental'],]},
59
+ 'rcode': {
60
+ 'options': [
61
+ None, "return code", 'queries/s', 'return code', 'nsd.rcode', 'stacked'],
62
+ 'lines': [
63
+ ['num.rcode.NOERROR', 'NOERROR', 'incremental'],
64
+ ['num.rcode.FORMERR', 'FORMERR', 'incremental'],
65
+ ['num.rcode.SERVFAIL', 'SERVFAIL', 'incremental'],
66
+ ['num.rcode.NXDOMAIN', 'NXDOMAIN', 'incremental'],
67
+ ['num.rcode.NOTIMP', 'NOTIMP', 'incremental'],
68
+ ['num.rcode.REFUSED', 'REFUSED', 'incremental'],
69
+ ['num.rcode.YXDOMAIN', 'YXDOMAIN', 'incremental'],]}
70
+}
71
+
72
+
73
+class Service(ExecutableService):
74
+ def __init__(self, configuration=None, name=None):
75
+ ExecutableService.__init__(
76
+ self, configuration=configuration, name=name)
77
+ self.command = "nsd-control stats_noreset"
78
+ self.order = ORDER
79
+ self.definitions = CHARTS
80
+ self.regex = re.compile(r'([A-Za-z0-9.]+)=(\d+)')
81
+
82
+ def _get_data(self):
83
+ try:
84
+ lines = self._get_raw_data()
85
+ r = self.regex
86
+ stats = {k: int(v) for k, v in r.findall(''.join(lines))}
87
+ stats.setdefault('num.opcode.NOTIFY', 0)
88
+ stats.setdefault('num.type.TYPE252', 0)
89
+ stats.setdefault('num.type.TYPE255', 0)
90
+ return stats
91
+ except Exception:
92
+ return None