Module: check_mk
Branch: master
Commit: bbb866fabde1c05110e42472e41054693a6d9fc8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bbb866fabde1c0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 3 17:10:55 2014 +0100
#1612 FIX job: Fixed wrong reported start time for running jobs
---
.werks/1612 | 9 +++++++++
ChangeLog | 1 +
checks/job | 35 +++++++++++++++--------------------
3 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/.werks/1612 b/.werks/1612
new file mode 100644
index 0000000..8c6446c
--- /dev/null
+++ b/.werks/1612
@@ -0,0 +1,9 @@
+Title: job: Fixed wrong reported start time for running jobs
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417623022
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 7ba5338..d1193f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,7 @@
* 1564 FIX: check_mk_agent.linux: fix situation where async plugin is not executed
after crash...
* 1609 FIX: zpool_status: fix problem when the zpool has a separate log or cache
device...
* 1566 FIX: 3ware_disks: consider VERIFYING state as OK now...
+ * 1612 FIX: job: Fixed wrong reported start time for running jobs
Multisite:
* 1508 Allow input of plugin output and perfdata when faking check results...
diff --git a/checks/job b/checks/job
index 83f3ba6..f8c895f 100644
--- a/checks/job
+++ b/checks/job
@@ -71,31 +71,27 @@ def job_parse_real_time(s):
return float(parts[-1]) + min_sec + hour_sec
def job_parse(item, info):
- found = False
- found_running = False
data = {}
+ prefix = None
for line in info:
- if ' '.join(line[1:-1]) == item:
- found = True
+ if line[0] == '==>':
- elif ' '.join(line[1:-1]) == item + '.running':
- # There might be a second section per job, the contents of the
- # <ident>.running file which exists during execution of the job.
- # We use the start_time from this file.
- found_running = True
+ if ' '.join(line[1:-1]) == item:
+ prefix = ''
- elif found_running and line[0] == '==>':
- continue # simply skip over this line
+ elif ' '.join(line[1:-1]) == item + '.running':
+ # There might be a second section per job, the contents of the
+ # <ident>.running file which exists during execution of the job.
+ # We use the start_time from this file.
+ prefix = 'running_'
- elif found_running and len(line) == 2:
- key, val = line
- if key == 'start_time':
- data['running_start_time'] = int(val)
+ elif 'start_time' in data.keys() and 'running_start_time' in
data.keys():
+ break # both sections completed => we are done here
- elif found and line[0] == '==>':
- break # Stop at next section
+ else:
+ prefix = None
- elif found and len(line) == 2:
+ elif len(line) == 2 and prefix is not None:
key, val = line
# Convert several keys/values
if key == 'real_time':
@@ -107,7 +103,7 @@ def job_parse(item, info):
elif key in [ 'max_res_kbytes', 'avg_mem_kbytes' ]:
key = key.replace('kbytes', 'bytes')
val = int(val) * 1000
- data[key] = val
+ data[prefix+key] = val
return data
@@ -138,7 +134,6 @@ def check_job(item, params, info):
output.append('(Started: %s)' % display_value)
return state, ' '.join(output)
-
txt = 'Exit-Code: %d' % job['exit_code']
if job['exit_code'] != 0:
state = max(state, 2)