Module: check_mk
Branch: master
Commit: 0ee0eb10dda02d0318ea961ebfa2cb5ae92b0e26
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0ee0eb10dda02d…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Feb 7 13:16:00 2019 +0100
docker: minor cleanups
Change-Id: Idb8b33d83494b40019f951f4092dd723eecaed42
---
checks/docker_container_cpu | 7 +------
checks/docker_container_mem | 7 +------
checks/docker_container_status | 24 +++++++++---------------
3 files changed, 11 insertions(+), 27 deletions(-)
diff --git a/checks/docker_container_cpu b/checks/docker_container_cpu
index c05e866..41eb43b 100644
--- a/checks/docker_container_cpu
+++ b/checks/docker_container_cpu
@@ -25,11 +25,6 @@
# Boston, MA 02110-1301 USA.
-def inventory_docker_container_cpu(info):
- if info:
- return [(None, {})]
-
-
def check_docker_container_cpu(_no_item, params, info):
if not params:
params = {}
@@ -55,7 +50,7 @@ def check_docker_container_cpu(_no_item, params, info):
check_info["docker_container_cpu"] = {
"check_function": check_docker_container_cpu,
- "inventory_function": inventory_docker_container_cpu,
+ "inventory_function": discover_single,
"service_description": "CPU utilization",
"has_perfdata": True,
"includes": ["cpu_util.include"],
diff --git a/checks/docker_container_mem b/checks/docker_container_mem
index d3eb2ca..9541f55 100644
--- a/checks/docker_container_mem
+++ b/checks/docker_container_mem
@@ -54,18 +54,13 @@ def parse_docker_container_mem(info):
return mem
-def inventory_docker_container_mem(parsed):
- if parsed:
- return [(None, {})]
-
-
def check_docker_container_mem(_no_item, params, parsed):
return check_memory(params, parsed)
check_info["docker_container_mem"] = {
"parse_function": parse_docker_container_mem,
- "inventory_function": inventory_docker_container_mem,
+ "inventory_function": discover_single,
"check_function": check_docker_container_mem,
"service_description": "Memory used",
"has_perfdata": True,
diff --git a/checks/docker_container_status b/checks/docker_container_status
index aa9ee4a..f94205f 100644
--- a/checks/docker_container_status
+++ b/checks/docker_container_status
@@ -58,8 +58,8 @@ def inventory_docker_container_status_health(parsed):
return [(None, None)]
-def check_docker_container_status_health(_no_item, params, parsed):
- health_status = parsed[u"Health"][u"Status"]
+def check_docker_container_status_health(_no_item, _no_params, parsed):
+ health_status = parsed.get(u"Health", {}).get(u"Status")
if health_status == "healthy":
return 0, "Healthy"
@@ -90,25 +90,19 @@ check_info["docker_container_status.health"] = {
# '----------------------------------------------------------------------'
-def inventory_docker_container_status(parsed):
- if parsed:
- return [(None, None)]
+def check_docker_container_status(_no_item, _no_params, parsed):
+ status = parsed.get("Status", "unknown")
+ state = {"running": 0, "unknown": 3}.get(status, 2)
+ yield state, "Status: %s" % status
-def check_docker_container_status(_no_item, params, parsed):
- if parsed[u"Status"] == u"running":
- return 0, "Running"
- else:
- status = 2
- infotext = "Status: " + parsed[u"Status"]
- if parsed.get(u"Error"):
- infotext += " Error: " + parsed[u"Error"]
- return status, infotext
+ if parsed.get(u"Error"):
+ yield 2, "Error: %s" % parsed[u"Error"]
check_info['docker_container_status'] = {
'parse_function': parse_docker_container_status,
- 'inventory_function': inventory_docker_container_status,
+ 'inventory_function': discover_single,
'check_function': check_docker_container_status,
'service_description': 'Docker container status',
}