allowing to check custom MBeans
Message-ID: <5863e485.BULoVDSoiKy107K4%kb(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Module: check_mk
Branch: master
Commit: c5f67f46536a5344a320455e293da2b379eae400
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c5f67f46536a53…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue Dec 20 08:55:21 2016 +0100
mk_jolokia: Added section for future jolokia_generic check, allowing to check custom
MBeans
Change-Id: I95a3846a617de93c3a8916ae0d52b6e1bc66d8bc
---
agents/plugins/mk_jolokia | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/agents/plugins/mk_jolokia b/agents/plugins/mk_jolokia
index a54a342..0c8af4c 100755
--- a/agents/plugins/mk_jolokia
+++ b/agents/plugins/mk_jolokia
@@ -345,6 +345,39 @@ def query_instance(inst):
# Simply ignore exceptions. Need to be removed for debugging
continue
+ if custom_vars:
+ sys.stdout.write('<<<jolokia_generic>>>\n')
+ for var in custom_vars:
+ mbean, path, title, itemspec, do_search, value_type = var
+ queries = []
+ if do_search:
+ if mbean in mbean_search_results:
+ paths = mbean_search_results[mbean]
+ else:
+ paths = fetch_var(inst["protocol"],
inst["server"], inst["port"], mbean,
+ inst["suburi"], "", None, None,
None, function="search")[0][1]
+ mbean_search_results[mbean] = paths
+
+ for mbean_exp in paths:
+ queries.append( (inst, "%s/%s" % (urllib2.quote(mbean_exp),
path), path,
+ itemspec, inst_add=mbean_exp) )
+ else:
+ queries.append( (inst, mbean + "/" + path, title, itemspec) )
+
+ for inst, mbean_path, title, itemspec in queries:
+ try:
+ for out_item, out_title, out_value in fetch_metric(inst, mbean_path,
title, itemspec):
+ sys.stdout.write("%s %s %s %s\n" % (out_item,
out_title, out_value, value_type) )
+ except IOError:
+ return
+ except socket.timeout:
+ return
+ except:
+ if opt_debug:
+ raise
+ # Simply ignore exceptions. Need to be removed for debugging
+ continue
+
# Default configuration for all instances
protocol = "http"
@@ -438,6 +471,8 @@ specific_vars = {
# the global configuration values can be overridden.
instances = [{}]
+custom_vars = []
+
conffile = os.getenv("MK_CONFDIR", "/etc/check_mk") +
"/jolokia.cfg"
if os.path.exists(conffile):