Module: check_mk
Branch: master
Commit: 4b7a09b0ef5cbd97534abcdef4f462a04ec6e316
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4b7a09b0ef5cbd…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Sep 20 14:57:25 2018 +0200
6603 FIX CRE: Fixed Check_MK service crash if a check plugin is unknown to the check
context
Change-Id: I6e4103da535162f18d8eb2cd51948f42b0239db4
---
.werks/6603 | 19 +++++++++++++++++++
cmk_base/check_table.py | 11 ++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/6603 b/.werks/6603
new file mode 100644
index 0000000..213796c
--- /dev/null
+++ b/.werks/6603
@@ -0,0 +1,19 @@
+Title: CRE: Fixed Check_MK service crash if a check plugin is unknown to the check
context
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1537441766
+
+A host has discovered a set of check plugin names which are triggered by the
+Check_MK service. If the agent type of this host changes without performing a
+rediscovery afterwards and the configuration changes are activated then there
+may be new or vanished check plugins which are unknown to the current check
+context. This leads to a KeyError of the Check_MK service.
+
+Now if a check plugin is unknown to the current check context Check_MK ignores
+this check plugin. Aside from that the Check_MK Discovery service reports about
+vanished or unmonitored serices.
diff --git a/cmk_base/check_table.py b/cmk_base/check_table.py
index 2a28d16..03d6dd4 100644
--- a/cmk_base/check_table.py
+++ b/cmk_base/check_table.py
@@ -78,14 +78,19 @@ def get_check_table(hostname, remove_duplicates=False,
use_cache=True,
return is_checkname_valid_cache[the_id]
passed = True
+ if checkname not in config.check_info:
+ passed = False
+
# Skip SNMP checks for non SNMP hosts (might have been discovered before with
other
# agent setting. Remove them without rediscovery). Same for agent based checks.
- if not config.is_snmp_host(hostname) and
cmk_base.check_utils.is_snmp_check(checkname) and \
+ elif not config.is_snmp_host(hostname) and
cmk_base.check_utils.is_snmp_check(checkname) and \
(not config.has_management_board(hostname) or
config.management_protocol_of(hostname) != "snmp"):
- passed = False
- if not config.is_tcp_host(hostname) and not
piggyback.has_piggyback_raw_data(config.piggyback_max_cachefile_age, hostname) \
+ passed = False
+
+ elif not config.is_tcp_host(hostname) and not
piggyback.has_piggyback_raw_data(config.piggyback_max_cachefile_age, hostname) \
and cmk_base.check_utils.is_tcp_check(checkname):
passed = False
+
is_checkname_valid_cache[the_id] = passed
return passed