X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=gui%2Fbacula-web%2Fbackupjob-report.php;h=fd9f4391f07b6741095b07d58c2cfa5bf7ed0ed6;hb=fb684092f93108e0cccf3b2b0f383767ea9d28c4;hp=26a1b2308d81a90badca2f0b82e8e74fcd4a6d17;hpb=4f9375e9e428fdff1a48aac90ca1487b4f919887;p=bacula%2Fbacula diff --git a/gui/bacula-web/backupjob-report.php b/gui/bacula-web/backupjob-report.php index 26a1b2308d..fd9f4391f0 100644 --- a/gui/bacula-web/backupjob-report.php +++ b/gui/bacula-web/backupjob-report.php @@ -1,60 +1,114 @@ -compile_check = true; - $smarty->debugging = false; - $smarty->force_compile = true; - - $smarty->template_dir = "./templates"; - $smarty->compile_dir = "./templates_c"; - $smarty->config_dir = "./configs"; - - $backupjob_name = ""; - - if( isset( $_POST["backupjob_name"] ) ) - $backupjob_name = $_POST["backupjob_name"]; - elseif( isset( $_GET["backupjob_name"] ) ) - $backupjob_name = $_GET["backupjob_name"]; - else - die( "Please specify a backup job name " ); - - $smarty->assign('backupjob_name', $backupjob_name ); - - // 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 ) ) ); - } - - $days_stored_bytes = array(); - - foreach( $days as $day ) { - array_push( $days_stored_bytes, $dbSql->GetStoredBytesByJob( $backupjob_name, $day['start'], $day['end'] ) ); - } - - $graph->SetData( $days_stored_bytes, 'bars', 'text-data' ); - $graph->SetGraphSize( 400, 230 ); - - $graph->Render(); - $smarty->assign('graph_stored_bytes', $graph->Get_Image_file() ); - + // =============================================================== + // Get Backup Job name from GET or POST + // =============================================================== + if( isset( $_POST["backupjob_name"] ) ) + $backupjob_name = $_POST["backupjob_name"]; + elseif( isset( $_GET["backupjob_name"] ) ) + $backupjob_name = $_GET["backupjob_name"]; + else + die( "Please specify a backup job name " ); + + // 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 ) ) ); + } - // Process and display the template - $smarty->display('backupjob-report.tpl'); + // Generate Backup Job report period string + $backupjob_period = "From " . date( "Y-m-d", mktime()-LAST_WEEK ) . " to " . date( "Y-m-d", mktime() ); -?> \ No newline at end of file + // =============================================================== + // Last 7 days stored Bytes graph + // =============================================================== + $graph = new BGraph( "graph2.png" ); + + foreach( $days as $day ) + array_push( $days_stored_bytes, $dbSql->GetStoredBytesByJob( $backupjob_name, $day['start'], $day['end'] ) ); + + // Calculate total bytes for this period + foreach( $days_stored_bytes as $day ) + $backupjob_bytes += $day[1]; + + $graph->SetData( $days_stored_bytes, 'bars', 'text-data' ); + $graph->SetGraphSize( 400, 230 ); + + $graph->Render(); + $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() ); + + // =============================================================== + // Getting last 7 days stored files graph + // =============================================================== + $graph = new BGraph("graph3.png" ); + + foreach( $days as $day ) + array_push( $days_stored_files, $dbSql->GetStoredFilesByJob( $backupjob_name, $day['start'], $day['end'] ) ); + + // Calculate total files for this period + foreach( $days_stored_files as $day ) + $backupjob_files += $day[1]; + + $graph->SetData( $days_stored_files, 'bars', 'text-data' ); + $graph->SetGraphSize( 400, 230 ); + + $graph->Render(); + $dbSql->tpl->assign('graph_stored_files', $graph->Get_Image_file() ); + + // Last 10 jobs + $query = "SELECT JobId, Level, JobFiles, JobBytes, JobStatus, EndTime, Name "; + $query .= "FROM Job "; + $query .= "WHERE Name = '$backupjob_name' "; + $query .= "ORDER BY EndTime DESC "; + $query .= "LIMIT 10 "; + + $jobs = array(); + $joblevel = array( 'I' => 'Incr', 'D' => 'Diff', 'F' => 'Full' ); + $result = $dbSql->db_link->query( $query ); + + if( ! PEAR::isError( $result ) ) + { + while( $job = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) { + $job['Level'] = $joblevel[ $job['Level'] ]; + array_push( $jobs, $job); + } + }else + die( "Unable to get last jobs from catalog " . $result->getMessage() ); + + $dbSql->tpl->assign('jobs', $jobs ); + $dbSql->tpl->assign('backupjob_name', $backupjob_name ); + $dbSql->tpl->assign('backupjob_period', $backupjob_period ); + $dbSql->tpl->assign('backupjob_bytes', $backupjob_bytes ); + $dbSql->tpl->assign('backupjob_files', $backupjob_files ); + + // Process and display the template + $dbSql->tpl->display('backupjob-report.tpl'); + +?>