X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=gui%2Fbacula-web%2Findex.php;h=976fb832a7adcf8bd2a63f5966d978a670589301;hb=bed4d6c620101ad0893a1eb28bfdb7bcf7511b00;hp=96fe053f23d6418c695c09239396843ff9945b80;hpb=1e57dccd107dc1633b8301050d9446700fe23a17;p=bacula%2Fbacula diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 96fe053f23..976fb832a7 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -14,153 +14,159 @@ | GNU General Public License for more details. | +-------------------------------------------------------------------------+ */ -// Last Err: session_start(); -require ("paths.php"); -require($smarty_path."Smarty.class.php"); -include "classes.inc"; +require_once('paths.php'); +include_once( 'bweb.inc.php' ); -$smarty = new Smarty; // Template engine $dbSql = new Bweb(); -$smarty->compile_check = true; -$smarty->debugging = false; -$smarty->force_compile = true; +$mode = ""; -$smarty->template_dir = "./templates"; -$smarty->compile_dir = "./templates_c"; -$smarty->config_dir = "./configs"; -$smarty->config_load("bacula.conf"); // Load config file -$mode = $smarty->get_config_vars("mode"); // Lite o Extend? +/* +// Getting mode from config file +$mode = $dbSql->get_config_param("mode"); +if( $mode == false ) + $mode = "Lite"; -require("lang.php"); +$smarty->assign( "mode", $mode ); +*/ + +// Assign to template catalogs number +$dbSql->tpl->assign( "dbs", $dbSql->Get_Nb_Catalogs() ); //Assign dbs +/* if ( count($dbSql->dbs) >1 ) { $smarty->assign("dbs", $dbSql->dbs); $smarty->assign("dbs_now", $_SESSION['DATABASE']); } +*/ + +// Stored files number +$totalfiles = $dbSql->GetStoredFiles( ALL ); +$dbSql->tpl->assign('stored_files',$totalfiles); + +// Database size +$dbSql->tpl->assign('database_size', $dbSql->GetDbSize()); + +// Overall stored bytes +$result = $dbSql->GetStoredBytes( ALL ); +$dbSql->tpl->assign('stored_bytes', $dbSql->human_file_size($result['stored_bytes']) ); + +// Total stored bytes since last 24 hours +$result = $dbSql->GetStoredBytes( LAST_DAY ); +$dbSql->tpl->assign('bytes_last', $dbSql->human_file_size($result['stored_bytes']) ); + +// Total stored files since last 24 hours +$files_last = $dbSql->GetStoredFiles( LAST_DAY ); +$dbSql->tpl->assign('files_last', $files_last ); + + +// Number of clients +$nb_clients = $dbSql->Get_Nb_Clients(); +$dbSql->tpl->assign('clientes_totales',$nb_clients["nb_client"] ); + +// Backup Job list for report.tpl and last_run_report.tpl +$dbSql->tpl->assign( 'jobs_list', $dbSql->Get_BackupJob_Names() ); + +// Get volumes list (volumes.tpl) +$dbSql->tpl->assign('pools', $dbSql->GetVolumeList() ); + +// Last 24 hours completed jobs number +$dbSql->tpl->assign( 'completed_jobs', $dbSql->CountJobs( LAST_DAY, 'completed' ) ); + +// Last 24 hours failed jobs number +$dbSql->tpl->assign( 'failed_jobs', $dbSql->CountJobs( LAST_DAY, 'failed' ) ); + +// Last 24 hours waiting jobs number +$dbSql->tpl->assign( 'waiting_jobs', $dbSql->CountJobs( LAST_DAY, 'waiting' ) ); + +// Last 24 hours elapsed time (last_run_report.tpl) +//$smarty->assign( 'elapsed_jobs', $dbSql->Get_ElapsedTime_Job() ); + +// Last 24 hours Job Levels +$dbSql->tpl->assign( 'incr_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'I') ); +$dbSql->tpl->assign( 'diff_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'D') ); +$dbSql->tpl->assign( 'full_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'F') ); + +// Last 24 hours Job status graph +$data = array(); +$status = array( 'completed', 'terminated_errors', 'failed', 'waiting', 'created', 'running', 'error' ); + +foreach( $status as $job_status ) { + array_push( $data, $dbSql->GetJobsStatistics( $job_status ) ); +} + +$graph = new BGraph( "graph.png" ); +$graph->SetData( $data, 'pie', 'text-data-single' ); +$graph->SetGraphSize( 400, 230 ); + +$graph->Render(); +$dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() ); +unset($graph); + +// Pool and volumes graph +$data = array(); +$graph = new BGraph( "graph1.png" ); + +$pools = $dbSql->Get_Pools_List(); + +foreach( $pools as $pool ) { + array_push( $data, $dbSql->GetPoolsStatistics( $pool ) ); +} + +$graph->SetData( $data, 'pie', 'text-data-single' ); +$graph->SetGraphSize( 400, 230 ); + +$graph->Render(); +$dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() ); + +// Last 7 days stored Bytes graph +$data = array(); +$graph = new BGraph( "graph2.png" ); +$days = array(); + +// Get the last 7 days interval (start and end) +for( $c = 6 ; $c >= 0 ; $c-- ) { + $today = ( mktime() - ($c * LAST_DAY) ); + array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) ); +} -// generaldata.tpl & last_run_report.tpl (last24bytes) -$client = $dbSql->link->query("select count(*) from Client") - or die ("Error query: 1"); -$totalfiles = $dbSql->link->query("select count(FilenameId) from Filename") - or die ("Error query: 2"); -if ( $dbSql->driver == "mysql") - $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400") - or die ("Error query: 3"); -if ( $dbSql->driver == "pgsql") - $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'") - or die ("Error query: 3"); -$bytes_stored =& $dbSql->link->getOne("select SUM(VolBytes) from Media") - or die ("Error query: 4"); - -$smarty->assign('database_size', $dbSql->GetDbSize()); -$smarty->assign('bytes_stored',$bytes_stored); - -$tmp = $client->fetchRow(); -$smarty->assign('clientes_totales',$tmp[0]); - -$tmp = $last24bytes->fetchRow(); -/*if ( empty($tmp[0]) ) { // No data for last 24, search last 48 - if ( $dbSql->driver == "mysql" ) - $last24bytes = $dbSql->link->query("select sum(JobBytes) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-172800" ); - if ( $dbSql->driver == "pgsql") - $last24bytes = $dbSql->link->query("select sum(JobBytes) from Job where Endtime <= NOW() and EndTime > NOW()-172800 * interval '1 second'" ) - or die ("Error query: 4.1"); - $smarty->assign('when',"yesterday"); - $tmp = $last24bytes->fetchRow(); -}*/ - -$smarty->assign('bytes_totales',$tmp[0]); -$smarty->assign('total_jobs', $tmp[1]); - -$tmp = $totalfiles->fetchRow(); -$smarty->assign('files_totales',$tmp[0]); - -$client->free(); -$totalfiles->free(); -$last24bytes->free(); - - - -// report_select.tpl & last_run_report.tpl -$res = $dbSql->link->query("select Name from Job group by Name"); -$a_jobs = array(); -while ( $tmp = $res->fetchRow() ) - array_push($a_jobs, $tmp[0]); -$smarty->assign('total_name_jobs',$a_jobs); -$smarty->assign('time2',( (time())-2678400) ); // Current time - 1 month.