@cryptotaxi247 / netdata-1 / commits / 33f9a3193

better check in ExecutableService

paulfantom committed Aug 12, 2016 at 18:54 UTC 33f9a3193b51fe89e45dca3cb6360d12979225b6
1 file changed +6 -6
python.d/python_modules/base.py
+6 -6
@@ -775,20 +775,20 @@ class ExecutableService(SimpleService):
775 self.command = str(self.configuration['command'])
776 except (KeyError, TypeError):
777 self.error("No command specified. Using: '" + self.command + "'")
778 - self.command = self.command.split(' ')
778 + command = self.command.split(' ')
779
780 - for arg in self.command[1:]:
780 + for arg in command[1:]:
781 if any(st in arg for st in self.bad_substrings):
782 self.error("Bad command argument:" + " ".join(self.command[1:]))
783 return False
784 # test command and search for it in /usr/sbin or /sbin when failed
785 - base = self.command[0].split('/')[-1]
785 + base = command[0].split('/')[-1]
786 if self._get_raw_data() is None:
787 for prefix in ['/sbin/', '/usr/sbin/']:
788 - self.command[0] = prefix + base
789 - if os.path.isfile(self.command[0]):
788 + command[0] = prefix + base
789 + if os.path.isfile(command[0]):
790 break
791 -
791 + self.command = command
792 if self._get_data() is None or len(self._get_data()) == 0:
793 self.error("Command", self.command, "returned no data")
794 return False