Module: check_mk
Branch: master
Commit: f8ce3fe82669c9390713e0506819ca8d418b29dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f8ce3fe82669c9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jan 14 13:04:06 2019 +0100
6682 FIX SNMP Checks: Fixed randomly missing data, when using the rule 'Check
intervals for SNMP checks'
Change-Id: I1fba992b416f15aecc84d06d0ac8abe938895d10
---
.werks/6682 | 11 +++++++++++
cmk_base/data_sources/abstract.py | 8 +++++---
cmk_base/data_sources/snmp.py | 8 +++-----
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/.werks/6682 b/.werks/6682
new file mode 100644
index 0000000..2cfe7ee
--- /dev/null
+++ b/.werks/6682
@@ -0,0 +1,11 @@
+Title: SNMP Checks: Fixed randomly missing data, when using the rule "Check
intervals for SNMP checks"
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1542114586
+
+One outcome of this bug was that successive service discoveries reported different
amounts of services found.
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index 56e562d..ca783c1 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -86,6 +86,7 @@ class DataSource(object):
self._exception = None
self._host_sections = None
self._exit_code_spec = config.exit_code_spec(hostname, data_source_id=self.id())
+ self._persisted_sections = None
def _setup_logger(self):
"""Add the source log prefix to the class
logger"""
@@ -116,10 +117,12 @@ class DataSource(object):
self._exception = None
self._host_sections = None
+ self._persisted_sections = None
try:
cpu_tracking.push_phase(self._cpu_tracking_id())
+ self._persisted_sections = self._load_persisted_sections()
raw_data, is_cached_data = self._get_raw_data()
self._host_sections = host_sections = self._convert_to_sections(raw_data)
@@ -426,11 +429,10 @@ class DataSource(object):
self._logger.debug("Stored persisted sections: %s" % (",
".join(persisted_sections.keys())))
def _update_info_with_persisted_sections(self, host_sections):
- persisted_sections = self._load_persisted_sections()
- if not persisted_sections:
+ if not self._persisted_sections:
return host_sections
- for section_name, entry in persisted_sections.iteritems():
+ for section_name, entry in self._persisted_sections.items():
if len(entry) == 2:
continue # Skip entries of "old" format
diff --git a/cmk_base/data_sources/snmp.py b/cmk_base/data_sources/snmp.py
index e3580f6..a0ec428 100644
--- a/cmk_base/data_sources/snmp.py
+++ b/cmk_base/data_sources/snmp.py
@@ -168,8 +168,6 @@ class SNMPDataSource(DataSource):
self._verify_ipaddress()
- persisted_sections = self._load_persisted_sections()
-
check_plugin_names = self.get_check_plugin_names()
access_data = self._get_access_data()
@@ -197,7 +195,7 @@ class SNMPDataSource(DataSource):
# This checks data is configured to be persisted (snmp_check_interval) and
recent enough.
# Skip gathering new data here. The persisted data will be added latera
- if section_name in persisted_sections:
+ if section_name in self._persisted_sections:
self._logger.debug(
"%s: Skip fetching data (persisted info exists)" %
(check_plugin_name))
continue
@@ -248,8 +246,8 @@ class SNMPDataSource(DataSource):
key=lambda x: (not ('cpu' in x or x in
cpu_checks_without_cpu_in_check_name), x))
def _convert_to_sections(self, raw_data):
- persisted_sections = self._extract_persisted_sections(raw_data)
- return HostSections(raw_data, persisted_sections=persisted_sections)
+ sections_to_persist = self._extract_persisted_sections(raw_data)
+ return HostSections(raw_data, persisted_sections=sections_to_persist)
def _extract_persisted_sections(self, raw_data):
"""Extract the sections to be persisted from the raw_data and
return it