<?php
-/*
-+-------------------------------------------------------------------------+
-| Copyright (C) 2004 Juan Luis Francés Jiménez |
-| |
-| This program is free software; you can redistribute it and/or |
-| modify it under the terms of the GNU General Public License |
-| as published by the Free Software Foundation; either version 2 |
-| of the License, or (at your option) any later version. |
-| |
-| This program is distributed in the hope that it will be useful, |
-| but WITHOUT ANY WARRANTY; without even the implied warranty of |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-| GNU General Public License for more details. |
-+-------------------------------------------------------------------------+
-*/
session_start();
- require ("paths.php");
- require($smarty_path."Smarty.class.php");
- include "classes.inc.php";
+ require_once ("paths.php");
+ require_once ($smarty_path."Smarty.class.php");
+ require_once ("classes.inc.php");
+ require_once ("config.inc.php");
$smarty = new Smarty();
$dbSql = new Bweb();
break;
case 'pgsql':
- $query = "select (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
+ $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 <= NOW() and EndTime > NOW() - 86400 * interval '1 second' ";
+ $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;
}
$smarty->assign( 'failed_jobs', $failed_jobs );
+ // Get the last completed jobs (last 24 hours)
+ $query = "";
+ $completed_jobs = array();
+
+ // Interval calculation
+ $end_date = mktime();
+ $start_date = $end_date - LAST_DAY;
+
+ $start_date = date( "Y-m-d H:m:s", $start_date );
+ $end_date = date( "Y-m-d H:m:s", $end_date );
+
+ 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 ";
+
+ 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";
+ break;
+ }
+ $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 ) ) {
+ array_push( $completed_jobs, $job);
+ }
+ }
+ $smarty->assign( 'completed_jobs', $completed_jobs );
+
$smarty->display('jobs.tpl');
?>
<body>
{popup_init src='./js/overlib.js'}
{include file=header.tpl}
-<a href="index.php">Back to main page</a>
+
+<div id="nav">
+ <a href="index.php">Dashboard</a> > Jobs list
+</div>
<div id="main_center">
+ <!-- Failed jobs -->
<div class="box">
<p class="title">Last failed jobs (limited to 10)</p>
<table>
</tr>
{foreach from=$failed_jobs item=job}
<tr>
- <td> <img width="20px" src="style/images/s_error.gif" alt=""/> </td>
+ <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>
{/foreach}
</table>
</div>
+ <!-- Completed jobs -->
<div class="box">
<p class="title">Last completed jobs</p>
- bkjlajkdjaf
+ <table>
+ <tr>
+ <th>Status</th>
+ <th>Job ID</th>
+ <th>BackupJob</th>
+ <th>Start Time</th>
+ <th>End Time</th>
+ <th>Elapsed time</th>
+ <th>Level</th>
+ <th>Pool</th>
+ </tr>
+ {foreach from=$completed_jobs item=job}
+ <tr>
+ <td> <img width="20px" src="style/images/s_ok.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}
+ </table>
</div>
</div>