Module: check_mk
Branch: master
Commit: f3545a088ba2712c737cb25df18f9132b3456715
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f3545a088ba271…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Mar 12 15:00:29 2019 +0100
7245 New builtin tag group "piggyback" allows to explictly turn piggyback data
usage on/off
Change-Id: I85bc3637db7e70ec8cb7c6fe87e53ba181c35145
---
.werks/7245 | 24 +++++++++++++
cmk/gui/config.py | 5 +++
cmk_base/config.py | 40 +++++++++++++++++-----
cmk_base/data_sources/__init__.py | 3 +-
tests/unit/cmk/gui/watolib/test_host_attributes.py | 1 +
5 files changed, 63 insertions(+), 10 deletions(-)
diff --git a/.werks/7245 b/.werks/7245
new file mode 100644
index 0000000..ad286f4
--- /dev/null
+++ b/.werks/7245
@@ -0,0 +1,24 @@
+Title: New builtin tag group "piggyback" allows to explictly turn piggyback
data usage on/off
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1552398906
+Class: feature
+
+Piggyback data is currently only read when the host has a Check_MK service.
+For some systems, the existance of the Check_MK service solely depends on the
+existance of piggyback files for the given host.
+During the config generation phase of the monitoring core, race conditions could apply,
+where a host might receive no Check_MK service.
+
+
+This werk introduces an explicit piggyback host tag, which allows you to enforce/disable
the use of piggyback data.
+Per default this option is currently set to <tt>Automatically detect piggyback
usage</tt>, to be compatible with the previous
+behaviour.
+
+
+You should explictly set the <tt>Use piggyback data</tt> option if you have a
ping only host,
+which receives additional piggyback data from another host. This actively prevents
beforementioned race conditions.
+
diff --git a/cmk/gui/config.py b/cmk/gui/config.py
index 51625d6..7181e92 100644
--- a/cmk/gui/config.py
+++ b/cmk/gui/config.py
@@ -729,6 +729,11 @@ class BuiltinTags(object):
("special-agents", _("Use all enabled datasource
programs"), ["tcp"]),
("no-agent", _("No agent"), []),
], ["!ping"]),
+ ("piggyback", "%s/%s" % (_("Data sources"),
_("Piggyback")), [
+ (None, _("Legacy: Automatically detect piggyback usage"), []),
+ ("piggyback", _("Use piggyback data"), []),
+ ("no-piggyback", _("Do not use piggyback data"),
[]),
+ ], ["!ping"]),
("snmp", "%s/%s" % (_("Data sources"),
_("SNMP")), [
("no-snmp", _("No SNMP"), []),
("snmp-v2", _("SNMP v2 or v3"), ["snmp"]),
diff --git a/cmk_base/config.py b/cmk_base/config.py
index 1b82a6f..232131c 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -827,11 +827,23 @@ def is_ping_host(hostname):
and not has_management_board(hostname)
+# Deprecated: Use HostConfig:is_agent_host instance instead
def is_agent_host(hostname):
- import cmk_base.data_sources as data_sources
- return is_tcp_host(hostname) or \
- piggyback.has_piggyback_raw_data(piggyback_max_cachefile_age, hostname) or \
- data_sources.has_persisted_piggyback_agent_sections(hostname)
+ if is_tcp_host(hostname):
+ return True
+
+ tags = tags_of_host(hostname)
+
+ if "piggyback" in tags:
+ is_piggyback_host = True
+ elif "no-piggyback" in tags:
+ is_piggyback_host = False
+ else: # Legacy automatic detection
+ import cmk_base.data_sources as data_sources
+ is_piggyback_host = piggyback.has_piggyback_raw_data(piggyback_max_cachefile_age,
hostname) or \
+
data_sources.has_persisted_piggyback_agent_sections(hostname)
+
+ return is_piggyback_host
def is_dual_host(hostname):
@@ -2729,10 +2741,21 @@ class HostConfig(object):
self.is_tcp_host = self._config_cache.in_binary_hostlist(hostname, tcp_hosts)
self.is_snmp_host = self._config_cache.in_binary_hostlist(hostname, snmp_hosts)
+ if "piggyback" in self.tags:
+ self.is_piggyback_host = True
+ elif "no-piggyback" in self.tags:
+ self.is_piggyback_host = False
+ else: # Legacy automatic detection
+ self.is_piggyback_host = self.has_piggyback_data
+
# Agent types
+ self.is_agent_host = self.is_tcp_host or self.is_piggyback_host
self.management_protocol = management_protocol_of(hostname)
self.has_management_board = self.management_protocol is not None
- self.is_ping_host = not self.is_snmp_host and not self.is_agent_host and not
self.has_management_board
+
+ self.is_ping_host = not self.is_snmp_host and\
+ not self.is_agent_host and\
+ not self.has_management_board
self.is_dual_host = self.is_tcp_host and self.is_snmp_host
self.is_all_agents_host = "all-agents" in self.tags
@@ -2749,11 +2772,10 @@ class HostConfig(object):
or (self.is_ipv4v6_host and
_primary_ip_address_family_of(hostname) == "ipv6")
@property
- def is_agent_host(self):
+ def has_piggyback_data(self):
import cmk_base.data_sources as data_sources
- return self.is_tcp_host or \
- piggyback.has_piggyback_raw_data(piggyback_max_cachefile_age,
self.hostname) or \
- data_sources.has_persisted_piggyback_agent_sections(self.hostname)
+ return piggyback.has_piggyback_raw_data(piggyback_max_cachefile_age,
self.hostname) or \
+ data_sources.has_persisted_piggyback_agent_sections(self.hostname)
#.
diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py
index cba1b0e..896cd3e 100644
--- a/cmk_base/data_sources/__init__.py
+++ b/cmk_base/data_sources/__init__.py
@@ -137,7 +137,8 @@ class DataSources(object):
source.set_main_agent_data_source()
self._add_source(source)
- self._add_source(PiggyBackDataSource(self._hostname, self._ipaddress))
+ if "no-piggyback" not in config.tags_of_host(self._hostname):
+ self._add_source(PiggyBackDataSource(self._hostname, self._ipaddress))
def _initialize_snmp_data_sources(self):
if config.is_snmp_host(self._hostname):
diff --git a/tests/unit/cmk/gui/watolib/test_host_attributes.py
b/tests/unit/cmk/gui/watolib/test_host_attributes.py
index 6270429..e9befa6 100644
--- a/tests/unit/cmk/gui/watolib/test_host_attributes.py
+++ b/tests/unit/cmk/gui/watolib/test_host_attributes.py
@@ -419,6 +419,7 @@ def test_host_attributes(load_plugins, for_what):
],
"data_sources": [
'tag_agent',
+ 'tag_piggyback',
'tag_snmp',
],
"management_board": [