Skip to content

Commit d6c9b19

Browse files
committed
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.
1 parent 24eed07 commit d6c9b19

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

python.d/python_modules/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,22 +868,22 @@ def check(self):
868868
self.command = str(self.configuration['command'])
869869
except (KeyError, TypeError):
870870
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(' ')
872873

873-
for arg in command[1:]:
874+
for arg in self.command[1:]:
874875
if any(st in arg for st in self.bad_substrings):
875876
self.error("Bad command argument:" + " ".join(self.command[1:]))
876877
return False
877878

878879
# 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]
880881
if self._get_raw_data() is None:
881882
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]):
884885
break
885886

886-
self.command = command
887887
if self._get_data() is None or len(self._get_data()) == 0:
888888
self.error("Command", self.command, "returned no data")
889889
return False

0 commit comments

Comments
 (0)