X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=gui%2Fbacula-web%2Findex.php;h=b459a08a4c768ebf195b3999b6a2e7001b0eb452;hb=fb684092f93108e0cccf3b2b0f383767ea9d28c4;hp=538f62b75300f909dc9fca8211eabf5b25103538;hpb=6178a2bcd0e9e1a7c025fda76a756df890aa0637;p=bacula%2Fbacula diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 538f62b753..b459a08a4c 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -1,7 +1,8 @@ tpl->assign( "dbs", $dbSql->bwcfg->Count_Catalogs() ); +// Assign dbs +/* +if ( count($dbSql->dbs) >1 ) { + $smarty->assign("dbs", $dbSql->dbs); + $smarty->assign("dbs_now", $_SESSION['DATABASE']); +} +*/ +// Catalog count +$catalog_nb = $dbSql->catalog_nb; +$dbSql->tpl->assign( 'catalog_nb', $catalog_nb ); + +// Stored files number +$totalfiles = $dbSql->GetStoredFiles( ALL ); +$dbSql->tpl->assign('stored_files',$totalfiles); + +// Database size +$dbSql->tpl->assign('database_size', $dbSql->GetDbSize()); -$mode = ""; +// Overall stored bytes +$result = $dbSql->GetStoredBytes( ALL ); +$dbSql->tpl->assign('stored_bytes', Utils::Get_Human_Size( $result['stored_bytes'] ) ); -$smarty->compile_check = true; -$smarty->debugging = false; -$smarty->force_compile = true; +// Total stored bytes since last 24 hours +$result = $dbSql->GetStoredBytes( LAST_DAY ); +$dbSql->tpl->assign('bytes_last', Utils::Get_Human_Size( $result['stored_bytes'] ) ); -$smarty->template_dir = "./templates"; -$smarty->compile_dir = "./templates_c"; -$smarty->config_dir = "./configs"; +// Total stored files since last 24 hours +$files_last = $dbSql->GetStoredFiles( LAST_DAY ); +$dbSql->tpl->assign('files_last', $files_last ); -/* -$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"; +// 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' ) ); -$smarty->assign( "mode", $mode ); +// Last 24 hours failed jobs number +$dbSql->tpl->assign( 'failed_jobs', $dbSql->CountJobs( LAST_DAY, 'failed' ) ); -// Determine which template to show -$indexreport = $dbSql->get_config_param( "IndexReport" ); +// Last 24 hours waiting jobs number +$dbSql->tpl->assign( 'waiting_jobs', $dbSql->CountJobs( LAST_DAY, 'waiting' ) ); -if( $indexreport == 0 ) { - $smarty->assign( "last_report", "last_run_report.tpl" ); -}else { - $smarty->assign( "last_report", "report_select.tpl" ); +// 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 ) ); } -// Assign to template catalogs number -$smarty->assign( "dbs", $dbSql->Get_Nb_Catalogs() ); +$graph = new BGraph( "graph.png" ); +$graph->SetData( $data, 'pie', 'text-data-single' ); +$graph->SetGraphSize( 400, 230 ); -//Assign dbs -/* -if ( count($dbSql->dbs) >1 ) { - $smarty->assign("dbs", $dbSql->dbs); - $smarty->assign("dbs_now", $_SESSION['DATABASE']); +$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->CountVolumesByPool( $pool ) ); } -*/ -// generaldata.tpl & last_run_report.tpl ( Last 24 hours report ) -$last24bytes = ""; -$query = ""; +$graph->SetData( $data, 'pie', 'text-data-single' ); +$graph->SetGraphSize( 400, 230 ); -/*$client = $dbSql->db_link->query("select count(*) from Client") - or die ("Error query: 1");*/ - $totalfiles = $dbSql->db_link->query("select count(FilenameId) from Filename") or die ("Error query: 2"); - - if ( PEAR::isError( $totalfiles ) ) { - die( "Unable to get Total Files information from catalog" . $totalfiles->getMessage() ); - }else { - $tmp = $totalfiles->fetchRow(); - $smarty->assign('files_totales',$tmp[0]); - } - $totalfiles->free(); - - switch( $dbSql->driver ) - { - case 'mysql': - $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400"; - break; - case 'pgsql': - $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and EndTime > NOW() - 86400 * interval '1 second'"; - break; - default: - $query = "select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400"; - break; - } - - $last24bytes = $dbSql->db_link->query( $query ) or die ("Failed to get Total Job Bytes from catalog"); - - if ( PEAR::isError( $last24bytes ) ) { - die( "Unable to get Total Job Bytes from catalog" . $last24bytes->getMessage() ); - }else { - $tmp = $last24bytes->fetchRow(); - //var_dump( $tmp ); - // Transfered bytes since last 24 hours - $smarty->assign('bytes_totales', $dbSql->human_file_size( $tmp[0] ) ); - - $smarty->assign('total_jobs', $tmp[1]); - - $last24bytes->free(); - } - -// Database size -$smarty->assign('database_size', $dbSql->GetDbSize()); +$graph->Render(); +$dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() ); -// 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) ); +// Last 7 days stored Bytes graph +$data = array(); +$graph = new BGraph( "graph2.png" ); +$days = array(); -// Number of clients -$nb_clients = $dbSql->Get_Nb_Clients(); -$smarty->assign('clientes_totales',$nb_clients["nb_client"] ); - -/*if ( empty($tmp[0]) ) { // No data for last 24, search last 48 - if ( $dbSql->driver == "mysql" ) - $last24bytes = $dbSql->db_link->query("select sum(JobBytes) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-172800" ); - if ( $dbSql->driver == "pgsql") - $last24bytes = $dbSql->db_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(); -}*/ +// 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 ) ) ); +} -// Backup Job list for report.tpl and last_run_report.tpl -$smarty->assign( 'total_name_jobs', $dbSql->Get_BackupJob_Names() ); +$days_stored_bytes = array(); + +foreach( $days as $day ) { + array_push( $days_stored_bytes, $dbSql->GetStoredBytesByInterval( $day['start'], $day['end'] ) ); +} -/*$res = $dbSql->db_link->query("select Name from Job group by Name"); +$graph->SetData( $days_stored_bytes, 'bars', 'text-data' ); +$graph->SetGraphSize( 400, 230 ); -$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.