Module: check_mk
Branch: master
Commit: 6f48926edbb8eae9a746f8727cf9d9cf2236cad7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6f48926edbb8ea…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri Feb 15 07:41:49 2019 +0100
docker deprecation: quick fix
Change-Id: Idc68724e5e669759f4a2709319727cbab23418ce
---
checks/docker_container_status | 36 ++++++++++++++++++++++++++++++++++++
checks/docker_node_disk_usage | 36 ++++++++++++++++++++++++++++++++++++
checks/docker_node_info | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+)
diff --git a/checks/docker_container_status b/checks/docker_container_status
index 69649fa..13e7b3a 100644
--- a/checks/docker_container_status
+++ b/checks/docker_container_status
@@ -25,6 +25,42 @@
# Boston, MA 02110-1301 USA.
+# TODO: see why it's not enough to have it in legacy_docker.include
+def append_deprecation_warning(check_function):
+ '''A wrapper to WARN if legacy code is used
+
+ If the parse result is of one of the legacy Types the decorated
+ check function will yield an additional WARNING state.
+
+ These legacy parse results correspond to agents/plugins from version
+ 1.5.0b1 to 1.5.0p12
+ '''
+
+ @functools.wraps(check_function)
+ def wrapper(item, params, parsed):
+
+ is_deprecated = isinstance(parsed, (DeprecatedDict, DeprecatedList))
+ catch_these = Exception if is_deprecated else ()
+
+ try:
+ results = check_function(item, params, parsed)
+ if isinstance(results, tuple):
+ yield results
+ else:
+ for result in results:
+ yield result
+ except catch_these:
+ yield 3, "Could not handle data"
+ finally:
+ if is_deprecated:
+ yield 1, ("Deprecated plugin/agent (see long output)(!)\n"
+ "You are using legacy code, which may lead to crashes and/or"
+ " incomplete information. Please upgrade the monitored host to"
+ " use the plugin 'mk_docker.py'.")
+
+ return wrapper
+
+
def parse_docker_container_status(info):
'''process the first line to a JSON object
diff --git a/checks/docker_node_disk_usage b/checks/docker_node_disk_usage
index d5355e2..a4be887 100644
--- a/checks/docker_node_disk_usage
+++ b/checks/docker_node_disk_usage
@@ -25,6 +25,42 @@
# Boston, MA 02110-1301 USA.
+# TODO: see why it's not enough to have it in legacy_docker.include
+def append_deprecation_warning(check_function):
+ '''A wrapper to WARN if legacy code is used
+
+ If the parse result is of one of the legacy Types the decorated
+ check function will yield an additional WARNING state.
+
+ These legacy parse results correspond to agents/plugins from version
+ 1.5.0b1 to 1.5.0p12
+ '''
+
+ @functools.wraps(check_function)
+ def wrapper(item, params, parsed):
+
+ is_deprecated = isinstance(parsed, (DeprecatedDict, DeprecatedList))
+ catch_these = Exception if is_deprecated else ()
+
+ try:
+ results = check_function(item, params, parsed)
+ if isinstance(results, tuple):
+ yield results
+ else:
+ for result in results:
+ yield result
+ except catch_these:
+ yield 3, "Could not handle data"
+ finally:
+ if is_deprecated:
+ yield 1, ("Deprecated plugin/agent (see long output)(!)\n"
+ "You are using legacy code, which may lead to crashes and/or"
+ " incomplete information. Please upgrade the monitored host to"
+ " use the plugin 'mk_docker.py'.")
+
+ return wrapper
+
+
def parse_docker_node_disk_usage(info):
version = docker_get_version(info) # pylint: disable=undefined-variable
diff --git a/checks/docker_node_info b/checks/docker_node_info
index 3d193d1..f560f9e 100644
--- a/checks/docker_node_info
+++ b/checks/docker_node_info
@@ -25,6 +25,42 @@
# Boston, MA 02110-1301 USA.
+# TODO: see why it's not enough to have it in legacy_docker.include
+def append_deprecation_warning(check_function):
+ '''A wrapper to WARN if legacy code is used
+
+ If the parse result is of one of the legacy Types the decorated
+ check function will yield an additional WARNING state.
+
+ These legacy parse results correspond to agents/plugins from version
+ 1.5.0b1 to 1.5.0p12
+ '''
+
+ @functools.wraps(check_function)
+ def wrapper(item, params, parsed):
+
+ is_deprecated = isinstance(parsed, (DeprecatedDict, DeprecatedList))
+ catch_these = Exception if is_deprecated else ()
+
+ try:
+ results = check_function(item, params, parsed)
+ if isinstance(results, tuple):
+ yield results
+ else:
+ for result in results:
+ yield result
+ except catch_these:
+ yield 3, "Could not handle data"
+ finally:
+ if is_deprecated:
+ yield 1, ("Deprecated plugin/agent (see long output)(!)\n"
+ "You are using legacy code, which may lead to crashes and/or"
+ " incomplete information. Please upgrade the monitored host to"
+ " use the plugin 'mk_docker.py'.")
+
+ return wrapper
+
+
def parse_docker_node_info(info):
version = docker_get_version(info) # pylint: disable=undefined-variable
Module: check_mk
Branch: master
Commit: c7575232f3cb97e522057f81a75dc8a99dc44506
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c7575232f3cb97…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sun Feb 10 09:56:25 2019 +0100
Add some integration tests for SNMP modules
We really want to test the SNMP implementations communicating against a
SNMP agent and the "netsnmp" python module (used for inline SNMP) and
snmp commands (used for classic SNMP) are not available in the git
environment. For the moment it does not make sense to build these tests
as unit tests because we want to tests the whole chain from single SNMP
actions in our modules to the faked SNMP device and back.
We use the snmpsimd (thanks Ilya! :-)) for simulating SNMP agents
providing different sets of SNMP information.
The tests invoke various calls using our different SNMP backends: SNMP
classic (based on snmp commands subprocesses), Inline SNMP (based on
netsnmp python bindings) and also get data from Check_MKs stored SNMP
walks.
For internal and more detailed testing we'll use unit tests instead.
Change-Id: I61e98d748220374b341f838c30617ca6043f1487
---
Pipfile | 1 +
cmk_base/snmp.py | 1 +
omd/packages/python-modules/python-modules.make | 1 +
.../python-modules/src/snmpsim-0.4.6.tar.gz | Bin 0 -> 414473 bytes
.../snmp/snmp_data/1.3.6.1.6.1.1.0.snmprec | 1 +
.../snmp_data/1.3.6.1.6.1.1.0/127.0.0.1.snmprec | 1 +
.../cmk_base/snmp/snmp_data/cmk-walk/localhost | 555 +++++++++++++++++++
.../cmk_base/snmp/snmp_data/public.snmprec | 614 +++++++++++++++++++++
tests/integration/cmk_base/snmp/test_snmp.py | 420 ++++++++++++++
9 files changed, 1594 insertions(+)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=c7575232f3…