Module: check_mk
Branch: master
Commit: a1eefdd809fb81fafdbd89b246a3697525ff49ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a1eefdd809fb81…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 23 09:58:29 2019 +0100
Take piggyback persisted sections into account during checking phase
Change-Id: Id602ee4bf51adc6805c8cb1546018430ef6fe005
---
cmk_base/config.py | 6 ++++--
cmk_base/data_sources/__init__.py | 7 +++++++
cmk_base/data_sources/abstract.py | 4 +++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/cmk_base/config.py b/cmk_base/config.py
index 9c800a0..169ad13 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -855,8 +855,10 @@ def is_ping_host(hostname):
def is_agent_host(hostname):
import cmk_base.piggyback as piggyback
- return is_tcp_host(hostname) or
piggyback.has_piggyback_raw_data(piggyback_max_cachefile_age,
- 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))
def is_dual_host(hostname):
diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py
index 5f1a1e6..cba1b0e 100644
--- a/cmk_base/data_sources/__init__.py
+++ b/cmk_base/data_sources/__init__.py
@@ -91,6 +91,13 @@ def _in_keepalive_mode():
# '----------------------------------------------------------------------'
+def has_persisted_piggyback_agent_sections(hostname):
+ for source in DataSources(hostname, None).get_data_sources():
+ if isinstance(source, PiggyBackDataSource) and
source.has_persisted_agent_sections():
+ return True
+ return False
+
+
class DataSources(object):
def __init__(self, hostname, ipaddress):
super(DataSources, self).__init__()
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index 3f6a6ff..135f8b5 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -408,12 +408,14 @@ class DataSource(object):
# | of sections that are not provided on each query. |
# '----------------------------------------------------------------------'
+ def has_persisted_agent_sections(self):
+ return os.path.exists(self._persisted_sections_file_path())
+
def _store_persisted_sections(self, persisted_sections):
if not persisted_sections:
return
file_path = self._persisted_sections_file_path()
-
try:
os.makedirs(os.path.dirname(file_path))
except OSError as e: