public function GetLastJobs( $delay = LAST_DAY )
{
+ $query = "";
+ $start_date = "";
+ $end_date = "";
+
+ // Interval calculation
+ $end_date = mktime();
+ $start_date = $end_date - $delay;
+
+ $start_date = date( "Y-m-d H:m:s", $start_date );
+ $end_date = date( "Y-m-d H:m:s", $end_date );
+
switch( $this->driver )
{
case 'mysql':
- $query = "SELECT JobId, Name, EndTime, JobStatus ";
- $query .= "FROM Job ";
- $query .= "WHERE EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400 and JobStatus!='T'";
- break;
- case 'pgsql':
- $query = "SELECT JobId, Name, EndTime, JobStatus ";
- $query .= "FROM Job ";
- $query .= "WHERE EndTime <= NOW() and EndTime >NOW() - 86400 * interval '1 second' and JobStatus!= 'T'";
+ $query = 'SELECT COUNT(JobId) AS completed_jobs ';
+ $query .= 'FROM Job ';
+ $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' ";
+ $query .= "AND JobStatus = 'T'";
break;
}
- $lastjobstatus = $this->db_link->query( $query );
+ $jobs = $this->db_link->query( $query );
if (PEAR::isError( $lastjobstatus ) ) {
- die( "Unable to get last job status from catalog<br />" . $status->getMessage() );
+ die( "Unable to get last completed jobs status from catalog<br />" . $status->getMessage() );
}else {
- //echo "numrows = " . $lastjobstatus->numRows() . "<br />";
- return $lastjobstatus->numRows();
+ return $jobs->fetchRow();
}
} // end function GetLastJobStatus()
+ public function GetLastErrorJobs( $delay = LAST_DAY )
+ {
+ $query = "";
+ $start_date = "";
+ $end_date = "";
+
+ // Interval calculation
+ $end_date = mktime();
+ $start_date = $end_date - $delay;
+
+ $start_date = date( "Y-m-d H:m:s", $start_date );
+ $end_date = date( "Y-m-d H:m:s", $end_date );
+
+ //echo "start date: $start_date <br />";
+ //echo "end date: $end_date <br />";
+
+ switch( $this->driver )
+ {
+ default:
+ $query = 'SELECT COUNT(JobId) AS failed_jobs ';
+ $query .= 'FROM Job ';
+ $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' ";
+ $query .= "AND JobStatus = 'f'";
+ break;
+ }
+ $result = $this->db_link->query( $query );
+
+ if (PEAR::isError( $result ) ) {
+ die( "Unable to get last failed jobs status from catalog<br />query = $query <br />" . $result->getMessage() );
+ }else {
+ return $result->fetchRow( DB_FETCHMODE_ASSOC );
+ } // end if else
+ } // end function GetLastErrorJobs
+
+ public function Get_BackupJob_Names()
+ {
+ $query = "SELECT Name FROM Job GROUP BY Name";
+ $backupjobs = array();
+
+ $result = $this->db_link->query( $query );
+
+ if (PEAR::isError( $result ) ) {
+ die("Unable to get BackupJobs list from catalog" );
+ }else{
+ while( $backupjob = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) {
+ array_push( $backupjobs, $backupjob["Name"] );
+ }
+ return $backupjobs;
+ }
+ }
+
} // end class Bweb
class BGraph {
}//end class
?>
+
--- /dev/null
+<?php
+ define( 'LAST_DAY', 86400 );
+ define( 'LAST_WEEK', 604800 );
+ define( 'LAST_MONTH', 2678400 );
+?>
$tmp = $last24bytes->fetchRow();
}*/
-// report_select.tpl & last_run_report.tpl
-$res = $dbSql->db_link->query("select Name from Job group by Name");
+// Backup Job list for report.tpl and last_run_report.tpl
+$smarty->assign( 'total_name_jobs', $dbSql->Get_BackupJob_Names() );
+
+/*$res = $dbSql->db_link->query("select Name from Job group by Name");
$a_jobs = array();
-while ( $tmp = $res->fetchRow() )
+while( $tmp = $res->fetchRow() )
array_push($a_jobs, $tmp[0]);
$smarty->assign('total_name_jobs',$a_jobs);
$smarty->assign('time2',( (time())-2678400) ); // Current time - 1 month. <select> date
$res->free();
+*/
// Get volumes list (volumes.tpl)
$smarty->assign('pools',$dbSql->GetVolumeList() );
-// Last job status (default is last 24 hours)
-$smarty->assign( 'lastjobs', $dbSql->GetLastJobs() );
+// Completed jobs number
+$failed_jobs = $dbSql->GetLastJobs();
+$smarty->assign( 'completed_jobs', $failed_jobs['completed_jobs'] );
+
+// Failed jobs number (last_run_report.tpl)
+$failed_jobs = $dbSql->GetLastErrorJobs();
+$smarty->assign( 'failed_jobs', $failed_jobs['failed_jobs'] );
// last_run_report.tpl
if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) {
- $tmp = array();
- switch( $dbSql->driver )
- {
- case 'mysql':
- $query = "SELECT JobId, Name, EndTime, JobStatus ";
- $query .= "FROM Job ";
- $query .= "WHERE EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400 and JobStatus!='T'";
- break;
- case 'pgsql':
- $query = "SELECT JobId, Name, EndTime, JobStatus ";
- $query .= "FROM Job ";
- $query .= "WHERE EndTime <= NOW() and EndTime >NOW() - 86400 * interval '1 second' and JobStatus!= 'T'";
- break;
- }
-
- $status = $dbSql->db_link->query( $query );
-
- if (PEAR::isError( $status ) )
- die( "Unable to get last job status from catalog<br />" . $status->getMessage() );
-
- /*
- if ( $dbSql->driver == "mysql" )
- $status = $dbSql->db_link->query("select JobId,Name,EndTime,JobStatus from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 and JobStatus!='T'" )
- or die ("Error: query at row 95");
- if ( $dbSql->driver == "pgsql" )
- $status = $dbSql->db_link->query("select JobId,Name,EndTime,JobStatus from Job where EndTime <= NOW() and EndTime >NOW() - 86400 * interval '1 second' and JobStatus!= 'T'")
- or die ( "Error: query at row 98" );
- */
- $smarty->assign('status', $status->numRows() );
-
- if ( $status->numRows() ) {
- echo "status nomrow -> " . $status->numRows() . "<br />";
- while ( $res = $status->fetchRow() ) {
- array_push($tmp, $res);
- }
-
- $smarty->assign('errors_array',$tmp);
- }else {
- //echo "status pas marche ...<br />";
- }
- $status->free();
-
// Total Elapsed Time. Only for single Job.
if ( $dbSql->driver == "mysql" )
$ret = $dbSql->db_link->query("select UNIX_TIMESTAMP(EndTime)-UNIX_TIMESTAMP(StartTime) as elapsed from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-84600")
<div class="box">
<p class="title">Last 24 hours status</p>
-<!--
-<table width=100% align=center {if !$status }background="style/images/backlast.gif"{else}background="style/images/backlastred.gif" {/if} style="background-repeat:no-repeat" height=178px border=0 cellspacing=0 cellpadding=0>
- <tr>
- <td colspan=2 align=center style="font-size: 12px; font-weight: bold; background-repeat: repeat" background="style/images/bg6.png" height=25>
- {t}Status from last 24h{/t}
- </td>
- </tr>
--->
{* {if $mode == "Lite" && $smarty.get.Full_popup != "yes"} *}
<table>
<tr>
- <td class="label">Failed jobs</td> <td class="info">{$jobserror}</td>
+ <td class="label">Failed jobs</td> <td class="info">{$failed_jobs}</td>
</tr>
<tr>
- <td class="label">Completed jobs</td> <td class="info">{$total_jobs}</td>
+ <td class="label">Completed jobs</td> <td class="info">{$completed_jobs}</td>
</tr>
<tr>
- <td class="label">Backup elapsed time</td> <td class="info">{$totalElapsed}</td>
+ <td class="label">Elapsed time</td> <td class="info">{$totalElapsed}</td>
</tr>
<tr>
- <td class="label">Transferred bytes</td> <td class="info">{$bytes_totales}</td>
+ <td class="label">Transferred Bytes</td> <td class="info">{$bytes_totales}</td>
</tr>
<tr>
<td colspan=2 align=center>