]> arthur.barton.de Git - netdata.git/commitdiff
varnish plugin: now uses PATH env variable to find varnishstat binary
authorIlya <ilyamaschenko@gmail.com>
Tue, 31 Jan 2017 03:31:02 +0000 (12:31 +0900)
committerIlya <ilyamaschenko@gmail.com>
Tue, 31 Jan 2017 03:31:02 +0000 (12:31 +0900)
python.d/varnish.chart.py

index 4b4daddd24d32d77d4a184b5085fe7f854646672..9c1b8de236f98b54b22094dfa0bc183060f45a9e 100644 (file)
@@ -4,10 +4,8 @@
 
 from base import SimpleService
 from re import compile
-from os import access as is_executable, X_OK
 from subprocess import Popen, PIPE
 
-
 # default module values (can be overridden per job in `config`)
 # update_every = 2
 priority = 60000
@@ -80,17 +78,11 @@ CHARTS = {'backend_health':
               'options': [None, 'Varnish uptime', 'seconds', 'Uptime', 'varnish.uptime', 'line']}
 }
 
-DIRECTORIES = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/']
-
 
 class Service(SimpleService):
     def __init__(self, configuration=None, name=None):
         SimpleService.__init__(self, configuration=configuration, name=name)
-        try:
-            self.varnish = [''.join([directory, 'varnishstat']) for directory in DIRECTORIES
-                         if is_executable(''.join([directory, 'varnishstat']), X_OK)][0]
-        except IndexError:
-            self.varnish = False
+        self.varnish = self.find_binary('varnishstat')
         self.rgx_all = compile(r'([A-Z]+\.)?([\d\w_.]+)\s+(\d+)')
         # Could be
         # VBE.boot.super_backend.pipe_hdrbyte (new)
@@ -104,7 +96,7 @@ class Service(SimpleService):
     def check(self):
         # Cant start without 'varnishstat' command
         if not self.varnish:
-            self.error('\'varnishstat\' command was not found in %s or not executable by netdata' % DIRECTORIES)
+            self.error('Can\'t locate \'varnishstat\' binary or binary is not executable by netdata')
             return False
 
         # If command is present and we can execute it we need to make sure..