]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New Pools and volumes graph in main dashboard
authorDavide Franco <bacula-dev@dflc.ch>
Thu, 2 Dec 2010 14:46:13 +0000 (15:46 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:43 +0000 (14:39 +0200)
 - 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
gui/bacula-web/bweb.inc.php
gui/bacula-web/graph1.png [new file with mode: 0644]
gui/bacula-web/index.php
gui/bacula-web/templates/index.tpl

index 9f0fb218a3d27f5f70f367d16e6f2ad2ef7c4b9c..ddb8e25d302a30ee528f32bc730dee13bc6ef446 100644 (file)
@@ -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 )
index a201188c9b3ea1996ca5a551fc9b1e7db1ffd80e..4c968212f72186eb9cfecba6e28dc3140543fcfd 100644 (file)
@@ -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 . '<br />';
+                               //echo 'Pool name ' . $pool_name . '<br />';
+                               $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 (file)
index 0000000..35a04ea
Binary files /dev/null and b/gui/bacula-web/graph1.png differ
index 55c6f88ff88d3f72abe55e5cbf36f7d550e3dc11..151093b9b76c753e1d9b443382205f67f25dd729 100644 (file)
@@ -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');
index 03031cecd746a5c164512873b40cfde3ccd2dc3c..507ef4fd1b6247f3f907a3528d529525e7647b2e 100644 (file)
   <!-- Last job Status -->
   <div class="box">
        <p class="title">Job Status Report (last 24 hours)</p>
-         <img src="{$graph}" alt="" /> 
+         <img src="{$graph_jobs}" alt="" />
+  </div> <!-- end div box -->
+  
+  <!-- Pools and Volumes Status -->
+  <div class="box">
+       <p class="title">Job Status Report (last 24 hours)</p>
+         <img src="{$graph_pools}" alt="" />
   </div> <!-- end div box -->
   <!-- General information -->
   <div class="box">