]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New Stored bytes graph in main layout
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 10 Dec 2010 19:44:12 +0000 (20:44 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:43:32 +0000 (14:43 +0200)
 - New function in bweb.inc.php GetStoredBytesByInterval()
 - Added new graph in main layout for last 7 days stored bytes
 - Improved some internal code

gui/bacula-web/bweb.inc.php
gui/bacula-web/index.php
gui/bacula-web/templates/index.tpl

index 9e425595b5ccfca0d93d243e1ff13cc133136e3f..d943d955527d9c651c180455104125e57551579a 100644 (file)
@@ -584,5 +584,18 @@ class Bweb extends DB {
                        }
                }
                
+               public function GetStoredBytesByInterval( $start_date, $end_date )
+               {
+                       $query = "SELECT SUM(JobBytes) as stored_bytes, EndTime FROM Job WHERE EndTime BETWEEN '$start_date' AND '$end_date'";
+                       
+                       $result = $this->db_link->query( $query );
+                       
+                       if( PEAR::isError( $result ) ) {
+                               die( "Unable to get Job Bytes from catalog" );
+                       }else{
+                               $tmp = $result->fetchRow( DB_FETCHMODE_ASSOC );
+                               return array( $tmp['EndTime'], $tmp['stored_bytes'] );
+                       }
+               }
 } // end class Bweb
 ?>
index e41bccc98957038ee4fcbb98d2c41631766b1915..31562cab77c37baf609fb28ad8fe599ab401beb6 100644 (file)
@@ -220,12 +220,47 @@ foreach( $pools as $pool ) {
        array_push( $data, $dbSql->GetPoolsStatistics( $pool ) );
 }
 
+echo '<pre>';
+var_dump( $data );
+echo '</pre>';
+
 $graph->SetData( $data, 'pie', 'text-data-single' );
 $graph->SetGraphSize( 400, 230 );
 
 $graph->Render();
 $smarty->assign('graph_pools', $graph->Get_Image_file() );
 
+// Stored Bytes last 7 days
+$data  = array();
+$graph = new BGraph( "graph2.png" );
+$days  = array();
+
+// Get the last 7 days interval (start and end)
+for( $c = 0 ; $c < 7 ; $c++ ) {
+       $today = ( mktime() - ($c * 86400) );
+       array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) );
+}
+
+$days_stored_bytes = array();
+
+foreach( $days as $day ) {
+  array_push( $days_stored_bytes, $dbSql->GetStoredBytesByInterval( $day['start'], $day['end'] ) );
+}
+
+//echo '<pre>';
+//var_dump( $days );
+//echo '</pre>';
+
+echo '<pre>';
+var_dump( $days_stored_bytes );
+echo '</pre>';
+
+$graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
+$graph->SetGraphSize( 400, 230 );
+
+$graph->Render();
+$smarty->assign('graph_stored_bytes', $graph->Get_Image_file() );
+
 if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes")
         $smarty->display('full_popup.tpl');
 else
index f2ff0176192148685037408659bf057873b05a1d..ccb6c1059d957391f9dda6d7c257cf5ade5f160d 100644 (file)
        <p class="title">Pools and volumes status</p>
          <img src="{$graph_pools}" alt="" />
   </div> <!-- end div box -->
+  
+  <div class="box">
+       <p class="title">Total stored bytes (last 7 days)</p>
+         <img src="{$graph_stored_bytes}" alt="" />
+  </div> <!-- end div box -->
 
 {* {include file=volumes.tpl}*}
 
@@ -89,6 +94,7 @@
          <img src="{$graph_jobs}" alt="" />
   </div> <!-- end div box -->
   
+
   {include file="$last_report"}        
 
 </div> <!-- end div main_right -->