From: Davide Franco Date: Fri, 10 Dec 2010 19:44:12 +0000 (+0100) Subject: bacula-web: New Stored bytes graph in main layout X-Git-Tag: Release-5.2.1~588 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=82c31f82c8c7fe97dacfce9c3ff6c2d072c186ff;p=bacula%2Fbacula bacula-web: New Stored bytes graph in main layout - New function in bweb.inc.php GetStoredBytesByInterval() - Added new graph in main layout for last 7 days stored bytes - Improved some internal code --- diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index 9e425595b5..d943d95552 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -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 ?> diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index e41bccc989..31562cab77 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -220,12 +220,47 @@ foreach( $pools as $pool ) { array_push( $data, $dbSql->GetPoolsStatistics( $pool ) ); } +echo '
';
+var_dump( $data );
+echo '
'; + $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 '
';
+//var_dump( $days );
+//echo '
'; + +echo '
';
+var_dump( $days_stored_bytes );
+echo '
'; + +$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 diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index f2ff017619..ccb6c1059d 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -42,6 +42,11 @@

Pools and volumes status

+ +
+

Total stored bytes (last 7 days)

+ +
{* {include file=volumes.tpl}*} @@ -89,6 +94,7 @@ + {include file="$last_report"}