Skip to content

Commit

Permalink
Merge pull request #90 from tim-moody/9-25-enh
Browse files Browse the repository at this point in the history
change job stat to show duration
  • Loading branch information
tim-moody authored Sep 25, 2018
2 parents 4e1df13 + 0f2cd46 commit 5fb76ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion roles/cmdsrv/files/iiab-cmdsrv
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ def get_last_jobs_stat(cmd_info):
db_lock.acquire() # will block if lock is already held
try:
conn = sqlite3.connect(cmdsrv_dbpath)
cur = conn.execute ("SELECT jobs.rowid, job_command, job_output, job_status, last_update_datetime, cmd_msg FROM jobs, commands where cmd_rowid = commands.rowid ORDER BY jobs.rowid DESC LIMIT 30")
cur = conn.execute ("SELECT jobs.rowid, job_command, job_output, job_status, strftime('%s',jobs.create_datetime), strftime('%s',last_update_datetime), strftime('%s','now'), cmd_msg FROM jobs, commands where cmd_rowid = commands.rowid ORDER BY jobs.rowid DESC LIMIT 30")
last_jobs = cur.fetchall()
conn.close()
except sqlite3.Error, e:
Expand Down Expand Up @@ -1922,6 +1922,8 @@ def get_last_jobs_stat(cmd_info):
job_cc.append(job[3])
job_cc.append(job[4])
job_cc.append(job[5])
job_cc.append(job[6])
job_cc.append(job[7])

last_jobs_cc.append(job_cc)
else:
Expand Down
2 changes: 1 addition & 1 deletion roles/console/files/htmlf/70-utilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h2>Job Status</h2><br>
<th style="width:30%">Command</th>
<th style="width:40%">Result</th>
<th style="width:10%">Status</th>
<th style="width:10%">As Of</th>
<th style="width:10%">Duration</th>
</tr>
</thead>
<tbody>
Expand Down
22 changes: 20 additions & 2 deletions roles/console/files/js/admin_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,8 @@ function procJobStat(data)
job_status = {};
var html = "";
var html_break = '<br>';
var duration = 0;
var durationStr = "";

data.forEach(function(entry) {
//console.log(entry);
Expand Down Expand Up @@ -1425,8 +1427,15 @@ function procJobStat(data)

job_info['status'] = entry[3];
html += "<td>" + entry[3] + "</td>";
job_info['status_date'] = entry[4];
html += "<td>" + entry[4] + "</td>";
duration = entry[5] - entry[4]; // unless is running

if (["STARTED","RESTARTED"].includes(entry[3]))
duration = entry[6] - entry[4]; // then use current time on server
durationStr = secondsToDuration(duration)

job_info['duration'] = durationStr;

html += "<td>" + durationStr + "</td>";

html += "</tr>";

Expand Down Expand Up @@ -1929,6 +1938,15 @@ function getServerInfoError (jqXHR, textStatus, errorThrown){
alert ("Connection to Server failed.\n Please make sure your network settings are correct,\n that the server is turned on,\n and that the web server is running.");
}

function secondsToDuration(seconds){
var d = Number(seconds);

var h = Math.floor(d / 3600);
var m = Math.floor(d % 3600 / 60);
var s = Math.floor(d % 3600 % 60);

return ('0' + h).slice(-2) + ":" + ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
}

function formCommand(cmd_verb, args_name, args_obj)
{
Expand Down

0 comments on commit 5fb76ee

Please sign in to comment.