From 98d435e954e456ad63f6fba41a4ff9b60df686b0 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Fri, 10 Dec 2010 19:01:53 +0100 Subject: [PATCH] bacula-web: Internal code improvments - 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 | 24 ++++++++++++++++++++++++ gui/bacula-web/config.inc.php | 2 ++ gui/bacula-web/index.php | 14 +++++++++----- gui/bacula-web/templates/index.tpl | 2 +- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index 4cb078990d..9e425595b5 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -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 ?> diff --git a/gui/bacula-web/config.inc.php b/gui/bacula-web/config.inc.php index 6d7c74265a..edc827e5bb 100644 --- a/gui/bacula-web/config.inc.php +++ b/gui/bacula-web/config.inc.php @@ -1,5 +1,7 @@ diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 8265f91350..e41bccc989 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -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() ); diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index d144e40069..f2ff017619 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -26,7 +26,7 @@ {t}Clients{/t} {$clientes_totales} - {t}Total bytes stored{/t} {$bytes_stored} + {t}Total bytes stored{/t} {$stored_bytes} {t}Total files{/t} {$files_totales} file(s) -- 2.39.5