}
}
- // Return Jobs statistics for a specific interval such as
- // - Completed jobs number
- // - Failed jobs number
- // - Waiting jobs number
- // The returned values will be used by a Bgraph classe
- public function GetJobsStatistics( $type = 'completed', $delay = LAST_DAY )
- {
- $query = "";
- $where = "";
- $jobs = "";
- $label = "";
- $res = "";
-
- // Interval calculation
- $end_date = mktime();
- $start_date = $end_date - $delay;
-
- $start_date = date( "Y-m-d H:i:s", $start_date );
- $end_date = date( "Y-m-d H:i:s", $end_date );
-
- $interval_where = "(EndTime BETWEEN '$start_date' AND '$end_date') AND ";
-
- // Job status
- switch( $type )
- {
- case 'completed':
- $where = $interval_where . "JobStatus = 'T' ";
- $label = "Completed";
- break;
- case 'terminated_errors':
- $where = $interval_where . "JobStatus = 'E' ";
- $label = "Terminated with errors";
- break;
- case 'failed':
- $where = $interval_where . "JobStatus = 'f' ";
- $label = "Failed";
- break;
- case 'waiting':
- $where = "JobStatus IN ('F','S','M','m','s','j','c','d','t') ";
- $label = "Waiting";
- break;
- case 'created':
- $where = "JobStatus = 'C' ";
- $label = "Created but not running";
- break;
- case 'running':
- $where = "JobStatus = 'R' ";
- $label = "Running";
- break;
- case 'error':
- $where = $interval_where . "JobStatus IN ('e','f') ";
- $label = "Errors";
- break;
- }
-
- $query = 'SELECT COUNT(JobId) AS count ';
- $query .= 'FROM Job ';
- $query .= "WHERE $where ";
-
- $res = $this->db_link->query( $query );
-
- if (PEAR::isError( $res ) ) {
- $this->TriggerDBError( 'Unable to get last' . $type . 'jobs status from catalog', $res);
- }else {
- $result = $res->fetchRow();
-
- if( isset($result['count']) and !empty($result['count']) )
- return $result['count'];
- else
- return 0;
- }
- } // end function GetJobsStatistics()
-
public function CountVolumesByPool( $pool_id )
{
$res = null;