Module: check_mk
Branch: master
Commit: fc7a4f4bfd96d47822503586a31d542d4a98c62e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fc7a4f4bfd96d4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 5 13:11:49 2013 +0200
Fix Check_MK execution time in keepalive mode
---
modules/check_mk_base.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index dd67c78..e470ad4 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -933,6 +933,8 @@ def do_check(hostname, ipaddress, only_check_types = None):
run_time = time.time() - start_time
if check_mk_perfdata_with_times:
times = os.times()
+ if opt_keepalive:
+ times = map(lambda a: a[0]-a[1], zip(times, g_initial_times))
output += "execution time %.1f sec|execution_time=%.3f user_time=%.3f
"\
"system_time=%.3f children_user_time=%.3f
children_system_time=%.3f\n" %\
(run_time, run_time, times[0], times[1], times[2], times[3])
@@ -990,6 +992,8 @@ class MKCheckTimeout(Exception):
pass
def do_check_keepalive():
+ global g_initial_times
+
def check_timeout(signum, frame):
raise MKCheckTimeout()
@@ -1005,6 +1009,7 @@ def do_check_keepalive():
while True:
cleanup_globals()
hostname = sys.stdin.readline()
+ g_initial_times = os.times()
if not hostname:
break
hostname = hostname.strip()