Module: check_mk
Branch: master
Commit: 47fe70da86a965fcfc99238b9a884303269777df
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=47fe70da86a965…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 25 10:32:17 2015 +0200
Fixed check result sanitize in case of single yielded result
---
modules/check_mk_base.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 4b002db..2e4e8e3 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1670,7 +1670,11 @@ def sanitize_yield_check_result(result, is_snmp):
# Simple check with no separate subchecks (yield wouldn't have been neccessary
here!)
if len(subresults) == 1:
- return sanitize_tuple_check_result(subresults[0])
+ state, infotext, perfdata = sanitize_tuple_check_result(subresults[0],
allow_missing_infotext=True)
+ if infotext == None:
+ return state, u"", perfdata
+ else:
+ 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
@@ -1683,6 +1687,7 @@ def sanitize_yield_check_result(result, is_snmp):
for subresult in subresults:
st, text, perf = sanitize_tuple_check_result(subresult,
allow_missing_infotext=True)
+ # FIXME/TODO: Why is the state only aggregated when having text != None?
if text != None:
infotexts.append(text + ["", "(!)", "(!!)",
"(?)"][st])
if st == 2 or status == 2:
@@ -1710,14 +1715,13 @@ def sanitize_tuple_check_result(result,
allow_missing_infotext=False):
state, infotext = result
perfdata = None
- if not allow_missing_infotext or infotext != None:
- infotext = sanitize_check_result_infotext(infotext)
+ infotext = sanitize_check_result_infotext(infotext, allow_missing_infotext)
return state, infotext, perfdata
-def sanitize_check_result_infotext(infotext):
- if infotext == None:
+def sanitize_check_result_infotext(infotext, allow_missing_infotext):
+ if infotext == None and not allow_missing_infotext:
raise MKGeneralException("Invalid infotext from check:
\"None\"")
if type(infotext) == str: