Module: check_mk
Branch: master
Commit: 3f310555d9f677bf4cf13e3eabcac2e77a237b9a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3f310555d9f677…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Nov 23 21:28:41 2015 +0100
check_mk.agent_update: better output of timestamps
---
checks/check_mk | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/checks/check_mk b/checks/check_mk
index 03a466b..ffe938f 100644
--- a/checks/check_mk
+++ b/checks/check_mk
@@ -128,12 +128,6 @@ def inventory_cmk_agent_update(info):
return [ (None, {}) ]
def check_cmk_agent_update(_no_item, _no_params, info):
- def output_age(text):
- if text == "None":
- return "never"
- else:
- return "%s ago" % (get_age_human_readable(time.time() -
float(text)))
-
for line in info:
if line[0] == "AgentUpdate:":
parsed = {}
@@ -150,6 +144,11 @@ def check_cmk_agent_update(_no_item, _no_params, info):
now = time.time()
+ if parsed["error"] != "None":
+ yield 2, "error: %s" % parsed["error"]
+ else:
+ yield 0, "no errors"
+
try:
last_check = float(parsed["last_check"])
age = now - last_check
@@ -164,17 +163,14 @@ def check_cmk_agent_update(_no_item, _no_params, info):
levels_text = " (warn/crit at %s/%s)" %
(get_age_human_readable(warn), get_age_human_readable(crit))
else:
levels_text = ""
- yield state, "previous update check: " +
output_age(parsed["last_check"]) + levels_text
+ yield state, "last update check: " +
get_timestamp_human_readable(parsed["last_check"]) + levels_text
except:
yield 1, "no successful connect to server yet"
- yield 0, "last agent update: %s" %
output_age(parsed["last_update"])
+ yield 0, "last agent update: %s" %
get_timestamp_human_readable(parsed["last_update"])
+
if parsed["aghash"] != "None":
yield 0, "agent configuration: %s" %
parsed["aghash"][:8]
- if parsed["error"] != "None":
- yield 2, "error: %s" % parsed["error"]
- else:
- yield 0, "no errors"
return