Module: check_mk
Branch: master
Commit: e9232fd829c0cc7615694a6b7fad999166161d02
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e9232fd829c0cc…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 28 08:18:01 2018 +0200
6181 FIX Improved execution of agent in containers
When the docker command is available in a container and the Check_MK agent is
executed in this container while it was started from the node, it does not
execute the docker logic.
The REMOTE environment variable was not set correctly in previous 1.5 releases.
Change-Id: I04cde2bd8442061664d56b453e1704abd2d93287
---
.werks/6181 | 15 +++++++++++++++
agents/check_mk_agent.linux | 6 +++---
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/.werks/6181 b/.werks/6181
new file mode 100644
index 0000000..b76a5ab
--- /dev/null
+++ b/.werks/6181
@@ -0,0 +1,15 @@
+Title: Improved execution of agent in containers
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527446328
+
+When the docker command is available in a container and the Check_MK agent is
+executed in this container while it was started from the node, it does not
+execute the docker logic.
+
+The REMOTE environment variable was not set correctly in previous 1.5 releases.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 4347424..14696be 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -992,7 +992,7 @@ if type pvecm > /dev/null 2>&1 ; then
fi
# Iterate all running containers and report piggyback data for them
-if type docker > /dev/null 2>&1 ; then
+if type docker > /dev/null 2>&1 && [ -z "$MK_IS_PIGGYBACKED"
]; then
NODE_NAME=$(docker info --format "{{json .Name}}")
echo "<<<docker_node_info>>>"
@@ -1046,9 +1046,9 @@ if type docker > /dev/null 2>&1 ; then
# a little more complex setup. Have a look at the documentation.
AGENT_PATH=$(docker container exec "$CONTAINER_ID" which check_mk_agent
2>/dev/null)
if [ -n "$AGENT_PATH" ]; then
- docker container exec --env "REMOTE=$REMOTE"
"$CONTAINER_ID" check_mk_agent
+ docker container exec --env MK_IS_PIGGYBACKED=1 --env
"REMOTE=$REMOTE" "$CONTAINER_ID" check_mk_agent
elif docker container exec "$CONTAINER_ID" which bash >/dev/null
2>&1; then
- docker container exec --env "MK_FROM_NODE=1,REMOTE=$REMOTE" -i
"$CONTAINER_ID" bash < "$0"
+ docker container exec --env MK_IS_PIGGYBACKED=1 --env MK_FROM_NODE=1 --env
"REMOTE=$REMOTE" -i "$CONTAINER_ID" bash < "$0"
fi
echo "<<<<>>>>"