summaryrefslogtreecommitdiffstats
path: root/python.d/bind_rndc.chart.py
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
commit61aedf201c2c4bf0e5aa4db32e74f4d860b88593 (patch)
treebcf4f9a0cd8bc2daf38b2ff9f29bfcc1e5ed8968 /python.d/bind_rndc.chart.py
parentNew upstream version 1.8.0+dfsg (diff)
downloadnetdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.tar.xz
netdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.zip
New upstream version 1.9.0+dfsgupstream/1.9.0+dfsg
Diffstat (limited to 'python.d/bind_rndc.chart.py')
-rw-r--r--python.d/bind_rndc.chart.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/python.d/bind_rndc.chart.py b/python.d/bind_rndc.chart.py
index 5a9749287..cc96659b2 100644
--- a/python.d/bind_rndc.chart.py
+++ b/python.d/bind_rndc.chart.py
@@ -2,11 +2,13 @@
# Description: bind rndc netdata python.d module
# Author: l2isbad
-from os.path import getsize
-from os import access, R_OK
-from subprocess import Popen
+import os
+
from collections import defaultdict
-from base import SimpleService
+from subprocess import Popen
+
+from bases.collection import find_binary
+from bases.FrameworkServices.SimpleService import SimpleService
priority = 60000
retries = 60
@@ -94,7 +96,7 @@ class Service(SimpleService):
self.order = ORDER
self.definitions = CHARTS
self.named_stats_path = self.configuration.get('named_stats_path', '/var/log/bind/named.stats')
- self.rndc = self.find_binary('rndc')
+ self.rndc = find_binary('rndc')
self.data = dict(nms_requests=0, nms_responses=0, nms_failure=0, nms_auth=0,
nms_non_auth=0, nms_nxrrset=0, nms_success=0, nms_nxdomain=0,
nms_recursion=0, nms_duplicate=0, nms_rejected_queries=0,
@@ -102,10 +104,10 @@ class Service(SimpleService):
def check(self):
if not self.rndc:
- self.error('Can\'t locate \'rndc\' binary or binary is not executable by netdata')
+ self.error('Can\'t locate "rndc" binary or binary is not executable by netdata')
return False
- if not access(self.named_stats_path, R_OK):
+ if not (os.path.isfile(self.named_stats_path) and os.access(self.named_stats_path, os.R_OK)):
self.error('Cannot access file %s' % self.named_stats_path)
return False
@@ -124,7 +126,7 @@ class Service(SimpleService):
"""
result = dict()
try:
- current_size = getsize(self.named_stats_path)
+ current_size = os.path.getsize(self.named_stats_path)
run_rndc = Popen([self.rndc, 'stats'], shell=False)
run_rndc.wait()
@@ -159,12 +161,12 @@ class Service(SimpleService):
parsed_key, chart_name = elem[0], elem[1]
for dimension_id, value in queries_mapper(data=parsed[parsed_key],
add=chart_name[:9]).items():
+
if dimension_id not in self.data:
dimension = dimension_id.replace(chart_name[:9], '')
- self._add_new_dimension(dimension_id=dimension_id,
- dimension=dimension,
- chart_name=chart_name,
- priority=self.priority + self.order.index(chart_name))
+ if dimension_id not in self.charts[chart_name]:
+ self.charts[chart_name].add_dimension([dimension_id, dimension, 'incremental'])
+
self.data[dimension_id] = value
self.data['stats_size'] = raw_data['size']