@cryptotaxi247 / netdata-1 / commits / d3ef7dacf

varnish plugin: now uses PATH env variable to find varnishstat binary

Ilya committed Jan 31, 2017 at 12:31 UTC d3ef7dacf7797d076d25624a26a05bc0563c5456
1 file changed +2 -10
python.d/varnish.chart.py
+2 -10
@@ -4,10 +4,8 @@
4
5 from base import SimpleService
6 from re import compile
7 -from os import access as is_executable, X_OK
7 from subprocess import Popen, PIPE
8
10 -
9 # default module values (can be overridden per job in `config`)
10 # update_every = 2
11 priority = 60000
@@ -80,17 +78,11 @@ CHARTS = {'backend_health':
78 'options': [None, 'Varnish uptime', 'seconds', 'Uptime', 'varnish.uptime', 'line']}
79 }
80
83 -DIRECTORIES = ['/bin/', '/usr/bin/', '/sbin/', '/usr/sbin/']
84 -
81
82 class Service(SimpleService):
83 def __init__(self, configuration=None, name=None):
84 SimpleService.__init__(self, configuration=configuration, name=name)
89 - try:
90 - self.varnish = [''.join([directory, 'varnishstat']) for directory in DIRECTORIES
91 - if is_executable(''.join([directory, 'varnishstat']), X_OK)][0]
92 - except IndexError:
93 - self.varnish = False
85 + self.varnish = self.find_binary('varnishstat')
86 self.rgx_all = compile(r'([A-Z]+\.)?([\d\w_.]+)\s+(\d+)')
87 # Could be
88 # VBE.boot.super_backend.pipe_hdrbyte (new)
@@ -104,7 +96,7 @@ class Service(SimpleService):
96 def check(self):
97 # Cant start without 'varnishstat' command
98 if not self.varnish:
107 - self.error('\'varnishstat\' command was not found in %s or not executable by netdata' % DIRECTORIES)
99 + self.error('Can\'t locate \'varnishstat\' binary or binary is not executable by netdata')
100 return False
101
102 # If command is present and we can execute it we need to make sure..