Module: check_mk
Branch: master
Commit: baad4089ad5f484b7b653ba575148df036e524a5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=baad4089ad5f48…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Mar 14 16:43:14 2019 +0100
WATO service discovery: Fixed incorrect creation of disable rule for duplicate service
description
Change-Id: Ia3d71d96a23ed281b1f682dc07927c3f0ce6b354
---
.werks/6708 | 14 ++++++++++++++
cmk/gui/wato/pages/services.py | 35 ++++++++++++++++++++++-------------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/.werks/6708 b/.werks/6708
new file mode 100644
index 0000000..20a148a
--- /dev/null
+++ b/.werks/6708
@@ -0,0 +1,14 @@
+Title: WATO service discovery: Fixed incorrect creation of disable rule for duplicate
service description
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1551265114
+
+Different check_types may have the same service description, for example <tt>CPU
utilization</tt>.
+If you created a <tt>Disabled check</tt> rule for some SNMP based CPU
utilization check and
+used the service discovery page, a <tt>Disabled service</tt> rule was
automatically created for this SNMP
+based check. As a side effect, the TCP based CPU utilization check was disabled as
well..
diff --git a/cmk/gui/wato/pages/services.py b/cmk/gui/wato/pages/services.py
index ea48703..bba55ef 100644
--- a/cmk/gui/wato/pages/services.py
+++ b/cmk/gui/wato/pages/services.py
@@ -666,7 +666,8 @@ class ModeAjaxServiceDiscovery(WatoWebApiMode):
return discovery_result
def _do_discovery(self, discovery_result, request):
- services_to_save, remove_disabled_rule, add_disabled_rule = {}, [], []
+ autochecks_to_save, remove_disabled_rule, add_disabled_rule, saved_services = {},
set(
+ ), set(), set()
apply_changes = False
for table_source, check_type, _checkgroup, item, paramstring, _params, \
descr, _state, _output, _perfdata in discovery_result.check_table:
@@ -691,24 +692,29 @@ class ModeAjaxServiceDiscovery(WatoWebApiMode):
if table_source == DiscoveryState.UNDECIDED:
if table_target == DiscoveryState.MONITORED:
- services_to_save[(check_type, item)] = paramstring
+ autochecks_to_save[(check_type, item)] = paramstring
+ saved_services.add(descr)
elif table_target == DiscoveryState.IGNORED:
- add_disabled_rule.append(descr)
+ add_disabled_rule.add(descr)
elif table_source == DiscoveryState.VANISHED:
if table_target != DiscoveryState.REMOVED:
- services_to_save[(check_type, item)] = paramstring
+ autochecks_to_save[(check_type, item)] = paramstring
+ saved_services.add(descr)
if table_target == DiscoveryState.IGNORED:
- add_disabled_rule.append(descr)
+ add_disabled_rule.add(descr)
elif table_source == DiscoveryState.MONITORED:
if table_target in [
DiscoveryState.MONITORED,
DiscoveryState.IGNORED,
]:
- services_to_save[(check_type, item)] = paramstring
+ autochecks_to_save[(check_type, item)] = paramstring
+
if table_target == DiscoveryState.IGNORED:
- add_disabled_rule.append(descr)
+ add_disabled_rule.add(descr)
+ else:
+ saved_services.add(descr)
elif table_source == DiscoveryState.IGNORED:
if table_target in [
@@ -716,28 +722,31 @@ class ModeAjaxServiceDiscovery(WatoWebApiMode):
DiscoveryState.UNDECIDED,
DiscoveryState.VANISHED,
]:
- remove_disabled_rule.append(descr)
+ remove_disabled_rule.add(descr)
if table_target in [
DiscoveryState.MONITORED,
DiscoveryState.IGNORED,
]:
- services_to_save[(check_type, item)] = paramstring
+ autochecks_to_save[(check_type, item)] = paramstring
+ saved_services.add(descr)
if table_target == DiscoveryState.IGNORED:
- add_disabled_rule.append(descr)
+ add_disabled_rule.add(descr)
elif table_source in [
DiscoveryState.CLUSTERED_NEW,
DiscoveryState.CLUSTERED_OLD,
]:
- services_to_save[(check_type, item)] = paramstring
+ autochecks_to_save[(check_type, item)] = paramstring
+ saved_services.add(descr)
if apply_changes:
need_sync = False
if remove_disabled_rule or add_disabled_rule:
+ add_disabled_rule = add_disabled_rule - remove_disabled_rule -
saved_services
self._save_host_service_enable_disable_rules(remove_disabled_rule,
add_disabled_rule)
need_sync = True
- self._save_services(services_to_save, need_sync)
+ self._save_services(autochecks_to_save, need_sync)
def _save_services(self, checks, need_sync):
message = _("Saved check configuration of host '%s' with %d
services") % \
@@ -781,7 +790,7 @@ class ModeAjaxServiceDiscovery(WatoWebApiMode):
# Check whether or not the service still needs a host specific setting after
removing
# the host specific setting above and remove all services from the service list
# that are fine without an additional change.
- for service in services[:]:
+ for service in list(services):
value_without_host_rule = ruleset.analyse_ruleset(self._host.name(),
service)[0]
if (not value and value_without_host_rule in [None, False]) \
or value == value_without_host_rule: