Module: check_mk
Branch: master
Commit: 68b6e43aa08db657e5e89ddccb0c847923db5a02
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=68b6e43aa08db6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 11:23:15 2018 +0200
5947 df: Exclude docker local storage mounts on docker nodes
The df check is now excluding all filesystems found below
<tt>/var/lib/docker</tt>, which is the default location for
the docker container local storage.
Depending on the used storage engine docker creates overlay
filesystems and mounts below this hierarchy for the started
containers.
The filesystems are not interesting for our monitoring. They
will be monitored from the container context.
Change-Id: I25deab75bf7e9cc1a73b34999ce046f0bb06092a
---
.werks/5947 | 19 +++++++++++++++++++
checks/df | 10 +++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.werks/5947 b/.werks/5947
new file mode 100644
index 0000000..3aa41f4
--- /dev/null
+++ b/.werks/5947
@@ -0,0 +1,19 @@
+Title: df: Exclude docker local storage mounts on docker nodes
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523005992
+Class: feature
+
+The df check is now excluding all filesystems found below
+<tt>/var/lib/docker</tt>, which is the default location for
+the docker container local storage.
+
+Depending on the used storage engine docker creates overlay
+filesystems and mounts below this hierarchy for the started
+containers.
+
+The filesystems are not interesting for our monitoring. They
+will be monitored from the container context.
diff --git a/checks/df b/checks/df
index c0dfbc3..e4bef0e 100644
--- a/checks/df
+++ b/checks/df
@@ -203,7 +203,7 @@ def inventory_df(parsed):
(df_blocks, volume_info), _ = parsed
mplist = []
- for line in df_blocks:
+ for line in _filter_docker_local_storage(df_blocks):
mountpoint = line[0]
if mountpoint in inventory_df_exclude_mountpoints:
@@ -230,6 +230,9 @@ def inventory_df(parsed):
def check_df(item, params, parsed):
(df_blocks, volume_info), df_inodes = parsed
+
+ df_blocks = _filter_docker_local_storage(df_blocks)
+
if "patterns" in params or item in volume_info:
return df_check_filesystem_list(item, params, df_blocks, df_inodes)
else:
@@ -237,6 +240,11 @@ def check_df(item, params, parsed):
return df_check_filesystem_list(mountpoint, params, df_blocks, df_inodes)
+# Always exclude filesystems below dockers local storage area
+def _filter_docker_local_storage(df_blocks):
+ return [ e for e in df_blocks if not e[0].startswith("/var/lib/docker") ]
+
+
check_info['df'] = {
"parse_function" : parse_df,
"inventory_function" : inventory_df,
Module: check_mk
Branch: master
Commit: cded304a73515abc11efb375d89da430eaafdbaa
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cded304a73515a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 10:42:45 2018 +0200
5946 FIX lnx_if: Exclude veth* network interfaces on docker nodes
The veth* network interfaces created for docker containers are now
excluded by the linux agent in all cases. The interface names have no
direct match with the docker container name or ID. They seem to have
some kind of random nature.
These container specific interfaces are not relevant to be monitored
on the node. We are monitoring the docker network interfaces in the
container.
Change-Id: Icecc44425b30cd1ae4e74448f7f71f86ab7b065e
---
.werks/5946 | 17 +++++++++++++++++
agents/check_mk_agent.linux | 2 +-
checks/lnx_if | 4 ++++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/.werks/5946 b/.werks/5946
new file mode 100644
index 0000000..00063a4
--- /dev/null
+++ b/.werks/5946
@@ -0,0 +1,17 @@
+Title: lnx_if: Exclude veth* network interfaces on docker nodes
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523003860
+Class: fix
+
+The veth* network interfaces created for docker containers are now
+excluded by the linux agent in all cases. The interface names have no
+direct match with the docker container name or ID. They seem to have
+some kind of random nature.
+
+These container specific interfaces are not relevant to be monitored
+on the node. We are monitoring the docker network interfaces in the
+container.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 22bd49f..7db4db9 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -393,7 +393,7 @@ if type ip > /dev/null
then
echo '<<<lnx_if>>>'
echo "[start_iplink]"
- ip link
+ ip link
echo "[end_iplink]"
fi
diff --git a/checks/lnx_if b/checks/lnx_if
index 449441c..9cd9d0b 100644
--- a/checks/lnx_if
+++ b/checks/lnx_if
@@ -217,6 +217,10 @@ def parse_lnx_if(info):
def inventory_lnx_if(parsed):
if linux_nic_check == "legacy":
return []
+
+ # Always exclude dockers veth* interfaces on docker nodes
+ parsed = [ e for e in parsed if not e[2].startswith("veth") ]
+
return inventory_if_common(parsed, has_nodeinfo=True)
Module: check_mk
Branch: master
Commit: 60681f06f33495548fd64a6efcb7bbb032b16bfc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=60681f06f33495…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 14:48:22 2018 +0200
5953 lnx_thermal: Disabled in docker container contexts
These checks do not make sense in the context of a docker container.
The agent is now skipping this section when executed in a container.
Change-Id: Iec55097fb4b4a762e56d1ee8108655f68f13c634
---
.werks/5953 | 11 +++++++++++
agents/check_mk_agent.linux | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/.werks/5953 b/.werks/5953
new file mode 100644
index 0000000..feafebf
--- /dev/null
+++ b/.werks/5953
@@ -0,0 +1,11 @@
+Title: lnx_thermal: Disabled in docker container contexts
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523018887
+Class: feature
+
+These checks do not make sense in the context of a docker container.
+The agent is now skipping this section when executed in a container.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 15d3f6e..d99c53e 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -922,7 +922,7 @@ fi
# Gather thermal information provided e.g. by acpi
# At the moment only supporting thermal sensors
-if ls /sys/class/thermal/thermal_zone* >/dev/null 2>&1; then
+if [ -z "$MK_IN_CONTAINER" ] && ls /sys/class/thermal/thermal_zone* >/dev/null 2>&1; then
echo '<<<lnx_thermal>>>'
for F in /sys/class/thermal/thermal_zone*; do
echo -n "${F##*/} "
Module: check_mk
Branch: master
Commit: 6bf2d789da3f69a8458c7ff3922b89b42ee9800c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6bf2d789da3f69…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 13:39:14 2018 +0200
5950 uptime: Is now reported correctly for docker containers
In previous versions of the linux agent the uptime of the
docker node was reported by the agent when it is being executed
in a docker container context.
Change-Id: Ia7ad0cad8b8a50b3803243e05b487486c2901374
---
.werks/5950 | 13 +++++++++++++
agents/check_mk_agent.linux | 13 ++++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.werks/5950 b/.werks/5950
new file mode 100644
index 0000000..d15a7a6
--- /dev/null
+++ b/.werks/5950
@@ -0,0 +1,13 @@
+Title: uptime: Is now reported correctly for docker containers
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523014708
+Class: feature
+
+In previous versions of the linux agent the uptime of the
+docker node was reported by the agent when it is being executed
+in a docker container context.
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 0ae70e3..28e3005 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -131,6 +131,15 @@ function section_cpu()
fi
}
+function section_uptime()
+{
+ echo '<<<uptime>>>'
+ if [ -z "$MK_IN_CONTAINER" ]; then
+ cat /proc/uptime
+ else
+ echo "$(($(date +%s) - $(stat -c %Z /dev/pts)))"
+ fi
+}
function run_mrpe() {
local descr=$1
@@ -391,9 +400,7 @@ section_mem
section_cpu
# Uptime
-echo '<<<uptime>>>'
-cat /proc/uptime
-
+section_uptime
# New variant: Information about speed and state in one section
if type ip > /dev/null
Module: check_mk
Branch: master
Commit: b919890e51eabde773b7710fa1d8efd16542bfa0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b919890e51eabd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 12:15:56 2018 +0200
5949 cpu.threads cpu.load: Disabled in docker container contexts
These checks do not make sense in the context of a docker container.
The agent is now skipping this section when executed in a container.
Change-Id: I3619e796da31fbb7487baf2e13b5a6fe905ec25f
---
.werks/5949 | 11 +++++++++++
agents/check_mk_agent.linux | 14 ++++++++------
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/.werks/5949 b/.werks/5949
new file mode 100644
index 0000000..01c9930
--- /dev/null
+++ b/.werks/5949
@@ -0,0 +1,11 @@
+Title: cpu.threads cpu.load: Disabled in docker container contexts
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523009711
+Class: feature
+
+These checks do not make sense in the context of a docker container.
+The agent is now skipping this section when executed in a container.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 672fb3f..0ae70e3 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -120,13 +120,15 @@ function section_mem()
function section_cpu()
{
- echo '<<<cpu>>>'
- if [ $(uname -m) = "armv7l" ]; then
- CPU_REGEX='^processor'
- else
- CPU_REGEX='^CPU|^processor'
+ if [ -z "$MK_IN_CONTAINER" ]; then
+ echo '<<<cpu>>>'
+ if [ "$(uname -m)" = "armv7l" ]; then
+ CPU_REGEX='^processor'
+ else
+ CPU_REGEX='^CPU|^processor'
+ fi
+ echo "$(cat /proc/loadavg) $(grep -c -E $CPU_REGEX < /proc/cpuinfo)"
fi
- echo "$(cat /proc/loadavg) $(grep -E $CPU_REGEX < /proc/cpuinfo | wc -l)"
}
Module: check_mk
Branch: master
Commit: 1c95803af1a7c394c3d396daafcdd7a99b5f54d5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1c95803af1a7c3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 14:35:40 2018 +0200
5952 docker_container_cpu: Check the CPU utilization of a docker container
This check reports the percentage CPU utilization of a docker container.
Unlike the Linux CPU utilization check (kernel.util) it does only report
user and system time. More detailed values, like iowait, are not available.
Change-Id: I108c36a7609792b9c94abc1e9de7d4c3909b4395
---
.werks/5952 | 12 +++++++++++
agents/check_mk_agent.linux | 3 +++
checkman/docker_container_cpu | 14 ++++++++++++
checks/docker_container_cpu | 50 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+)
diff --git a/.werks/5952 b/.werks/5952
new file mode 100644
index 0000000..ffb1f98
--- /dev/null
+++ b/.werks/5952
@@ -0,0 +1,12 @@
+Title: docker_container_cpu: Check the CPU utilization of a docker container
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523018035
+Class: feature
+
+This check reports the percentage CPU utilization of a docker container.
+Unlike the Linux CPU utilization check (kernel.util) it does only report
+user and system time. More detailed values, like iowait, are not available.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index cc437c2..15d3f6e 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -128,6 +128,9 @@ function section_cpu()
CPU_REGEX='^CPU|^processor'
fi
echo "$(cat /proc/loadavg) $(grep -c -E $CPU_REGEX < /proc/cpuinfo)"
+ else
+ echo '<<<docker_container_cpu>>>'
+ echo "$(</sys/fs/cgroup/cpu/cpuacct.stat)"
fi
}
diff --git a/checkman/docker_container_cpu b/checkman/docker_container_cpu
new file mode 100644
index 0000000..c673a2c
--- /dev/null
+++ b/checkman/docker_container_cpu
@@ -0,0 +1,14 @@
+title: CPU utilization
+agents: linux
+catalog: app/docker
+license: GPL
+distribution: check_mk
+description:
+ This check measures the CPU utilization of a docker container during
+ the last check cycle. Levels can be set on the total utilization.
+
+ This check can currently report user and system time.
+
+inventory:
+ One check per container is created if the Check_MK agent is executed
+ in the context of a docker container.
diff --git a/checks/docker_container_cpu b/checks/docker_container_cpu
new file mode 100644
index 0000000..bef4b4c
--- /dev/null
+++ b/checks/docker_container_cpu
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 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 inventory_docker_container_cpu(info):
+ if info:
+ return [(None, {})]
+
+
+def check_docker_container_cpu(_no_item, params, info):
+ if not params:
+ params = {}
+
+ # user, nice, system, idle, iowait, hw-int, sw-int, steal
+ ticks = dict(info)
+ values = [ int(ticks["user"]), 0, int(ticks["system"]), 0, 0, 0, 0, 0 ]
+
+ return check_cpu_util_unix(values, params)
+
+
+check_info["docker_container_cpu"] = {
+ "check_function": check_docker_container_cpu,
+ "inventory_function": inventory_docker_container_cpu,
+ "service_description": "CPU utilization",
+ "has_perfdata": True,
+ "includes": ["cpu_util.include"],
+ "group": "cpu_iowait",
+}