Include existing system PATH in nagios_wrapper

Certain Nagios checks may be written in a manner that assumes common
executable-containing directories (like /bin or /usr/bin, for example)
to exist in $PATH, but in nagios_wrapper, the PATH is blanked out, except
when replaced with the path(s) specified in the init_config's check_path.
For most/all standard Nagios checks, this is fine, but for many others,
assuming a PATH that includes the likes of /bin /usr/bin, /usr/local/bin,
etc. would cause the check to fail.

One solution may be to require all Nagios checks to specify the full
path to the executables they call, but the more accommodating fix would
be include the system PATH as well as check_path, as proposed in this
patch.

Change-Id: I943c58a579bb3440c41f8b5059c2128262d24bdf
This commit is contained in:
David Schroeder 2015-11-25 16:32:24 -07:00
parent 1d72451aad
commit 124f8a0a92
1 changed files with 4 additions and 1 deletions

View File

@ -55,7 +55,10 @@ class WrapNagios(ServicesCheck):
dimensions.update({'target_host': socket.getfqdn()})
extra_path = self.init_config.get('check_path')
env = {"PATH": extra_path} if extra_path else None
env = {}
env['PATH'] = os.environ['PATH']
if extra_path:
env['PATH'] = "{0}:{1}".format(extra_path, env['PATH'])
last_run_path = self.init_config.get('temp_file_path')
# Use a default last_run_file if no temp_file is specified in the YAML