powerdns module: powerdns recursor support added
lgz committed
Jul 24, 2018 at 17:45 UTC
32ddd3ce33b21f066f21d4fbf8ce7bee2c213adc
1 file changed
+78
-1
python.d/powerdns.chart.py
+78
-1
@@ -1,6 +1,7 @@
1
# -*- coding: utf-8 -*-
2
# Description: powerdns netdata python.d module
3
-# Author: l2isbad
3
+# Author: Ilya Mashchenko (l2isbad)
4
+# Author: Luke Whitworth
5
# SPDX-License-Identifier: GPL-3.0+
6
7
from json import loads
@@ -45,6 +46,66 @@ CHARTS = {
46
47
}
48
49
+RECURSOR_ORDER = ['questions-in', 'questions-out', 'answer-times', 'timeouts', 'drops', 'cache_usage', 'cache_size']
50
+
51
+RECURSOR_CHARTS = {
52
+ 'questions-in': {
53
+ 'options': [
54
+ None, 'PowerDNS Recursor Questions In', 'count', 'questions', 'powerdns_recursor.questions-in', 'line'],
55
+ 'lines': [
56
+ ['questions', None, 'incremental'],
57
+ ['ipv6-questions', None, 'incremental'],
58
+ ['tcp-questions', None, 'incremental']
59
+ ]},
60
+ 'questions-out': {
61
+ 'options': [
62
+ None, 'PowerDNS Recursor Questions Out', 'count', 'questions', 'powerdns_recursor.questions-out', 'line'],
63
+ 'lines': [
64
+ ['all-outqueries', None, 'incremental'],
65
+ ['ipv6-outqueries', None, 'incremental'],
66
+ ['tcp-outqueries', None, 'incremental'],
67
+ ['throttled-outqueries', None, 'incremental']
68
+ ]},
69
+ 'answer-times': {
70
+ 'options': [
71
+ None, 'PowerDNS Recursor Answer Times', 'count', 'performance', 'powerdns_recursor.answer-times', 'line'],
72
+ 'lines': [
73
+ ['answers-slow', None, 'incremental'],
74
+ ['answers0-1', None, 'incremental'],
75
+ ['answers1-10', None, 'incremental'],
76
+ ['answers10-100', None, 'incremental'],
77
+ ['answers100-1000', None, 'incremental']
78
+ ]},
79
+ 'timeouts': {
80
+ 'options': [
81
+ None, 'PowerDNS Recursor Questions Time', 'count', 'performance', 'powerdns_recursor.timeouts', 'line'],
82
+ 'lines': [
83
+ ['outgoing-timeouts', None, 'incremental'],
84
+ ['outgoing4-timeouts', None, 'incremental'],
85
+ ['outgoing6-timeouts', None, 'incremental']
86
+ ]},
87
+ 'drops': {
88
+ 'options': [None, 'PowerDNS Recursor Drops', 'count', 'performance', 'powerdns_recursor.drops', 'line'],
89
+ 'lines': [
90
+ ['over-capacity-drops', None, 'incremental']
91
+ ]},
92
+ 'cache_usage': {
93
+ 'options': [None, 'PowerDNS Recursor Cache Usage', 'count', 'cache', 'powerdns_recursor.cache_usage', 'line'],
94
+ 'lines': [
95
+ ['cache-hits', None, 'incremental'],
96
+ ['cache-misses', None, 'incremental'],
97
+ ['packetcache-hits', 'packet-cache-hit', 'incremental'],
98
+ ['packetcache-misses', 'packet-cache-miss', 'incremental']
99
+ ]},
100
+ 'cache_size': {
101
+ 'options': [None, 'PowerDNS Recursor Cache Size', 'count', 'cache', 'powerdns_recursor.cache_size', 'line'],
102
+ 'lines': [
103
+ ['cache-entries', None, 'absolute'],
104
+ ['packetcache-entries', None, 'absolute'],
105
+ ['negcache-entries', None, 'absolute']
106
+ ]}
107
+}
108
+
109
110
class Service(UrlService):
111
def __init__(self, configuration=None, name=None):
@@ -52,8 +113,24 @@ class Service(UrlService):
113
self.order = ORDER
114
self.definitions = CHARTS
115
116
+ def check(self):
117
+ d = self._get_data()
118
+ if not d:
119
+ return False
120
+
121
+ if is_recursor(d):
122
+ self.order = RECURSOR_ORDER
123
+ self.definitions = RECURSOR_CHARTS
124
+ self.module_name = 'powerdns_recursor'
125
+
126
+ return True
127
+
128
def _get_data(self):
129
data = self._get_raw_data()
130
if not data:
131
return None
132
return dict((d['name'], d['value']) for d in loads(data))
133
+
134
+
135
+def is_recursor(d):
136
+ return 'over-capacity-drops' in d and 'tcp-questions' in d