Module: check_mk
Branch: master
Commit: 8e2c9570e4971f7409542d52f12386b585291722
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8e2c9570e4971f…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Dec 6 15:54:52 2018 +0100
6944 FIX docker_node_info: FIX missing Keys for docker versions on CentOS 6
FEED-3170
Change-Id: I1e41e3681a1055c3f13eeef65bc438f0ba5b08ef
---
.werks/6944 | 10 +++++
checks/docker.include | 20 +++++----
checks/docker_node_info | 1 +
.../docker_node_info_centos6_regression.py | 49 ++++++++++++++++++++++
4 files changed, 72 insertions(+), 8 deletions(-)
diff --git a/.werks/6944 b/.werks/6944
new file mode 100644
index 0000000..18593d3
--- /dev/null
+++ b/.werks/6944
@@ -0,0 +1,10 @@
+Title: docker_node_info: FIX missing keys for docker versions on CentOS 6
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1544108040
+Class: fix
+
+
diff --git a/checks/docker.include b/checks/docker.include
index 4670c1f..c3d7492 100644
--- a/checks/docker.include
+++ b/checks/docker.include
@@ -124,14 +124,18 @@ def parse_docker_node_info(info):
if k.startswith("Labels") and k != "Labels":
parsed["Labels"].append(k[6:] + parsed.pop(k))
# reconstruct swarm info:
- swarm = {"LocalNodeState": parsed["Swarm"]}
- if "SwarmNodeID" in parsed:
- swarm["NodeID"] = parsed["SwarmNodeID"]
- if "SwarmManagers" in parsed:
- swarm["RemoteManagers"] = parsed["SwarmManagers"]
- parsed["Swarm"] = swarm
- parsed["ServerVersion"] = parsed["Server Version"]
- parsed["IndexServerAddress"] = parsed["Registry"]
+ if "Swarm" in parsed:
+ swarm = {"LocalNodeState": parsed["Swarm"]}
+ if "SwarmNodeID" in parsed:
+ swarm["NodeID"] = parsed.pop("SwarmNodeID")
+ if "SwarmManagers" in parsed:
+ swarm["RemoteManagers"] = parsed.pop("SwarmManagers")
+ parsed["Swarm"] = swarm
+
+ if "Server Version" in parsed:
+ parsed["ServerVersion"] = parsed.pop("Server Version")
+ if "Registry" in parsed:
+ parsed["IndexServerAddress"] = parsed.pop("Registry")
return parsed
diff --git a/checks/docker_node_info b/checks/docker_node_info
index aa1e420..38c76c9 100644
--- a/checks/docker_node_info
+++ b/checks/docker_node_info
@@ -77,6 +77,7 @@ def check_docker_node_containers(item, params, parsed):
raw_count = parsed.get(key)
if raw_count is None:
yield 3, "%s: count not present in agent output" % title
+ continue
count = int(raw_count)
warn, crit = params.get(upper_name, (None, None))
diff --git
a/tests/unit/checks/generictests/datasets/docker_node_info_centos6_regression.py
b/tests/unit/checks/generictests/datasets/docker_node_info_centos6_regression.py
new file mode 100644
index 0000000..510640a
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/docker_node_info_centos6_regression.py
@@ -0,0 +1,49 @@
+
+
+checkname = 'docker_node_info'
+
+
+info = [
+ [u'|Containers', u' 42'],
+ [u'|Images', u' 23'],
+ [u'|Storage Driver', u' devicemapper'],
+ [u'| Pool Name', u' docker-9', u'232-23232323-pool'],
+ [u'| Pool Blocksize', u' 23.23 kB'],
+ [u'| Backing Filesystem', u' extfs'],
+ [u'| Data file', u' /dev/loop23'],
+ [u'| Metadata file', u' /dev/loop24'],
+ [u'| Data Space Used', u' 42.42 GB'],
+ [u'| Data Space Total', u' 142.42 GB'],
+ [u'| Data Space Available', u' 42.42 GB'],
+ [u'| Metadata Space Used', u' 42.42 MB'],
+ [u'| Metadata Space Total', u' 23.23 GB'],
+ [u'| Metadata Space Available', u' 3.141 GB'],
+ [u'| Udev Sync Supported', u' true'],
+ [u'| Deferred Removal Enabled', u' false'],
+ [u'| Data loop file', u'
/data/docker/devicemapper/devicemapper/data'],
+ [u'| Metadata loop file', u'
/data/docker/devicemapper/devicemapper/metadata'],
+ [u'| Library Version', u' 1.02.117-Koechelverzeichnis/
(2024-12-12)'],
+ [u'|Execution Driver', u' killmenow-0.23'],
+ [u'|Logging Driver', u' json-file'],
+ [u'|Kernel Version', u' 3.14.15-926.5.3.el5.x86_64'],
+ [u'|Operating System', u' <unknown>'],
+ [u'|CPUs', u' 1024'],
+ [u'|Total Memory', u' -23 GiB'],
+ [u'|Name', u' voms01'],
+ [u'|ID', u' XXXX', u'XXXX', u'XXXX', u'XXXX',
u'XXXX', u'XXXX',
+ u'BLOB', u'BOBO', u'0COV', u'FEFE',
u'WHOO', u'0TEH'],
+]
+
+
+discovery = {'': [(None, {})], 'containers': [(None, {})]}
+
+
+checks = {'': [(None, 'default', [(0, u'Daemon running on host
voms01', [])])],
+ 'containers': [(None,
+ 'default',
+ [(0,
+ 'containers: 42',
+ [('containers', 42, None, None, None, None)]),
+ (3, 'running: count not present in agent output',
[]),
+ (3, 'paused: count not present in agent output', []),
+ (3, 'stopped: count not present in agent output',
[])])]}