}
// Return the list of Pools in a array
- public function Get_Pools_List()
+ public function get_Pools()
{
- $result = "";
- $query = "SELECT Name, PoolId FROM Pool";
+ $pools = array();
+ $query = "SELECT name, poolid FROM pool";
$result = $this->db_link->query ( $query );
- if( PEAR::isError( $result ) ) {
- $this->TriggerDBError( "Unable to get the pool list from catalog", $result );
- }else {
- return $result;
+ if( !PEAR::isError( $result ) ) {
+ while( $pool = $result->fetchRow() )
+ $pools[] = $pool;
+ return $pools;
}
+ $this->TriggerDBError( "Unable to get the pool list from catalog", $result );
}
public function Get_BackupJob_Names()
}
}
- public function CountVolumesByPool( $pool_id )
+ public function countVolumes( $pool_id = 'ALL' )
{
$res = null;
$nb_vol = null;
{
case 'sqlite':
case 'mysql':
- $query = 'SELECT COUNT(*) as vols,Pool.name as pool_name ';
+ $query = 'SELECT COUNT(*) as vols_count ';
$query .= 'FROM Media ';
- $query .= 'RIGHT JOIN Pool ON (Media.PoolId = Pool.PoolId) ';
- $query .= 'WHERE Media.poolid = ' . $pool_id;
break;
case 'pgsql':
- $query = 'SELECT COUNT(*) as vols,Pool.name as pool_name ';
+ $query = 'SELECT COUNT(*) as vols_count ';
$query .= 'FROM Media ';
- $query .= 'RIGHT JOIN Pool ON (Media.PoolId = Pool.PoolId) ';
- $query .= 'WHERE Media.poolid = ' . $pool_id;
- $query .= 'GROUP BY pool.name';
break;
}
- $res = $this->db_link->query( $query );
- if( PEAR::isError( $res ) )
- $this->triggerDBError( 'Unable to get volume number from pool', $res );
+ if( $pool_id != 'ALL' )
+ $query .= 'WHERE media.poolid = ' . $pool_id;
- $vols = $res->fetchRow( );
+ $res = $this->db_link->query( $query );
- return array( $vols['pool_name'], $vols['vols'] );
+ if( !PEAR::isError( $res ) ) {
+ $vols = $res->fetchRow( );
+ return $vols['vols_count'];
+ }
+
+ $this->triggerDBError( 'Unable to get volume number from pool', $res );
}
public function getStoredFiles( $start_timestamp, $end_timestamp, $job_name = 'ALL' )
$dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() );
unset($graph);
-// Pool and volumes graph
-$data = array();
-$graph = new CGraph( "graph1.png" );
+// Volumes by pools graph
+$vols_by_pool = array();
+$graph = new CGraph( "graph1.png" );
-$pools = $dbSql->Get_Pools_List();
-while( $pool = $pools->fetchRow( ) ) {
- array_push( $data, $dbSql->CountVolumesByPool( $pool['poolid']) );
-}
+foreach( $dbSql->get_Pools() as $pool )
+ $vols_by_pool[] = array( $pool['name'], $dbSql->countVolumes( $pool['poolid'] ) );
-$graph->SetData( $data, 'pie', 'text-data-single' );
+$graph->SetData( $vols_by_pool, 'pie', 'text-data-single' );
$graph->SetGraphSize( 400, 230 );
$graph->Render();