$smarty->compile_dir = "./templates_c";
$smarty->config_dir = "./configs";
- // Get the last 10 failed jobs
- $query = "";
- $failed_jobs = array();
+ // Running jobs
+ $running_jobs = array();
+
+ $query = "SELECT Job.JobId, Job.JobStatus, Status.JobStatusLong, Job.Name, Job.StartTime, Job.Level, Pool.Name AS Pool_name ";
+ $query .= "FROM Job ";
+ $query .= "JOIN Status ON Job.JobStatus = Status.JobStatus ";
+ $query .= "LEFT JOIN Pool ON Job.PoolId = Pool.PoolId ";
+ $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R')";
- switch( $dbSql->driver )
- {
- case 'mysql':
- $query = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, Job.JobId, Job.Name AS job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS pool_name, Job.JobStatus ";
- $query .= "FROM Job ";
- $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
- $query .= "WHERE Job.JobStatus = 'f' ";
- //$query .= "WHERE Job.EndTime BETWEEN <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 ";
- $query .= "ORDER BY Job.EndTime DESC ";
- $query .= "LIMIT 10";
-
- break;
-
- case 'pgsql':
- $query = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
- $query .= "FROM Job ";
- $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
- $query .= "WHERE Job.JobStatus = 'f' ";
- //$query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' AND ";
- $query .= "ORDER BY Job.EndTime DESC";
- $query .= "LIMIT 10";
- break;
- }
$jobsresult = $dbSql->db_link->query( $query );
if( PEAR::isError( $jobsresult ) ) {
die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
}else {
while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
- array_push( $failed_jobs, $job);
+ $elapsed = 'N/A';
+
+ if( $job['JobStatus'] == 'R') {
+ $elapsed = mktime() - strtotime($job['StartTime']);
+ if( $elapsed > 3600 )
+ $elapsed = date( "H:i:s", $elapsed );
+ elseif( $elapsed > 86400 )
+ $elapsed = date( "d day(s) i:s", $elapsed );
+ else
+ $elapsed = date( "i:s", $elapsed );
+ }
+ $job['elapsed_time'] = $elapsed;
+
+ array_push( $running_jobs, $job);
}
}
- $smarty->assign( 'failed_jobs', $failed_jobs );
- // Get the last completed jobs (last 24 hours)
- $query = "";
- $completed_jobs = array();
+ $smarty->assign( 'running_jobs', $running_jobs );
- // Interval calculation
- $end_date = mktime();
- $start_date = $end_date - LAST_DAY;
-
- $start_date = date( "Y-m-d H:i:s", $start_date );
- $end_date = date( "Y-m-d H:i:s", $end_date );
+ // Get the last jobs list
+ $query = "";
+ $last_jobs = array();
switch( $dbSql->driver )
{
case 'mysql':
- $query = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, Job.JobId, Job.Name AS job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS pool_name, Job.JobStatus ";
- $query .= "FROM Job ";
- $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
- $query .= "WHERE Job.JobStatus = 'T' AND ";
- $query .= "Job.EndTime BETWEEN '$start_date' AND '$end_date' ";
- $query .= "ORDER BY Job.EndTime DESC ";
-
+ $query = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, ";
break;
-
case 'pgsql':
- $query = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
- $query .= "FROM Job ";
- $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
- $query .= "WHERE EndTime BETWEEN '$start_date' and '$end_date' ";
- $query .= "ORDER BY Job.EndTime DESC";
+ $query = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, ";
break;
}
-
+
+ $query .= "Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong ";
+ $query .= "FROM Job ";
+ $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
+ $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus ";
+ $query .= "ORDER BY Job.EndTime DESC ";
+ $query .= "LIMIT 20";
+
$jobsresult = $dbSql->db_link->query( $query );
if( PEAR::isError( $jobsresult ) ) {
die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
}else {
while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
- array_push( $completed_jobs, $job);
+ if( $job['JobStatus'] == 'T' )
+ $job['Job_icon'] = "s_ok.gif";
+ else
+ $job['Job_icon'] = "s_error.gif";
+
+ array_push( $last_jobs, $job);
}
}
- $smarty->assign( 'completed_jobs', $completed_jobs );
+ $smarty->assign( 'last_jobs', $last_jobs );
+ // Process and display the template
$smarty->display('jobs.tpl');
?>
</div>
<div id="main_center">
- <!-- Failed jobs -->
<div class="box">
- <p class="title">Last failed jobs (limited to 10)</p>
+ <p class="title">Running jobs</p>
<table class="list">
- <tr>
- <td class="info">Status</td>
- <td class="info">Job ID</td>
- <td class="info">BackupJob</td>
- <td class="info">Start Time</td>
- <td class="info">End Time</td>
- <td class="info">Elapsed time</td>
- <td class="info">Level</td>
- <td class="info">Pool</td>
- </tr>
- {foreach from=$failed_jobs item=job}
- <tr>
- <td> <img width="20" src="style/images/s_error.gif" alt=""/> </td>
- <td>{$job.JobId}</td>
- <td>{$job.job_name}</td>
- <td>{$job.StartTime}</td>
- <td>{$job.EndTime}</td>
- <td>{$job.elapsed}</td>
- <td align="center">{$job.Level}</td>
- <td>{$job.pool_name}</td>
- </tr>
- {/foreach}
+ <tr>
+ <td class="info">Status</td>
+ <td class="info">Job ID</td>
+ <td class="info">BackupJob</td>
+ <td class="info">Start Time</td>
+ <td class="info">Elapsed time</td>
+ <td class="info">Level</td>
+ <td class="info">Pool</td>
+ </tr>
+ {foreach from=$running_jobs item=job}
+ <tr>
+ <td>{$job.JobStatusLong}</td>
+ <td>{$job.JobId}</td>
+ <td>{$job.Name}</td>
+ <td>{$job.StartTime}</td>
+ <td>{$job.elapsed_time}</td>
+ <td>{$job.Level}</td>
+ <td>{$job.Pool_name}</td>
+ </tr>
+ {/foreach}
</table>
- </div>
- <!-- Completed jobs -->
+ </div> <!-- end div box -->
+ <!-- Failed jobs -->
<div class="box">
- <p class="title">Last completed jobs</p>
+ <p class="title">Last jobs</p>
<table class="list">
<tr>
<td class="info">Status</td>
<td class="info">Level</td>
<td class="info">Pool</td>
</tr>
- {foreach from=$completed_jobs item=job}
+ {foreach from=$last_jobs item=job}
<tr>
- <td> <img width="20px" src="style/images/s_ok.gif" alt=""/> </td>
+ <td> <img width="20" src="style/images/{$job.Job_icon}" alt="" title="{$job.JobStatusLong}" /> </td>
<td>{$job.JobId}</td>
- <td>{$job.job_name}</td>
+ <td>{$job.Job_name}</td>
<td>{$job.StartTime}</td>
<td>{$job.EndTime}</td>
<td>{$job.elapsed}</td>
<td align="center">{$job.Level}</td>
- <td>{$job.pool_name}</td>
+ <td>{$job.Pool_name}</td>
</tr>
{/foreach}
- </table>
+ </table>
</div>
+
</div>
{include file="footer.tpl"}