diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2017-04-30 16:09:37 +0000 |
---|---|---|
committer | Federico Ceratto <federico.ceratto@gmail.com> | 2017-04-30 18:09:45 +0000 |
commit | bed7e5b6a0b9ea0ddfc76c6f77eb91df81b92521 (patch) | |
tree | 519e5945ec0db75bfb50583539caa408a5819e87 /python.d/freeradius.chart.py | |
parent | Temporarily disable signature checking (diff) | |
download | netdata-bed7e5b6a0b9ea0ddfc76c6f77eb91df81b92521.tar.xz netdata-bed7e5b6a0b9ea0ddfc76c6f77eb91df81b92521.zip |
New upstream version 1.6.0+dfsg
Diffstat (limited to 'python.d/freeradius.chart.py')
-rw-r--r-- | python.d/freeradius.chart.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/python.d/freeradius.chart.py b/python.d/freeradius.chart.py index 2ac280f0..f3de1573 100644 --- a/python.d/freeradius.chart.py +++ b/python.d/freeradius.chart.py @@ -3,7 +3,6 @@ # Author: l2isbad from base import SimpleService -from os.path import isfile from re import findall from subprocess import Popen, PIPE @@ -11,7 +10,6 @@ from subprocess import Popen, PIPE priority = 60000 retries = 60 update_every = 15 -directories = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/'] # charts order (can be overridden if you want less charts, or different order) ORDER = ['authentication', 'accounting', 'proxy-auth', 'proxy-acct'] @@ -62,27 +60,23 @@ class Service(SimpleService): self.acct = self.configuration.get('acct', False) self.proxy_auth = self.configuration.get('proxy_auth', False) self.proxy_acct = self.configuration.get('proxy_acct', False) - try: - self.echo = [''.join([directory, 'echo']) for directory in directories if isfile(''.join([directory, 'echo']))][0] - self.radclient = [''.join([directory, 'radclient']) for directory in directories if isfile(''.join([directory, 'radclient']))][0] - except IndexError: - self.echo = [] - self.radclient = [] + self.echo = self.find_binary('echo') + self.radclient = self.find_binary('radclient') self.sub_echo = [self.echo, 'Message-Authenticator = 0x00, FreeRADIUS-Statistics-Type = 15, Response-Packet-Type = Access-Accept'] self.sub_radclient = [self.radclient, '-r', '1', '-t', '1', ':'.join([self.host, self.port]), 'status', self.secret] def check(self): if not all([self.echo, self.radclient]): - self.error('Command radclient not found') + self.error('Can\'t locate \'radclient\' binary or binary is not executable by netdata') return False if self._get_raw_data(): chart_choice = [True, bool(self.acct), bool(self.proxy_auth), bool(self.proxy_acct)] self.order = [chart for chart, choice in zip(ORDER, chart_choice) if choice] - self.definitions = {k:v for k, v in CHARTS.items() if k in self.order} + self.definitions = dict([chart for chart in CHARTS.items() if chart[0] in self.order]) self.info('Plugin was started succesfully') return True else: - self.error('Request returned no data. Is server alive? Used options: host {}, port {}, secret {}'.format(self.host, self.port, self.secret)) + self.error('Request returned no data. Is server alive? Used options: host {0}, port {1}, secret {2}'.format(self.host, self.port, self.secret)) return False @@ -92,7 +86,7 @@ class Service(SimpleService): :return: dict """ result = self._get_raw_data() - return {k.lower():int(v) for k, v in findall(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)', result)} + return dict([(elem[0].lower(), int(elem[1])) for elem in findall(r'((?<=-)[AP][a-zA-Z-]+) = (\d+)', result)]) def _get_raw_data(self): """ |