Module: check_mk
Branch: master
Commit: e7c811bc2a3b7723c97bd9b1b5f0cf6537a8b3f9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e7c811bc2a3b77…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 21 10:07:54 2019 +0100
Detect error messages from web service
When the webservice detects an error -- such as an authentication problem --
it does not output a JSON tree by a string starting with ERROR: This is now
correctly being detected and the error is output as check output, rather than
a nasty JSON parsing exception
---
active_checks/check_bi_aggr | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/active_checks/check_bi_aggr b/active_checks/check_bi_aggr
index ae7ab10..c16337f 100755
--- a/active_checks/check_bi_aggr
+++ b/active_checks/check_bi_aggr
@@ -199,6 +199,10 @@ except Exception, e:
'ERROR: Exception while opening URL: %s - %s\n%s' % (url, e,
traceback.format_exc()))
sys.exit(3)
+if json.startswith("ERROR:"):
+ sys.stdout.write(json.rstrip() + "\n")
+ sys.exit(3)
+
try:
obj = eval(json)
except Exception, e: