Commit aad81f98 authored by Iustin Pop's avatar Iustin Pop

Add output of job/opcode timestamps

This patch adds posibility of selection of job/opcode timestamps in
gnt-job list and info.

The code handling the possible cases (None or a valid timestamps) are
ugly though...

Reviwed-by: imsnah
parent c56ec146
......@@ -67,6 +67,11 @@ def ListJobs(opts, args):
"opstatus": "OpCode_status",
"oplog": "OpCode_log",
"summary": "Summary",
"opstart": "OpCode_start",
"opend": "OpCode_end",
"start_ts": "Start",
"end_ts": "End",
"received_ts": "Received",
headers = None
......@@ -86,6 +91,10 @@ def ListJobs(opts, args):
raise errors.ProgrammerError("Unknown job status code '%s'" % val)
elif field == "summary":
val = ",".join(val)
elif field in ("start_ts", "end_ts", "received_ts"):
val = FormatTimestamp(val)
elif field in ("opstart", "opend"):
val = [FormatTimestamp(entry) for entry in val]
row[idx] = str(val)
......@@ -131,17 +140,27 @@ def ShowJobs(opts, args):
return str(value)
selected_fields = ["id", "status", "ops", "opresult", "opstatus", "oplog"]
selected_fields = [
"id", "status", "ops", "opresult", "opstatus", "oplog",
"opstart", "opend", "received_ts", "start_ts", "end_ts",
result = GetClient().QueryJobs(args, selected_fields)
first = True
for job_id, status, ops, opresult, opstatus, oplog in result:
for entry, arg_job in zip(result, args):
if not first:
format(0, "")
first = False
if entry is None:
format(0, "Job ID %s not found" % arg_job)
(job_id, status, ops, opresult, opstatus, oplog,
opstart, opend, recv_ts, start_ts, end_ts) = entry
format(0, "Job ID: %s" % job_id)
if status in _USER_JOB_STATUS:
status = _USER_JOB_STATUS[status]
......@@ -149,10 +168,50 @@ def ShowJobs(opts, args):
raise errors.ProgrammerError("Unknown job status code '%s'" % val)
format(1, "Status: %s" % status)
if recv_ts is not None:
format(1, "Received: %s" % FormatTimestamp(recv_ts))
format(1, "Missing received timestamp (%s)" % str(recv_ts))
if start_ts is not None:
if recv_ts is not None:
d1 = start_ts[0] - recv_ts[0] + (start_ts[1] - recv_ts[1]) / 1000000.0
delta = " (delta %.6fs)" % d1
delta = ""
format(1, "Processing start: %s%s" % (FormatTimestamp(start_ts), delta))
format(1, "Processing start: unknown (%s)" % str(start_ts))
if end_ts is not None:
if start_ts is not None:
d2 = end_ts[0] - start_ts[0] + (end_ts[1] - start_ts[1]) / 1000000.0
delta = " (delta %.6fs)" % d2
delta = ""
format(1, "Processing end: %s%s" % (FormatTimestamp(end_ts), delta))
format(1, "Processing end: unknown (%s)" % str(end_ts))
if end_ts is not None and recv_ts is not None:
d3 = end_ts[0] - recv_ts[0] + (end_ts[1] - recv_ts[1]) / 1000000.0
format(1, "Total processing time: %.6f seconds" % d3)
format(1, "Total processing time: N/A")
format(1, "Opcodes:")
for opcode, result, status, log in zip(ops, opresult, opstatus, oplog):
for (opcode, result, status, log, s_ts, e_ts) in \
zip(ops, opresult, opstatus, oplog, opstart, opend):
format(2, "%s" % opcode["OP_ID"])
format(3, "Status: %s" % status)
if isinstance(s_ts, (tuple, list)):
format(3, "Processing start: %s" % FormatTimestamp(s_ts))
format(3, "No processing start time")
if isinstance(e_ts, (tuple, list)):
format(3, "Processing end: %s" % FormatTimestamp(e_ts))
format(3, "No processing end time")
format(3, "Input fields:")
for key, val in opcode.iteritems():
if key == "OP_ID":
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment