From: Davide Franco Date: Thu, 2 Dec 2010 14:46:13 +0000 (+0100) Subject: bacula-web: New Pools and volumes graph in main dashboard X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eb228d634acb2bff515690f5f3b3616b1b940622;p=bacula%2Fbacula bacula-web: New Pools and volumes graph in main dashboard - New function Get_Pools_List() in bweb classe - New function GetPoolsStatistics in bweb classe - Fixed bug in bgraph::construct with output_file variable - New Pools usage in main Dashboard --- diff --git a/gui/bacula-web/bgraph.inc.php b/gui/bacula-web/bgraph.inc.php index 9f0fb218a3..ddb8e25d30 100644 --- a/gui/bacula-web/bgraph.inc.php +++ b/gui/bacula-web/bgraph.inc.php @@ -19,9 +19,9 @@ class BGraph{ function __construct( $filename = "graph.png" ) { if( !empty($filename) ) - $this->output_file = "graph.png"; - else $this->output_file = $filename; + else + $this->output_file = 'graph.png'; } public function SetData( $data_in, $type, $data_type, $shading = 5 ) diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index a201188c9b..4c968212f7 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -400,6 +400,26 @@ class Bweb extends DB { } // end if else } // end function GetLastErrorJobs + // Return the list of Pools in a array + public function Get_Pools_List() + { + $pool_list = array(); + $result = ""; + + $query = "SELECT Name, PoolId FROM Pool"; + + $result = $this->db_link->query ( $query ); + + if( PEAR::isError( $result ) ) { + die( "Unable to get the pool list from catalog" ); + }else { + while( $pool = $result->fetchRow(DB_FETCHMODE_ASSOC) ) { + array_push( $pool_list, array( $pool['Name'] => $pool['PoolId'] ) ); + } + return $pool_list; + } + } + public function Get_BackupJob_Names() { $query = "SELECT Name FROM Job GROUP BY Name"; @@ -522,8 +542,22 @@ class Bweb extends DB { } } // end function GetJobsStatistics() - public function GetPoolsStatistics() + public function GetPoolsStatistics( $pools ) { + foreach( $pools as $pool_name => $pool ) { + //var_dump( $pool ); + $query = "SELECT COUNT(*) AS nb_vol FROM Media WHERE PoolId = '$pool'"; + //echo $query . '
'; + //echo 'Pool name ' . $pool_name . '
'; + $result = $this->db_link->query( $query ); + + if( PEAR::isError( $result ) ) { + die("Unable to get volume number from catalog"); + }else{ + $nb_vol = $result->fetchRow(); + return array( $pool_name, $nb_vol['nb_vol'] ); + } + } } } // end class Bweb diff --git a/gui/bacula-web/graph1.png b/gui/bacula-web/graph1.png new file mode 100644 index 0000000000..35a04ea3d8 Binary files /dev/null and b/gui/bacula-web/graph1.png differ diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 55c6f88ff8..151093b9b7 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -187,7 +187,7 @@ else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){ */ } -// Create a graph for last 24 hours job status +// Last 24 hours Job status graph $data = array(); $status = array( 'completed', 'completed_errors', 'failed', 'waiting', 'created', 'running', 'error' ); @@ -195,14 +195,32 @@ foreach( $status as $job_status ) { array_push( $data, $dbSql->GetJobsStatistics( $job_status ) ); } -$graph = new BGraph( ); +$graph = new BGraph( "graph.png" ); $graph->SetData( $data, 'pie', 'text-data-single' ); //$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() ); +$smarty->assign('graph_jobs', $graph->Get_Image_file() ); +unset($graph); + +// Pool and volumes graph +$data = array(); +$graph = new BGraph( "graph1.png" ); + +$pools = $dbSql->Get_Pools_List(); + +foreach( $pools as $pool ) { + array_push( $data, $dbSql->GetPoolsStatistics( $pool ) ); +} + +$graph->SetData( $data, 'pie', 'text-data-single' ); +$graph->SetGraphSize( 400, 230 ); + + +$graph->Render(); +$smarty->assign('graph_pools', $graph->Get_Image_file() ); if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes") $smarty->display('full_popup.tpl'); diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index 03031cecd7..507ef4fd1b 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -32,7 +32,13 @@

Job Status Report (last 24 hours)

- + +
+ + +
+

Job Status Report (last 24 hours)

+