Module: check_mk
Branch: master
Commit: 5cfdefed7c76cb49dffa8bdad9d37466ca8c8d8f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5cfdefed7c76cb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 13:49:19 2018 +0200
5951 kernel: 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: I9811054b1c9ab559fa934c9fd8798db793d55f43
---
.werks/5951 | 11 +++++++++++
agents/check_mk_agent.linux | 8 +++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/.werks/5951 b/.werks/5951
new file mode 100644
index 0000000..b29c480
--- /dev/null
+++ b/.werks/5951
@@ -0,0 +1,11 @@
+Title: kernel: Disabled in docker container contexts
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523015219
+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 28e3005..cc437c2 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -478,9 +478,11 @@ fi
# Performancecounter Kernel
-echo '<<<kernel>>>'
-date +%s
-cat /proc/vmstat /proc/stat
+if [ -z "$MK_IN_CONTAINER" ]; then
+ echo '<<<kernel>>>'
+ date +%s
+ cat /proc/vmstat /proc/stat
+fi
# Hardware sensors via IPMI (need ipmitool)
if type ipmitool > /dev/null
Module: check_mk
Branch: master
Commit: f35b8038cd506346f216d5c850bc16429244fd35
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f35b8038cd5063…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 11:47:38 2018 +0200
5948 docker_container_mem: Docker container specific memory checking
Instead of using the default linux memory check (mem), Check_MK is now
using the container specific memory check.
The main reason is that the memory information in the container is not
available through <tt>/proc/meminfo</tt> as usual. The memory data is available
through the kernels cgroup interface which is available in the containers
context below <tt>/sys/fs/cgroup/memory/memory.stat</tt>
The features of both checks are exactly the same.
Change-Id: I3e7b229cfb550fd1b6c82105c449f8a648fed59e
---
.werks/5948 | 18 ++++++++++++++++++
agents/check_mk_agent.linux | 9 +++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/.werks/5948 b/.werks/5948
new file mode 100644
index 0000000..ebf66be
--- /dev/null
+++ b/.werks/5948
@@ -0,0 +1,18 @@
+Title: docker_container_mem: Docker container specific memory checking
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523007246
+Class: feature
+
+Instead of using the default linux memory check (mem), Check_MK is now
+using the container specific memory check.
+
+The main reason is that the memory information in the container is not
+available through <tt>/proc/meminfo</tt> as usual. The memory data is available
+through the kernels cgroup interface which is available in the containers
+context below <tt>/sys/fs/cgroup/memory/memory.stat</tt>
+
+The features of both checks are exactly the same.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 7db4db9..672fb3f 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -109,8 +109,13 @@ fi
function section_mem()
{
- echo '<<<mem>>>'
- egrep -v '^Swap:|^Mem:|total:' < /proc/meminfo
+ if [ -z "$MK_IN_CONTAINER" ]; then
+ echo '<<<mem>>>'
+ grep -E -v '^Swap:|^Mem:|total:' < /proc/meminfo
+ else
+ echo '<<docker_container_mem>>>'
+ echo "$(</sys/fs/cgroup/memory/memory.stat)"
+ fi
}
function section_cpu()
Module: check_mk
Branch: master
Commit: 488135e80e84ffdc996068045286d654b288c852
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=488135e80e84ff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 6 10:09:29 2018 +0200
Preparing linux agent for docker monitoring
* The agent now detects whether or not it is being executed
in a docker container context.
* The Agent can be told to leave stdin open. This is useful
when the docker nodes agent shal be executed in the context
of a container.
Change-Id: Id110745605a7af94e02c15f6e080ed2df666115f
---
agents/check_mk_agent.linux | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index a0dbd70..22bd49f 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -57,14 +57,26 @@ LOCALDIR=$MK_LIBDIR/local
# output if they are not outdated (see below)
SPOOLDIR=$MK_VARDIR/spool
-# close standard input (for security reasons) and stderr
+# close standard input (for security reasons) and stderr when not
+# explicitly in debug mode.
+# When the nodes agent is executed by a e.g. docker node in a container,
+# then don't close stdin, because the agent is piped through it in this
+# case.
if [ "$1" = -d ]
then
set -xv
-else
+elif [ -z "$MK_FROM_NODE" ]; then
exec </dev/null 2>/dev/null
fi
+# Detect whether or not the agent is being executed in a container
+# environment.
+if [ -f /.dockerenv ]; then
+ MK_IN_CONTAINER=1
+else
+ unset MK_IN_CONTAINER
+fi
+
# Prefer (relatively) new /usr/bin/timeout from coreutils against
# our shipped waitmax. waitmax is statically linked and crashes on
# some Ubuntu versions recently.