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