bind_rndc plugin: now uses PATH env variable to find rndc binary
Ilya committed
Jan 31, 2017 at 12:26 UTC
c71bf86afa5c756f255e6b26038014ada4ca572f
1 file changed
+3
-8
python.d/bind_rndc.chart.py
+3
-8
@@ -4,7 +4,7 @@
4
5
from base import SimpleService
6
from re import compile, findall
7
-from os.path import getsize, isfile, split
7
+from os.path import getsize, split
8
from os import access as is_accessible, R_OK
9
from subprocess import Popen
10
@@ -12,7 +12,6 @@ priority = 60000
12
retries = 60
13
update_every = 30
14
15
-DIRECTORIES = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/']
15
NMS = ['requests', 'responses', 'success', 'auth_answer', 'nonauth_answer', 'nxrrset', 'failure',
16
'nxdomain', 'recursion', 'duplicate', 'rejections']
17
QUERIES = ['RESERVED0', 'A', 'NS', 'CNAME', 'SOA', 'PTR', 'MX', 'TXT', 'X25', 'AAAA', 'SRV', 'NAPTR',
@@ -29,16 +28,12 @@ class Service(SimpleService):
28
# 'Cache DB RRsets', 'Socket I/O Statistics']
29
self.options = ['Name Server Statistics', 'Incoming Queries', 'Outgoing Queries']
30
self.regex_options = [r'(%s(?= \+\+)) \+\+([^\+]+)' % option for option in self.options]
32
- try:
33
- self.rndc = [''.join([directory, 'rndc']) for directory in DIRECTORIES
34
- if isfile(''.join([directory, 'rndc']))][0]
35
- except IndexError:
36
- self.rndc = False
31
+ self.rndc = self.find_binary('rndc')
32
33
def check(self):
34
# We cant start without 'rndc' command
35
if not self.rndc:
41
- self.error('Command "rndc" not found')
36
+ self.error('Can\'t locate \'rndc\' binary or binary is not executable by netdata')
37
return False
38
39
# We cant start if stats file is not exist or not readable by netdata user