Add sbin locations to PATH for sysctl
authorMark Wong <mark@2ndQuadrant.com>
Wed, 13 Dec 2017 19:31:16 +0000 (11:31 -0800)
committerMark Wong <mark@2ndQuadrant.com>
Fri, 5 Jan 2018 19:36:29 +0000 (11:36 -0800)
The location of sysctl may change depending on the distribution.  Try to
add all possible paths to the environment.

client/collectors/linux.py

index 31c042805cffe6754fdfc3061c083f34da12c98f..3a8b231370976fc9281f1bde0e7842d5726f1c7c 100644 (file)
@@ -15,6 +15,10 @@ class LinuxCollector(object):
         self._start_ts = None
         self._end_ts = None
 
+        # Hard code all possible places a packager might install sysctl.
+        self._env = os.environ
+        self._env['PATH'] = ':'.join(['/usr/sbin/', '/sbin/', self._env['PATH']])
+
     def start(self):
         self._start_ts = datetime.now()
 
@@ -80,7 +84,7 @@ class LinuxCollector(object):
         'collect kernel configuration'
 
         log("collecting sysctl")
-        r = run_cmd(['/usr/sbin/sysctl', '-a'])
+        r = run_cmd(['sysctl', '-a'], env=self._env)
 
         return r[1]