Module: check_mk
Branch: master
Commit: f6d8275447ecc5b15d81d6bd29a30b0b9144f9ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f6d8275447ecc5…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Sep 3 11:34:09 2015 +0200
#2567 FIX jolokia_metrics: fixed crash if agent output is missing memory metrics
---
.werks/2567 | 10 ++++++++++
ChangeLog | 1 +
checks/jolokia_metrics | 9 +++++++++
3 files changed, 20 insertions(+)
diff --git a/.werks/2567 b/.werks/2567
new file mode 100644
index 0000000..39d3a09
--- /dev/null
+++ b/.werks/2567
@@ -0,0 +1,10 @@
+Title: jolokia_metrics: fixed crash if agent output is missing memory metrics
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1441272789
+
+
diff --git a/ChangeLog b/ChangeLog
index a818cc6..8c4ffcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -157,6 +157,7 @@
* 2566 FIX: ups_modulys_battery.temp: fixed missing manpage
* 2585 FIX: include file for elecritcal phases handles warn/crit levels correct
* 2576 FIX: symantec_av_updates: fix crash due to missing datetime module, also
handle DD.MM.YYYY date format
+ * 2567 FIX: jolokia_metrics: fixed crash if agent output is missing memory metrics
* 2577 FIX: printer_input, printer_output: Fix exception on Brother NC-340h
Multisite:
diff --git a/checks/jolokia_metrics b/checks/jolokia_metrics
index 2f06d7f..f0c22a9 100644
--- a/checks/jolokia_metrics
+++ b/checks/jolokia_metrics
@@ -142,6 +142,10 @@ def inventory_jolokia_metrics(info, what):
for instance, data in parsed.items():
if what == 'uptime' and "Uptime" not in data:
continue
+ if what == 'mem' and ("HeapMemoryUsage" not in data or
"NonHeapMemoryUsage" not in data
+ or "HeapMemoryMax" not in data or
"NonHeapMemoryMax" not in data):
+ # don't add memory check if we don't have the necessary data
+ continue
yield instance, levels
@@ -259,6 +263,11 @@ def check_jolokia_metrics_mem(item, params, info):
d = parsed[item]
mb = 1024 * 1024.0
+
+ if "HeapMemoryUsage" not in d or "NonHeapMemoryUsage" not in d\
+ or "HeapMemoryMax" not in d or "NonHeapMemoryMax" not in d:
+ return 3, "data in agent output incomplete"
+
heap = saveint(d["HeapMemoryUsage"]) / mb
heapmax = saveint(d.get("HeapMemoryMax",-1)) / mb
nonheap = saveint(d["NonHeapMemoryUsage"]) / mb