Module: check_mk
Branch: master
Commit: 12b7213f68752408111b8181be95a824e09252bf
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=12b7213f687524…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Oct 11 16:45:14 2018 +0200
added #WK6556
Change-Id: I9a9972dc1e86cb92526b04bcec8c3fed036f2fb1
---
.werks/6665 | 14 ++++++++++++++
cmk_base/checking.py | 28 ++++++++++------------------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/.werks/6665 b/.werks/6665
new file mode 100644
index 0000000..b522304
--- /dev/null
+++ b/.werks/6665
@@ -0,0 +1,14 @@
+Title: Checks may now yield the value None as plugin output
+Level: 1
+Component: checks
+Class: feature
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1539174883
+
+A check usually returns a state, followed by text and optional perfdata.
+The plugin output was not well formatted, in case yield returned an empty string.
+It is now possible to yield None as plugin output, which instructs the Check API
+to ignore this value.
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 6dfdf1c..bb7c81e 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -421,33 +421,25 @@ def _sanitize_yield_check_result(result, is_snmp):
if not subresults:
return _item_not_found(is_snmp)
- # Simple check with no separate subchecks (yield wouldn't have been neccessary
here!)
- if len(subresults) == 1:
- state, infotext, perfdata = _sanitize_tuple_check_result(subresults[0],
allow_missing_infotext=True)
- # just to be safe - infotext should allways be a string
- if infotext == None:
- return state, u"", perfdata
-
- return state, infotext, perfdata
# Several sub results issued with multiple yields. Make that worst sub check
# decide the total state, join the texts and performance data. Subresults with
# an infotext of None are used for adding performance data.
- else:
- perfdata = []
- infotexts = []
- status = 0
+ perfdata = []
+ infotexts = []
+ status = 0
- for subresult in subresults:
- st, text, perf = _sanitize_tuple_check_result(subresult,
allow_missing_infotext=True)
+ for subresult in subresults:
+ st, text, perf = _sanitize_tuple_check_result(subresult,
allow_missing_infotext=True)
+ status = cmk_base.utils.worst_service_state(st, status)
+ if text != None:
infotexts.append(text + ["", "(!)", "(!!)",
"(?)"][st])
- status = cmk_base.utils.worst_service_state(st, status)
- if perf != None:
- perfdata += subresult[2]
+ if perf != None:
+ perfdata += perf
- return status, ", ".join(i for i in infotexts if i), perfdata
+ return status, ", ".join(infotexts), perfdata
def _item_not_found(is_snmp):