Module: check_mk
Branch: master
Commit: 54f1fc3df8bee845bc18fce1cfffed529f175e5e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=54f1fc3df8bee8…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri Mar 22 07:38:59 2019 +0100
mk_jolokia: increase debug capability
Change-Id: I67fe1e997071b6babc9fea49a571c3ab2f878906
---
agents/plugins/mk_jolokia.py | 9 +++++++--
tests/unit/plugins/test_mk_jolokia.py | 2 ++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/agents/plugins/mk_jolokia.py b/agents/plugins/mk_jolokia.py
index bfe76e8..6e6ec35 100755
--- a/agents/plugins/mk_jolokia.py
+++ b/agents/plugins/mk_jolokia.py
@@ -52,8 +52,8 @@ except ImportError as import_error:
" Please install it on the monitored system.")
sys.exit(1)
-VERBOSE = '--verbose' in sys.argv
-DEBUG = '--debug' in sys.argv
+VERBOSE = sys.argv.count('--verbose') + sys.argv.count('-v') + 2 *
sys.argv.count('-vv')
+DEBUG = sys.argv.count('--debug')
MBEAN_SECTIONS = {
'jvm_threading': ("java.lang:type=Threading",),
@@ -342,6 +342,11 @@ class JolokiaInstance(object):
def validate_response(raw):
'''return loaded response or raise exception'''
+ if VERBOSE > 1:
+ sys.stderr.write("DEBUG: %r:\n"
+ "DEBUG: headers: %r\n"
+ "DEBUG: content: %r\n\n" % (raw, raw.headers,
raw.content))
+
# check the status of the http server
if not 200 <= raw.status_code < 300:
sys.stderr.write("ERROR: HTTP STATUS: %d\n" % raw.status_code)
diff --git a/tests/unit/plugins/test_mk_jolokia.py
b/tests/unit/plugins/test_mk_jolokia.py
index 427f9a1..e51155e 100644
--- a/tests/unit/plugins/test_mk_jolokia.py
+++ b/tests/unit/plugins/test_mk_jolokia.py
@@ -104,6 +104,8 @@ def test_jolokia_yield_configured_instances():
class _MockHttpResponse(object):
def __init__(self, http_status, **kwargs):
self.status_code = http_status
+ self.headers = {}
+ self.content = b'\x00'
self._payload = kwargs
def json(self):