// Image border
$this->plot->SetImageBorderType( 'none' );
+ // Plot area (calculated regarding the width and height of the graph)
+ if( $this->type == 'pie' )
+ $this->plot->SetPlotAreaPixels( 10, 10, ($this->width / 2), $this->height-10 );
+
+ // Legend position (calculated regarding the width and height of the graph)
+ $this->plot->SetLegendPixels( ($this->width / 2) + 10, 25 );
- // Labels position
+ // Labels scale position
if( $this->type == 'pie' )
$this->plot->SetLabelScalePosition( 0.2 );
public function GetLastErrorJobs( $delay = LAST_DAY )
{
$query = "";
- $start_date = "";
- $end_date = "";
// Interval calculation
$end_date = mktime();
}
}
}
+
+ // 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:m:s", $start_date );
+ $end_date = date( "Y-m-d H:m:s", $end_date );
+
+ // Job status
+ switch( $type )
+ {
+ case 'completed':
+ $where = "AND JobStatus = 'T' ";
+ $label = "Completed";
+ break;
+ case 'completed_errors':
+ $where = "AND JobStatus = 'E' ";
+ $label = "Completed with errors";
+ break;
+ case 'failed':
+ $where = "AND JobStatus = 'f' ";
+ $label = "Failed";
+ break;
+ case 'waiting':
+ $where = "AND JobStatus IN ('F','S','M','m','s','j','c','d','t') ";
+ $label = "Waiting";
+ break;
+ case 'created':
+ $where = "AND JobStatus = 'C' ";
+ $label = "Created but not running";
+ break;
+ case 'running':
+ $where = "AND JobStatus = 'R' ";
+ $label = "Running";
+ break;
+ case 'error':
+ $where = "AND JobStatus IN ('e','f') ";
+ $label = "Errors";
+ break;
+ }
+ $query = 'SELECT COUNT(JobId) AS ' . $type . ' ';
+ $query .= 'FROM Job ';
+ $query .= "WHERE EndTime BETWEEN '$start_date' AND '$end_date' ";
+ $query .= $where;
+
+ $jobs = $this->db_link->query( $query );
+
+ if (PEAR::isError( $jobs ) ) {
+ die( "Unable to get last $type jobs status from catalog<br />" . $status->getMessage() );
+ }else {
+ $res = $jobs->fetchRow();
+ return array( $label , current($res) );
+ }
+ } // end function GetJobsStatistics()
+
+ public function GetPoolsStatistics()
+ {
+ }
} // end class Bweb
?>
*/
}
-// A simple graphing test with the new PHP BGraph classe
-$data = array( array( 'Completed', 15 ), array( 'Failed', 2 ) );
+// Create a graph for last 24 hours job status
+$data = array();
+$status = array( 'completed', 'completed_errors', 'failed', 'waiting', 'created', 'running', 'error' );
-$graph = new BGraph( "toto.png" );
+foreach( $status as $job_status ) {
+ array_push( $data, $dbSql->GetJobsStatistics( $job_status ) );
+}
+
+$graph = new BGraph( );
$graph->SetData( $data, 'pie', 'text-data-single' );
-$graph->SetTitle("Overall jobs status");
-$graph->SetGraphSize( 350, 200 );
-$graph->SetColors( array('green', 'red') );
+//$graph->SetTitle("Overall jobs status");
+$graph->SetGraphSize( 400, 230 );
+//$graph->SetColors( array('green', 'yellow','red','blue','white','green','red') );
$graph->Render();
$smarty->assign('graph', $graph->Get_Image_file() );
{include file=volumes.tpl}
</div>
+<!-- To be removed -->
+{if $server==""}
+ <!-- <img class="report" src="stats.php?server={$server}&tipo_dato=69&title=General%20report&modo_graph=bars&sizex=420&sizey=250&MBottom=20&legend=1" alt="" /> -->
+{else}
+ <!-- <img class="report" src="stats.php?server={$server}&tipo_dato=3&title={$server}&modo_graph=bars" alt="" /> -->
+{/if}
+
<div id="main_right">
+ <!-- Last job Status -->
+ <div class="box">
+ <p class="title">Job Status Report (last 24 hours)</p>
+ <img src="{$graph}" alt="" />
+ </div> <!-- end div box -->
<!-- General information -->
<div class="box">
<p class="title">General informations</p>
</div>
{include file="$last_report"}
-
- <div class="box">
- <p class="title">General report</p>
- {if $server==""}
- <!-- <img class="report" src="stats.php?server={$server}&tipo_dato=69&title=General%20report&modo_graph=bars&sizex=420&sizey=250&MBottom=20&legend=1" alt="" /> -->
- {else}
- <!-- <img class="report" src="stats.php?server={$server}&tipo_dato=3&title={$server}&modo_graph=bars" alt="" /> -->
- {/if}
- <img src="{$graph}" alt="" />
- </div> <!-- end div box -->
</div> <!-- end div main_right -->