Module: check_mk
Branch: master
Commit: 3624815028d953397d03dee5632f57e214b33fa7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3624815028d953…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu May 2 14:36:16 2019 +0200
Nagios config: Cleanup check service interval handling
CMK-2030
Change-Id: Ib3ae5aa367aa81c6939c13b91b004372722ca6bc
---
cmk_base/core_nagios.py | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py
index b264f88..012d787 100644
--- a/cmk_base/core_nagios.py
+++ b/cmk_base/core_nagios.py
@@ -250,6 +250,8 @@ def _create_nagios_servicedefs(cfg, config_cache, hostname,
host_attrs):
host_config = config_cache.get_host_config(hostname)
+ check_mk_attrs = core_config.get_service_attributes(hostname, "Check_MK",
config_cache)
+
# _____
# |___ /
# |_ \
@@ -314,20 +316,14 @@ def _create_nagios_servicedefs(cfg, config_cache, hostname,
host_attrs):
"dependent_service_description": description,
}).encode("utf-8"))
+ # TODO: Find a generic (CMC/Nagios) place for this logic
# Add the check interval of either the Check_MK service or
# (if configured) the snmp_check_interval for snmp based checks
- check_interval = 1 # default hardcoded interval
- # Customized interval of Check_MK service
- values = config_cache.service_extra_conf(
- hostname, "Check_MK",
config.extra_service_conf.get('check_interval', []))
- if values:
- try:
- check_interval = int(values[0])
- except:
- check_interval = float(values[0])
value =
host_config.snmp_check_interval(cmk_base.check_utils.section_name_of(checkname))
if value is not None:
check_interval = value
+ else:
+ check_interval = check_mk_attrs["check_interval"]
service_spec = {
"use": template,
@@ -354,7 +350,7 @@ def _create_nagios_servicedefs(cfg, config_cache, hostname,
host_attrs):
"host_name": hostname,
"service_description": "Check_MK",
}
- service_spec.update(core_config.get_service_attributes(hostname,
"Check_MK", config_cache))
+ service_spec.update(check_mk_attrs)
service_spec.update(_extra_service_conf_of(cfg, config_cache, hostname,
"Check_MK"))
outfile.write(_format_nagios_object("service",
service_spec).encode("utf-8"))