Module: check_mk
Branch: master
Commit: 0414324fe035e5804781781ac4388d999667fdce
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0414324fe035e5…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Mon Jan 28 12:55:03 2019 +0100
mk_jolokia: stop making up responses
Change-Id: I330dc3765631c8d897d6eebde0ae503c5ce1aa66
---
agents/plugins/mk_jolokia.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/agents/plugins/mk_jolokia.py b/agents/plugins/mk_jolokia.py
index d36b4ad..bae81ba 100755
--- a/agents/plugins/mk_jolokia.py
+++ b/agents/plugins/mk_jolokia.py
@@ -172,6 +172,10 @@ class SkipInstance(RuntimeError):
pass
+class SkipMBean(RuntimeError):
+ pass
+
+
def write_section(name, iterable):
sys.stdout.write('<<<%s:sep(0)>>>\n' % name)
for line in iterable:
@@ -278,18 +282,18 @@ def fetch_url(request_url, data):
sys.stderr.write("DEBUG: Result: %s\n\n" % json_data)
except () if DEBUG else Exception, exc:
sys.stderr.write("ERROR: %s\n\n" % exc)
- return {}
+ raise SkipMBean(exc)
try:
response = json.loads(json_data)
except (ValueError, TypeError), exc:
sys.stderr.write('ERROR: Invalid json code (%s)\n' % exc)
sys.stderr.write(' Response %s\n' % json_data)
- return {}
+ raise SkipMBean(exc)
if response.get('status', 200) != 200:
sys.stderr.write('ERROR: Invalid response when fetching url %r\n' %
request_url)
- return {}
+ raise SkipMBean("HTTP Error (%s)" % response.get('status'))
return response
@@ -307,9 +311,10 @@ def fetch_var(inst, function, path, use_target=False):
try:
return obj['value']
except KeyError:
+ msg = "not found: %s" % path
if VERBOSE:
- sys.stderr.write("ERROR: not found: %s\n" % path)
- return []
+ sys.stderr.write("ERROR: %s\n" % msg)
+ raise SkipMBean(msg)
# convert single values into lists of items in
@@ -412,6 +417,8 @@ def _process_queries(inst, queries):
yield item, out_title, value
except (IOError, socket.timeout):
raise SkipInstance()
+ except SkipMBean:
+ continue
except () if DEBUG else Exception:
continue