freeradius plugin: now uses PATH env variable to find radclient and echo binary
Ilya committed
Jan 31, 2017 at 12:25 UTC
d3c9af1c38d49650783769483c574a48e8a2649f
1 file changed
+3
-9
python.d/freeradius.chart.py
+3
-9
@@ -3,7 +3,6 @@
3
# Author: l2isbad
4
5
from base import SimpleService
6
-from os.path import isfile
6
from re import findall
7
from subprocess import Popen, PIPE
8
@@ -11,7 +10,6 @@ from subprocess import Popen, PIPE
10
priority = 60000
11
retries = 60
12
update_every = 15
14
-directories = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/']
13
14
# charts order (can be overridden if you want less charts, or different order)
15
ORDER = ['authentication', 'accounting', 'proxy-auth', 'proxy-acct']
@@ -62,18 +60,14 @@ class Service(SimpleService):
60
self.acct = self.configuration.get('acct', False)
61
self.proxy_auth = self.configuration.get('proxy_auth', False)
62
self.proxy_acct = self.configuration.get('proxy_acct', False)
65
- try:
66
- self.echo = [''.join([directory, 'echo']) for directory in directories if isfile(''.join([directory, 'echo']))][0]
67
- self.radclient = [''.join([directory, 'radclient']) for directory in directories if isfile(''.join([directory, 'radclient']))][0]
68
- except IndexError:
69
- self.echo = []
70
- self.radclient = []
63
+ self.echo = self.find_binary('echo')
64
+ self.radclient = self.find_binary('radclient')
65
self.sub_echo = [self.echo, 'Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 15, Response-Packet-Type = Access-Accept']
66
self.sub_radclient = [self.radclient, '-r', '1', '-t', '1', ':'.join([self.host, self.port]), 'status', self.secret]
67
68
def check(self):
69
if not all([self.echo, self.radclient]):
76
- self.error('Command radclient not found')
70
+ self.error('Can\'t locate \'radclient\' binary or binary is not executable by netdata')
71
return False
72
if self._get_raw_data():
73
chart_choice = [True, bool(self.acct), bool(self.proxy_auth), bool(self.proxy_acct)]