Module: check_mk
Branch: master
Commit: 47eeadd6a6cd9d1bb7005774b069dc89dfc7a427
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=47eeadd6a6cd9d…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue Dec 5 18:22:30 2017 +0100
5524 FIX Check API: Fix set_item_state/get_rate/get_counter logic when called from check
functions
In the 1.5.0 branch, the logic encoding the current item in the key for saved data between
checks
was broken for checks with item and parse function. This did not affect the 1.4.0 branch.
Change-Id: I689f8272b6f4e9e17861f845adb75f9a09bfabe0
---
.werks/5524 | 11 +++++++++++
cmk_base/checking.py | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/.werks/5524 b/.werks/5524
new file mode 100644
index 0000000..9698b65
--- /dev/null
+++ b/.werks/5524
@@ -0,0 +1,11 @@
+Title: Check API: Fix set_item_state/get_rate/get_counter logic when called from check
functions
+Level: 2
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1512494383
+Class: fix
+
+In the 1.5.0 branch, the logic encoding the current item in the key for saved data
between checks
+was broken for checks with item and parse function. This did not affect the 1.4.0
branch.
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 81a7861..0b64e34 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -308,6 +308,12 @@ def execute_check(multi_host_sections, hostname, ipaddress,
check_plugin_name, i
x = e.exc_info()
raise x[0], x[1], x[2] # re-raise the original exception to not destory the
trace
+ # We need to set this again, because get_section_content has the side effect of
setting this with
+ # item None if there is a parse function. This would break the entire
set_item/get_rate logic
+ # for checks with items that rely on this being handled by the API.
+ # TODO: Write a regression test for this.
+ item_state.set_item_state_prefix(check_plugin_name, item)
+
# TODO: Move this to a helper function
if section_content is None: # No data for this check type
return False