From eb228d634acb2bff515690f5f3b3616b1b940622 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Thu, 2 Dec 2010 15:46:13 +0100 Subject: [PATCH] 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 --- gui/bacula-web/bgraph.inc.php | 4 ++-- gui/bacula-web/bweb.inc.php | 36 ++++++++++++++++++++++++++++- gui/bacula-web/graph1.png | Bin 0 -> 1531 bytes gui/bacula-web/index.php | 24 ++++++++++++++++--- gui/bacula-web/templates/index.tpl | 8 ++++++- 5 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 gui/bacula-web/graph1.png 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 0000000000000000000000000000000000000000..35a04ea3d894f4cdd9470be8cca64d373f51cff0 GIT binary patch literal 1531 zcmVX9W zUm^EDLIfiuWW8aAfz|Z79DDuZOZOmQY2oz}i9{liNF)-8L?V$$^kbyB8;~#KW#J#q z-I`P>W8SfPW4N1?qQQvwO6{R2v!-YfWy_5Tozv$VbzeqsRgXKw5K$IRX9z;X5 zP>MarkoQiw_PXD(*tJK2N;mTh@<8$o*|CISgP2q4`<5{5#%FVE)_eJZRc^36307lr z9H|QAtLu_MECR?zl@tfTFl5V;;vg0UWNk@l5FA4`EGZ3Qkw8|K95=>wPTCEuK3>oq zh+aKO<$+)&Yn`oA5anB}rh!!+h(!bWwB#&W{u$#aaehH62%aG;OU|R^TRb10Y8*r_ zew7Sj5kWq(bps?nT9}4>T5?|OX1o9hWGoTHqJk_fDY`+d4LS6&#taps5ZA4viQ% zL=r&2uWCV*nL*&L_9l#XLyJ||o>vQ^Cr6ZqyE+^`TpX`@rGr=!khw@k5H*4*AE*&W zIj%Tb{=iil2#q0;CD8rCVJYRSW4a6e#Kmsl>y%nSmLK@pg3Z>}53)Wnb+fhicjJpY zaz}SwYl%RnYA-dgsubk+zkd$}p(>HNNCf1eAeIay6v<{|RCHdd`godd2_*jZ{R0Hf z4r&L)53CG~ZO7a38FY6+=t^WNlI>`PA=S&D5IEj$5Cl#z^}YZ|Jdke+1O`?x(rOuG z9waI^y3*0uDy`VrY6J@0p9=Ug;q2e&(A!-QO9(P{TV*zg)q>pJjjtBub@R0XQW*$k zrxm&_0TB=ZIR+{6hxsKyibz1t<&x1fNQigWb$^-!i2#CX0qNiN0zkh8r~#xm?&4(M z)*gWbfUmCm@;`NfxaNB!`rciR0lE&_KVbaX;3x^Q`Y)eA-1Q11K%j5WvbFDsecMYV zawN{}NN;R!Mv%>9wF2S@f+O2C(h5lLFUD2+aj#W5$Pg=+EQ6A*pRuncAOa#F0wN#} z04ed^uYd@MfYbm|;Ha*E2uRZ)l+|v33P{OLOF-%ap+C!1KpqN0e{Q^hJQaleFM0&z zsUTEEQg)Y-5Ttai)BmlmfIJq2dWL~=BALA6?@s|?;GmutML-@5LOYvNNm*8d+dpevqKo-2?trzizy zKFQKayjqA=(2*&v*a6x#rQ|eVI5JzVw1?rO%+i*=O$;xXoynG-q=`za#au)pkw_#G hi9{liNF)+r>p!A0Fi;QFPxb%+002ovPDHLkV1n%~x5)qi literal 0 HcmV?d00001 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)

+
-- 2.39.5