Module: check_mk
Branch: master
Commit: eefff612d75c92c2230a24aaa03dc72c82c600fe
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eefff612d75c92…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Tue Apr 23 14:02:32 2019 +0200
7403 FIX check_http, check_mail_loop, check_smtp: Unkown state during discovery
Active checks using the host_name() API function no longer go to UNKNOWN
during discovery.
CMK-1927
Change-Id: I8f8b46a125ab790edacc9913b7af6db2eaa2c9fd
---
.werks/7403 | 11 +++++++++++
cmk_base/automations/check_mk.py | 3 +++
cmk_base/discovery.py | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/.werks/7403 b/.werks/7403
new file mode 100644
index 0000000..6dece75
--- /dev/null
+++ b/.werks/7403
@@ -0,0 +1,11 @@
+Title: check_http, check_mail_loop, check_smtp: Unkown state during discovery
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1556020748
+Class: fix
+
+Active checks using the host_name() API function no longer go to UNKNOWN
+during discovery.
diff --git a/cmk_base/automations/check_mk.py b/cmk_base/automations/check_mk.py
index 693e7fc..700622e 100644
--- a/cmk_base/automations/check_mk.py
+++ b/cmk_base/automations/check_mk.py
@@ -1318,6 +1318,9 @@ class AutomationActiveCheck(Automation):
entries = config_cache.host_extra_conf(hostname, rules)
if entries:
act_info = config.active_check_info[plugin]
+ # Set host name for host_name()-function (part of the Check API)
+ # (used e.g. by check_http)
+ check_api_utils.set_hostname(hostname)
for params in entries:
description = config.active_check_service_description(
hostname, plugin, params)
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index 5391e21..9fc54a3 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -739,7 +739,7 @@ def schedule_discovery_check(hostname):
# "warn" -> output a warning on stderr
# "raise" -> let the exception come through
def _discover_services(hostname, ipaddress, sources, multi_host_sections, on_error):
- # Make hostname available as global variable in discovery functions
+ # Set host name for host_name()-function (part of the Check API)
# (used e.g. by ps-discovery)
check_api_utils.set_hostname(hostname)