]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Internal code improvments
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 10 Dec 2010 18:01:53 +0000 (19:01 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 3 Mar 2011 09:39:07 +0000 (10:39 +0100)
 - New function FetStored Bytes in bweb.inc.php
 - New constant in config.inc.php ALL ( mean no interval )
 - Improved stored bytes function in index.php

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

index 4cb078990d25072d68c67a3d74271cfff922076d..9e425595b5ccfca0d93d243e1ff13cc133136e3f 100644 (file)
@@ -560,5 +560,29 @@ class Bweb extends DB {
                        }
                }
                
+               public function GetStoredBytes( $delay = LAST_DAY )
+               {
+                       $query = "SELECT SUM(JobBytes) as stored_bytes FROM Job ";
+                       
+                       // Interval calculation
+                       $end_date   = mktime();
+                       $start_date = $end_date - $delay;
+                       
+                       $start_date = date( "Y-m-d H:m:s", $start_date );
+                       $end_date   = date( "Y-m-d H:m:s", $end_date );
+                       
+                       if( $delay != ALL ) {
+                               $query .= "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{
+                               return $result->fetchRow( DB_FETCHMODE_ASSOC );
+                       }
+               }
+               
 } // end class Bweb
 ?>
index 6d7c74265afed6c5341b8121b55519e3feb0e406..edc827e5bb640d27847a06477e40a75ded04fdec 100644 (file)
@@ -1,5 +1,7 @@
 <?php
+ // Intervalles in secondes
  define( 'LAST_DAY', 86400 );
  define( 'LAST_WEEK', 604800 );
  define( 'LAST_MONTH', 2678400 );
+ define( 'ALL', -1 );
 ?>
index 8265f91350efab0517c94d6b688eabd70051ef06..e41bccc98957038ee4fcbb98d2c41631766b1915 100644 (file)
@@ -82,6 +82,7 @@ $query = "";
   }
   $totalfiles->free();
   
+  /*
   switch( $dbSql->driver )
   {
        case 'mysql':
@@ -108,14 +109,18 @@ $query = "";
        $smarty->assign('total_jobs', $tmp[1]);
 
        $last24bytes->free();           
-  }
+  }*/
                
 // Database size
 $smarty->assign('database_size', $dbSql->GetDbSize());
 
-// Total bytes stored
-$bytes_stored = $dbSql->db_link->getOne("select SUM(VolBytes) from Media") or die ("Failed to get Total stored Bytes from catalog");
-$smarty->assign('bytes_stored', $dbSql->human_file_size($bytes_stored) );
+// Overall stored bytes
+$result = $dbSql->GetStoredBytes( ALL );
+$smarty->assign('stored_bytes', $dbSql->human_file_size($result['stored_bytes']) );
+
+// Total stored bytes since last 24 hours
+$result = $dbSql->GetStoredBytes( LAST_DAY );
+$smarty->assign('bytes_totales', $dbSql->human_file_size($result['stored_bytes']) );
 
 // Number of clients
 $nb_clients = $dbSql->Get_Nb_Clients();
@@ -218,7 +223,6 @@ foreach( $pools as $pool ) {
 $graph->SetData( $data, 'pie', 'text-data-single' );
 $graph->SetGraphSize( 400, 230 );
 
-
 $graph->Render();
 $smarty->assign('graph_pools', $graph->Get_Image_file() );
 
index d144e4006927522a99a80fdb3f832bc6896ef4a8..f2ff0176192148685037408659bf057873b05a1d 100644 (file)
@@ -26,7 +26,7 @@
            <td class="label">{t}Clients{/t}</td> <td class="info">{$clientes_totales}</td>
          </tr>
          <tr>
-               <td class="label">{t}Total bytes stored{/t}</td> <td class="info">{$bytes_stored}</td>
+               <td class="label">{t}Total bytes stored{/t}</td> <td class="info">{$stored_bytes}</td>
          </tr>
          <tr>
                <td class="label">{t}Total files{/t}</td> <td class="info">{$files_totales} file(s)</td>