3 +-------------------------------------------------------------------------+
4 | Copyright 2010-2011, Davide Franco |
6 | This program is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU General Public License |
8 | as published by the Free Software Foundation; either version 2 |
9 | of the License, or (at your option) any later version. |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 +-------------------------------------------------------------------------+
18 include_once( 'config.inc.php' );
20 $dbSql = new Bweb();
\r
27 $days_stored_bytes = array();
28 $days_stored_files = array();
30 // ===============================================================
31 // Get Backup Job name from GET or POST
\r
32 // ===============================================================
33 if( isset( $_POST["backupjob_name"] ) )
\r
34 $backupjob_name = $_POST["backupjob_name"];
\r
35 elseif( isset( $_GET["backupjob_name"] ) )
\r
36 $backupjob_name = $_GET["backupjob_name"];
\r
38 die( "Please specify a backup job name " );
\r
40 // Generate Backup Job report period string
41 $backupjob_period = "From " . date( "Y-m-d", (NOW-WEEK) ) . " to " . date( "Y-m-d", NOW );
43 // Calculate total bytes for this period
44 $backupjob_bytes = $dbSql->getStoredBytes( LAST_WEEK, NOW, $backupjob_name );
45 $backupjob_bytes = CUtils::Get_Human_Size( $backupjob_bytes );
47 // Get the last 7 days interval (start and end)
\r
48 for( $c = 6 ; $c >= 0 ; $c-- ) {
\r
49 $today = NOW - ($c * DAY);
50 $days[] = CTimeUtils::get_Day_Intervals($today);
53 // ===============================================================
54 // Last 7 days stored Bytes graph
\r
55 // ===============================================================
56 $graph = new CGraph( "graph2.png" );
58 foreach( $days as $day ) {
59 $stored_bytes = $dbSql->getStoredBytes( $day['start'], $day['end'], $backupjob_name);
60 $stored_bytes = CUtils::Get_Human_Size( $stored_bytes, 1, 'GB', false );
61 $days_stored_bytes[] = array( date("m-d", $day['start']), $stored_bytes );
64 $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
\r
65 $graph->SetGraphSize( 400, 230 );
\r
66 $graph->SetYTitle( "GB" );
69 $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
71 // ===============================================================
72 // Getting last 7 days stored files graph
\r
73 // ===============================================================
74 $graph = new CGraph("graph3.png" );
76 foreach( $days as $day )
\r
77 array_push( $days_stored_files, $dbSql->GetStoredFilesByJob( $backupjob_name, $day['start'], $day['end'] ) );
\r
79 // Calculate total files for this period
\r
80 foreach( $days_stored_files as $day )
\r
81 $backupjob_files += $day[1];
\r
83 $graph->SetData( $days_stored_files, 'bars', 'text-data' );
\r
84 $graph->SetGraphSize( 400, 230 );
\r
85 $graph->SetYTitle( "Files" );
88 $dbSql->tpl->assign('graph_stored_files', $graph->Get_Image_file() );
91 $query = "SELECT JobId, Level, JobFiles, JobBytes, JobStatus, StartTime, EndTime, Name ";
92 $query .= "FROM Job ";
\r
93 $query .= "WHERE Name = '$backupjob_name' ";
\r
94 $query .= "ORDER BY EndTime DESC ";
\r
95 $query .= "LIMIT 10 ";
\r
98 $joblevel = array( 'I' => 'Incr', 'D' => 'Diff', 'F' => 'Full' );
\r
99 $result = $dbSql->db_link->query( $query );
\r
101 if( ! PEAR::isError( $result ) )
\r
103 while( $job = $result->fetchRow() )
105 // Job level description
106 $job['joblevel'] = $joblevel[ $job['level'] ];
108 // Job execution execution time
109 $job['elapsedtime'] = CTimeUtils::Get_Elapsed_Time( $job['starttime'], $job['endtime'] );
112 if( count($jobs) % 2)
113 $job['row_class'] = 'odd';
114 // Job bytes in human format
115 $job['jobbytes'] = CUtils::Get_Human_Size( $job['jobbytes'] );
117 array_push( $jobs, $job);
\r
120 $dbSql->TriggerDBError("Unable to get last jobs from catalog", $result);
122 $dbSql->tpl->assign('jobs', $jobs );
123 $dbSql->tpl->assign('backupjob_name', $backupjob_name );
124 $dbSql->tpl->assign('backupjob_period', $backupjob_period );
125 $dbSql->tpl->assign('backupjob_bytes', $backupjob_bytes );
126 $dbSql->tpl->assign('backupjob_files', $backupjob_files );
128 // Process and display the template
\r
129 $dbSql->tpl->display('backupjob-report.tpl');