Module: check_mk
Branch: master
Commit: 1cc1d4622ea9b92b931cdd131429b1de6fda488b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1cc1d4622ea9b9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Apr 6 17:06:01 2018 +0200
5959 docker_node_info: New check which monitors the status of docker daemon
Change-Id: Ida31b1be0724887a803d10d420f8631806386db0
---
.werks/5959 | 10 +++++++++
agents/check_mk_agent.linux | 3 +++
checkman/docker_node_info | 12 ++++++++++
checks/docker_node_info | 54 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+)
diff --git a/.werks/5959 b/.werks/5959
new file mode 100644
index 0000000..860951b
--- /dev/null
+++ b/.werks/5959
@@ -0,0 +1,10 @@
+Title: docker_node_info: New check which monitors the status of docker daemon
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523020454
+Class: feature
+
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index e102d3a..a7ea57e 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -962,6 +962,9 @@ fi
# Iterate all running containers and report piggyback data for them
if type docker > /dev/null 2>&1 ; then
+ echo "<<<docker_node_info>>>"
+ docker info --format "{{json .}}" 2>&1
+
for CONTAINER_ID in $(docker container ls -q); do
echo "<<<<$CONTAINER_ID>>>>"
diff --git a/checkman/docker_node_info b/checkman/docker_node_info
new file mode 100644
index 0000000..b90895f
--- /dev/null
+++ b/checkman/docker_node_info
@@ -0,0 +1,12 @@
+title: Docker Node Info
+agents: linux
+catalog: app/docker
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the status of the docker application.
+ If the daemon is running, the check is OK, otherwise it is
+ CRIT and displays the error message.
+
+inventory:
+ One service is created.
diff --git a/checks/docker_node_info b/checks/docker_node_info
new file mode 100644
index 0000000..4839273
--- /dev/null
+++ b/checks/docker_node_info
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+def parse_docker_node_info(info):
+ try:
+ import json
+ return json.loads("".join(info[0]))
+ except ValueError:
+ return " ".join(info[0])
+
+
+def inventory_docker_node_info(parsed):
+ if parsed:
+ return [(None, {})]
+
+
+def check_docker_node_info(item, params, parsed):
+ if isinstance(parsed, dict):
+ # TODO use other infos from this section?
+ return 0, 'Daemon running on host %s' % parsed["Name"]
+
+ return 2, parsed
+
+
+check_info['docker_node_info'] = {
+ 'parse_function' : parse_docker_node_info,
+ 'inventory_function' : inventory_docker_node_info,
+ 'check_function' : check_docker_node_info,
+ 'service_description' : 'Docker Node Info',
+}