Changed ExecutableService check() to split properly
ExectuableService was splitting the command in the wrong place which was causing it to only be searched in /sbin and /usr/sbin instead of the regular PATH.
Jeff Willette committed
Dec 13, 2016 at 08:04 UTC
d6c9b19c6c9ebe2ef7af7f2d03beb92891ee7844
1 file changed
+6
-6
python.d/python_modules/base.py
+6
-6
@@ -868,22 +868,22 @@ class ExecutableService(SimpleService):
868
self.command = str(self.configuration['command'])
869
except (KeyError, TypeError):
870
self.info("No command specified. Using: '" + self.command + "'")
871
- command = self.command.split(' ')
871
+ # Splitting self.command on every space so subprocess.Popen reads it properly
872
+ self.command = self.command.split(' ')
873
873
- for arg in command[1:]:
874
+ for arg in self.command[1:]:
875
if any(st in arg for st in self.bad_substrings):
876
self.error("Bad command argument:" + " ".join(self.command[1:]))
877
return False
878
879
# test command and search for it in /usr/sbin or /sbin when failed
879
- base = command[0].split('/')[-1]
880
+ base = self.command[0].split('/')[-1]
881
if self._get_raw_data() is None:
882
for prefix in ['/sbin/', '/usr/sbin/']:
882
- command[0] = prefix + base
883
- if os.path.isfile(command[0]):
883
+ self.command[0] = prefix + base
884
+ if os.path.isfile(self.command[0]):
885
break
886
886
- self.command = command
887
if self._get_data() is None or len(self._get_data()) == 0:
888
self.error("Command", self.command, "returned no data")
889
return False