From: Paul Cuzner Date: Wed, 23 Aug 2017 02:52:33 +0000 (+1200) Subject: common: catch stderr output into the stdout pipe X-Git-Tag: v1.0~28^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c4de18bd945e2a05c354f8f7634a72e9f2b1942c;p=cephmetrics.git common: catch stderr output into the stdout pipe Ensure stdout and stderr output is returned to the caller --- diff --git a/collectors/common.py b/collectors/common.py index 5f35915..60b62bf 100644 --- a/collectors/common.py +++ b/collectors/common.py @@ -18,11 +18,12 @@ def os_cmd(command): Issue a command to the OS and return the output. NB. check_output default is shell=False :param command: (str) OS command - :return: (list) command response + :return: (str) command response (lines terminated with \n) """ cmd_list = command.split(' ') if cmd_exists(cmd_list[0]): - cmd_output = subprocess.check_output(cmd_list).rstrip() + cmd_output = subprocess.check_output(cmd_list, + stderr=subprocess.STDOUT).rstrip() return cmd_output else: return ''