$smarty->compile_dir = "./templates_c";
$smarty->config_dir = "./configs";
- // Global variables
- $job_status = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' );
-
- // Running jobs
- $running_jobs = array();
-
- $query = "SELECT Job.JobId, Job.JobStatus, Status.JobStatusLong, Job.Name, Job.StartTime, Job.EndTime, 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')";
- $query .= "ORDER BY JobId";
-
- $jobsresult = $dbSql->db_link->query( $query );
-
- if( PEAR::isError( $jobsresult ) ) {
- echo "SQL query = $query <br />";
- die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
- }else {
- while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
-
- // Elapsed time for this job
- $elapsed = 'N/A';
- if( $job['JobStatus'] == 'R' )
- $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), time() );
- else
- $job['elapsed_time'] = 'N/A';
-
- // Odd or even row
- if( count($running_jobs) % 2)
- $job['Job_classe'] = 'odd';
-
- // Job Status
- $job['Level'] = $job_status[ $job['Level'] ];
-
- array_push( $running_jobs, $job);
- }
- }
-
- $smarty->assign( 'running_jobs', $running_jobs );
-
- // Get the last jobs list
+ // Jobs list
$query = "";
$last_jobs = array();
- $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong ";
+ // Job Status list
+ $job_status = array( 'Any', 'Waiting', 'Running', 'Completed', 'Failed', 'Canceled' );
+ $smarty->assign( 'job_status', $job_status );
+
+ // Global variables
+ $job_level = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' );
+
+ $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Job.JobBytes, 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 ";
// Filter by status
if( isset( $_POST['status'] ) ) {
- switch( $_POST['status'] )
+ switch( strtolower( $_POST['status'] ) )
{
+ case 'running':
+ $query .= "WHERE Job.JobStatus = 'R' ";
+ break;
+ case 'waiting':
+ $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R') ";
+ break;
case 'completed':
$query .= "WHERE Job.JobStatus = 'T' ";
break;
}
}
- $query .= "ORDER BY Job.EndTime DESC ";
+ // order by
+ $query .= "ORDER BY Job.JobId DESC ";
// Determine how many jobs to display
if( isset($_POST['limit']) )
else
$query .= "LIMIT 20 ";
+ //echo $query . '<br />';
+
$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 ) ) {
- // Determine icon for job
- if( $job['JobStatus'] == 'T' )
- $job['Job_icon'] = "s_ok.gif";
- else
- $job['Job_icon'] = "s_error.gif";
+
+ // Determine icon for job status
+ switch( $job['JobStatus'] ) {
+ case 'R':
+ $job['Job_icon'] = "running.png";
+ break;
+ case 'T':
+ $job['Job_icon'] = "s_ok.png";
+ break;
+ case 'A':
+ case 'f':
+ case 'E':
+ $job['Job_icon'] = "s_error.gif";
+ break;
+ case 'F':
+ case 'S':
+ case 'M':
+ case 'm':
+ case 's':
+ case 'j':
+ case 'c':
+ case 'd':
+ case 't':
+ case 'C':
+ $job['Job_icon'] = "waiting.png";
+ break;
+ } // end switch
// Odd or even row
if( count($last_jobs) % 2)
$job['Job_classe'] = 'odd';
- // Elapsed time for this job
- $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) );
+ // Elapsed time for the job
+ if( $job['StartTime'] == '0000-00-00 00:00:00' )
+ $job['elapsed_time'] = 'N/A';
+ elseif( $job['EndTime'] == '0000-00-00 00:00:00' )
+ $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), mktime() );
+ else
+ $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) );
- // Job Status
- $job['Level'] = $job_status[ $job['Level'] ];
+ // Job Level
+ $job['Level'] = $job_level[ $job['Level'] ];
+
+ // Job Size
+ $job['JobBytes'] = $dbSql->human_file_size( $job['JobBytes'] );
array_push( $last_jobs, $job);
}
}
$smarty->assign( 'last_jobs', $last_jobs );
+ // Count jobs
if( isset( $_POST['status'] ) )
$total_jobs = $dbSql->CountJobs( ALL, $_POST['status'] );
else
{popup_init src='./external_packages/js/overlib.js'}
{include file=header.tpl}
-<div id="nav">
- <a href="index.php" title="Back to the dashboard">Dashboard</a> > Jobs list
-</div>
-
-<div id="main_center">
- <div class="box">
- <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">Elapsed time</td>
- <td class="info">Level</td>
- <td class="info">Pool</td>
- </tr>
- {foreach from=$running_jobs item=job}
- <tr>
- <td class="{$job.Job_classe}">{$job.JobStatusLong}</td>
- <td class="{$job.Job_classe}">{$job.JobId}</td>
- <td class="{$job.Job_classe}">{$job.Name}</td>
- <td class="{$job.Job_classe}">{$job.StartTime}</td>
- <td class="{$job.Job_classe}">{$job.elapsed_time}</td>
- <td class="{$job.Job_classe}">{$job.Level}</td>
- <td class="{$job.Job_classe}">{$job.Pool_name}</td>
- </tr>
- {/foreach}
- </table>
- </div> <!-- end div box -->
+ <div id="nav">
+ <a href="index.php" title="Back to the dashboard">Dashboard</a> > Jobs list
+ </div>
+ <div id="main_center">
+
<!-- Last jobs -->
<div class="box">
- <p class="title">Last jobs</p>
+ <p class="title">Jobs report</p>
<!-- Filter jobs -->
<form action="jobs.php" method="post">
- <table class="list" border="0">
+ <table border="0">
<tr>
<td class="info" width="200">
{$total_jobs} jobs found
<td class="info" width="200">
Job Status
<select name="status">
- <option value="Any">Any
+ {foreach from=$job_status item=status_label}
+ <option value="{$status_label}" {if $smarty.post.status == $status_label}Selected{/if}>{$status_label}
+<!--
+ <option value="waiting">Waiting
+ <option value="running">Running
<option value="completed">Completed
<option value="failed">Failed
<option value="canceled">Canceled
+-->
+ {/foreach}
</select>
</td>
<td class="info" width="120">
</table>
</form>
- <table class="list" border="0">
+ <table border="0">
<tr>
- <td width="50" class="info">Status</td>
- <td width="50" class="info">Job ID</td>
- <td width="70" class="info">BackupJob</td>
- <td width="80" class="info">Start Time</td>
- <td width="80" class="info">End Time</td>
- <td width="70" class="info">Elapsed time</td>
- <td width="50" class="info">Level</td>
- <td width="80" class="info">Pool</td>
+ <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">Bytes</td>
+ <td class="info">Pool</td>
</tr>
- </table>
- <div class="listbox">
- <table class="list" border="0">
+ <!-- <div class="listbox"> -->
{foreach from=$last_jobs item=job}
<tr>
<td width="50" class="{$job.Job_classe}">
<img width="20" src="style/images/{$job.Job_icon}" alt="" title="{$job.JobStatusLong}" />
</td>
- <td width="50" class="{$job.Job_classe}">{$job.JobId}</td>
- <td width="70" class="{$job.Job_classe}">{$job.Job_name}</td>
- <td width="80" class="{$job.Job_classe}">{$job.StartTime}</td>
- <td width="80" class="{$job.Job_classe}">{$job.EndTime}</td>
- <td width="70" class="{$job.Job_classe}">{$job.elapsed_time}</td>
- <td width="50" class="{$job.Job_classe}">{$job.Level}</td>
- <td width="80" class="{$job.Job_classe}">{$job.Pool_name}</td>
+ <td class="{$job.Job_classe}">{$job.JobId}</td>
+ <td class="{$job.Job_classe}">{$job.Job_name}</td>
+ <td class="{$job.Job_classe}">{$job.StartTime}</td>
+ <td class="{$job.Job_classe}">{$job.EndTime}</td>
+ <td class="{$job.Job_classe}">{$job.elapsed_time}</td>
+ <td class="{$job.Job_classe}">{$job.Level}</td>
+ <td class="{$job.Job_classe}">{$job.JobBytes}</td>
+ <td class="{$job.Job_classe}">{$job.Pool_name}</td>
</tr>
{/foreach}
</table>
- </div> <!-- end div class=listbox -->
+ <!-- </div> --> <!-- end div class=listbox -->
</div>
</div>