Module: check_mk
Branch: master
Commit: 2086a3b8fa9bfe304e4c1d96a3cbcd4e96ff8e88
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2086a3b8fa9bfe…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Mon Feb 5 14:06:16 2018 +0100
jolokia_generic: Give a better error message in case of missing data instead of crashing
Change-Id: I3a4e1eb6edc8b7fb53338f56ee75544bdbb23ac7
---
checks/jolokia_generic | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/checks/jolokia_generic b/checks/jolokia_generic
index 81e0abf..bf39f21 100644
--- a/checks/jolokia_generic
+++ b/checks/jolokia_generic
@@ -59,6 +59,8 @@ def inventory_jolokia_generic_string(parsed):
def check_jolokia_generic_string(item, params, parsed):
+ if item not in parsed:
+ return 3, "Item not found in agent output"
value = parsed[item]["value"]
default_status = params.get("default_status", 0)
@@ -95,6 +97,9 @@ def inventory_jolokia_generic_rate(parsed):
def check_jolokia_generic_rate(item, params, parsed):
+ if item not in parsed:
+ yield 3, "Item not found in agent output"
+ return
now = time.time()
rate = get_rate(item, now, parsed[item]["value"])
infotext = "%.1f" % rate
@@ -160,6 +165,9 @@ def inventory_jolokia_generic(parsed):
def check_jolokia_generic(item, params, parsed):
+ if item not in parsed:
+ yield 3, "Item not found in agent output"
+ return
value = parsed[item]["value"]
infotext = "%.1f" % value
perfdata = None