From 54a5387d1510e671ed8d6fa33130e2cfa0e3a2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Cavaill=C3=A9?= Date: Fri, 20 Feb 2015 12:51:29 -0500 Subject: [PATCH] [varnish] fix `varnishadm` subp call with sudo When calling subprocess with an argv-like array, argv[0] needs to be the program to execute and not a sequence of programs like `sudo someprogram`. Otherwise this results in: `OSError: [Errno 2] No such file or directory` when trying to find the `sudo someprogram` executable in the PATH. --- checks.d/varnish.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/checks.d/varnish.py b/checks.d/varnish.py index 8e533aa9a8..597abc2997 100644 --- a/checks.d/varnish.py +++ b/checks.d/varnish.py @@ -98,8 +98,7 @@ def check(self, instance): varnishadm_path = instance.get('varnishadm') if varnishadm_path: secretfile_path = instance.get('secretfile', '/etc/varnish/secret') - varnishadm_path = 'sudo %s' % varnishadm_path - cmd = [varnishadm_path, '-S', secretfile_path, 'debug.health'] + cmd = ['sudo', varnishadm_path, '-S', secretfile_path, 'debug.health'] proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) output, _ = proc.communicate() if output: