Module: check_mk
Branch: master
Commit: 7a6546083ab368a97e05710fbdd9f10b7a88053e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7a6546083ab368…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Aug 25 10:04:58 2016 +0200
3743 SEC mk_jolokia: Use JSON library to parse JSON output in lieu of eval()
Previously, the mk_jolokia agent plugin would try to parse the JSON data
returned from jolokia with eval(). Now, the simplejson or json python
libraries are a prerequisite for the plugin to work.
---
.werks/3743 | 12 ++++++++++++
ChangeLog | 2 ++
agents/plugins/mk_jolokia | 12 ++++--------
checks/jolokia_info | 5 +++++
4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/.werks/3743 b/.werks/3743
new file mode 100644
index 0000000..aa07db4
--- /dev/null
+++ b/.werks/3743
@@ -0,0 +1,12 @@
+Title: mk_jolokia: Use JSON library to parse JSON output in lieu of eval()
+Level: 1
+Component: checks
+Class: security
+Compatible: incomp
+State: unknown
+Version: 1.4.0i1
+Date: 1472111893
+
+Previously, the mk_jolokia agent plugin would try to parse the JSON data
+returned from jolokia with eval(). Now, the simplejson or json python
+libraries are a prerequisite for the plugin to work.
diff --git a/ChangeLog b/ChangeLog
index 6df1a19..bf35bd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -138,6 +138,8 @@
* 3790 f5_bigip_cluster_status: New check to monitor integrity of active/active and
standby/active clusters
* 3791 f5_bigip_vserver: now reports lots of additional performance data...
NOTE: Please refer to the migration notes!
+ * 3743 SEC: mk_jolokia: Use JSON library to parse JSON output in lieu of eval()...
+ NOTE: Please refer to the migration notes!
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/agents/plugins/mk_jolokia b/agents/plugins/mk_jolokia
index 1657d79..3b29dff 100755
--- a/agents/plugins/mk_jolokia
+++ b/agents/plugins/mk_jolokia
@@ -33,7 +33,9 @@ except ImportError:
try:
import json
except ImportError:
- json = None
+ sys.stdout.write("<<<jolokia_info>>>\n")
+ sys.stdout.write("Error: Missing JSON library for Agent Plugin
mk_jolokia\n")
+ exit()
opt_verbose = '--verbose' in sys.argv
opt_debug = '--debug' in sys.argv
@@ -151,13 +153,7 @@ def fetch_var(protocol, server, port, path, suburi, itemspec,
service_url, servi
json_data = fetch_url_get(base_url, path, function)
try:
- true = True
- false = False
- null = None
- if json:
- obj = json.loads(json_data)
- else:
- obj = eval(json_data)
+ obj = json.loads(json_data)
except Exception, e:
sys.stderr.write('ERROR: Invalid json code (%s)\n' % e)
sys.stderr.write(' Response %s\n' % json_data)
diff --git a/checks/jolokia_info b/checks/jolokia_info
index f44ce88..3dac7d0 100644
--- a/checks/jolokia_info
+++ b/checks/jolokia_info
@@ -28,6 +28,11 @@ def inventory_jolokia_info(info):
return [ (line[0], None) for line in info if line[1] != 'ERROR' ]
def check_jolokia_info(item, _no_params, info):
+
+ # Inform user of non-working agent plugin, eg. missing json library
+ if info[0][0] == "Error:":
+ return 3, " ".join(info[0])
+
for line in info:
if line[0] == item:
if line[1] == 'ERROR' or len(line) < 4: