From 2ccc43132bca058d0e6baa219022b0db42f937cb Mon Sep 17 00:00:00 2001 From: david raistrick Date: Thu, 22 Sep 2016 17:50:09 -0400 Subject: [PATCH 1/2] fix error handling output for userscripts collector another fix for error cases: before: if stderr is returned, but no stdout, we bail out before we report the stderr content - throwing away the error message that may only be reproducible in the conditions of the collector. after: if stderr is returned, log it regardless of if we bail. log it as warning, not error, since it's non-blocking. also removed "skipping" from the proc.returncode - we dont actually bail unless there's no stdout, regardless of return code, so dont tell the user we are. --- src/collectors/userscripts/userscripts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collectors/userscripts/userscripts.py b/src/collectors/userscripts/userscripts.py index dfb304fbb..006373856 100644 --- a/src/collectors/userscripts/userscripts.py +++ b/src/collectors/userscripts/userscripts.py @@ -76,14 +76,14 @@ def collect(self): (absolutescriptpath, e)) continue if proc.returncode: - self.log.error("%s return exit value %s; skipping" % + self.log.error("%s return exit value %s" % (absolutescriptpath, proc.returncode)) + if err: + self.log.warning("%s return error output: %s" % + (absolutescriptpath, err)) if not out: self.log.info("%s return no output" % absolutescriptpath) continue - if err: - self.log.error("%s return error output: %s" % - (absolutescriptpath, err)) # Use filter to remove empty lines of output for line in filter(None, out.split('\n')): # Ignore invalid lines From 74dacb508023e09e03e5d990bc69b75e6a96cbbd Mon Sep 17 00:00:00 2001 From: david raistrick Date: Thu, 22 Sep 2016 17:56:33 -0400 Subject: [PATCH 2/2] update userscripts log message for no stdout also update log message for the no stdout case: make it error, not info, since we bail - and log that we skip. --- src/collectors/userscripts/userscripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collectors/userscripts/userscripts.py b/src/collectors/userscripts/userscripts.py index 006373856..63e9564d6 100644 --- a/src/collectors/userscripts/userscripts.py +++ b/src/collectors/userscripts/userscripts.py @@ -82,7 +82,7 @@ def collect(self): self.log.warning("%s return error output: %s" % (absolutescriptpath, err)) if not out: - self.log.info("%s return no output" % absolutescriptpath) + self.log.error("%s returned no output; skipping" % absolutescriptpath) continue # Use filter to remove empty lines of output for line in filter(None, out.split('\n')):