From e283c002dd50e196237a302464991f13971804a4 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Sun, 24 Jul 2011 12:58:37 +0200 Subject: [PATCH] bacula-web: Added statistics graphs into client report page --- gui/bacula-web/client-report.php | 57 ++++++++++++++++++++-- gui/bacula-web/templates/client-report.tpl | 9 ++++ 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/gui/bacula-web/client-report.php b/gui/bacula-web/client-report.php index 6997645975..94c1a04b47 100644 --- a/gui/bacula-web/client-report.php +++ b/gui/bacula-web/client-report.php @@ -19,10 +19,13 @@ $dbSql = new Bweb(); - $clientid = ''; - $client = ''; - $client_jobs = array(); - $backup_jobs = array(); + $clientid = ''; + $client = ''; + $period = ''; + $client_jobs = array(); + $backup_jobs = array(); + $days_stored_bytes = array(); + $days_stored_files = array(); $job_levels = array( 'D' => 'Differential', 'I' => 'Incremental', 'F' => 'Full' ); @@ -35,6 +38,12 @@ $clientid = $http_get['client_id']; else die( "Application error: Client not specified " ); + + // Backup period + if( isset( $http_post['period'] ) ) + $period = $http_post['period']; + else + die( "Please specify a backup period" ); // Client informations $client = $dbSql->getClientInfos($clientid); @@ -59,8 +68,48 @@ }catch(PDOException $e) { CDBError::raiseError($e); } + $dbSql->tpl->assign( 'backup_jobs', $backup_jobs); + // Get the last 7 days interval (start and end) + $days = CTimeUtils::getLastDaysIntervals( $period ); + + // =============================================================== + // Last 7 days stored Bytes graph + // =============================================================== + $graph = new CGraph( "graph2.png" ); + + foreach( $days as $day ) { + $stored_bytes = $dbSql->getStoredBytes( $day['start'], $day['end'], 'ALL', $clientid); + $stored_bytes = CUtils::Get_Human_Size( $stored_bytes, 1, 'GB', false ); + $days_stored_bytes[] = array( date("m-d", $day['start']), $stored_bytes ); + } + + $graph->SetData( $days_stored_bytes, 'bars', 'text-data' ); + $graph->SetGraphSize( 400, 230 ); + $graph->SetYTitle( "GB" ); + + $graph->Render(); + $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() ); + + // =============================================================== + // Getting last 7 days stored files graph + // =============================================================== + $graph = new CGraph("graph3.png" ); + + foreach( $days as $day ) { + $stored_files = $dbSql->getStoredFiles( $day['start'], $day['end'], 'ALL', $clientid); + $days_stored_files[] = array( date("m-d", $day['start']), $stored_files ); + } + + $graph->SetData( $days_stored_files, 'bars', 'text-data' ); + $graph->SetGraphSize( 400, 230 ); + $graph->SetYTitle( "Files" ); + + $graph->Render(); + $dbSql->tpl->assign('graph_stored_files', $graph->Get_Image_file() ); + + $dbSql->tpl->assign( 'period', $period); $dbSql->tpl->assign( 'client_name', $client['name']); $dbSql->tpl->assign( 'client_os', $client['os']); $dbSql->tpl->assign( 'client_arch', $client['arch']); diff --git a/gui/bacula-web/templates/client-report.tpl b/gui/bacula-web/templates/client-report.tpl index 6f93b146f8..96eb86a6fe 100644 --- a/gui/bacula-web/templates/client-report.tpl +++ b/gui/bacula-web/templates/client-report.tpl @@ -54,6 +54,15 @@ {/foreach} +

Statistics - last {$period} days(s)

+ + + + + + +
+ -- 2.39.5