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 // Get the last 7 days interval (start and end)
\r
41 for( $c = 6 ; $c >= 0 ; $c-- ) {
\r
42 $today = ( mktime() - ($c * LAST_DAY) );
\r
43 array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) );
\r
46 // Generate Backup Job report period string
\r
47 $backupjob_period = "From " . date( "Y-m-d", mktime()-LAST_WEEK ) . " to " . date( "Y-m-d", mktime() );
\r
49 // ===============================================================
50 // Last 7 days stored Bytes graph
\r
51 // ===============================================================
52 $graph = new BGraph( "graph2.png" );
\r
54 foreach( $days as $day )
\r
55 array_push( $days_stored_bytes, $dbSql->GetStoredBytesByJob( $backupjob_name, $day['start'], $day['end'] ) );
\r
57 // Calculate total bytes for this period
\r
58 foreach( $days_stored_bytes as $day )
\r
59 $backupjob_bytes += $day[1];
\r
61 $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
\r
62 $graph->SetGraphSize( 400, 230 );
\r
63 $graph->SetYTitle( "GB" );
66 $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
68 // ===============================================================
69 // Getting last 7 days stored files graph
\r
70 // ===============================================================
71 $graph = new BGraph("graph3.png" );
\r
73 foreach( $days as $day )
\r
74 array_push( $days_stored_files, $dbSql->GetStoredFilesByJob( $backupjob_name, $day['start'], $day['end'] ) );
\r
76 // Calculate total files for this period
\r
77 foreach( $days_stored_files as $day )
\r
78 $backupjob_files += $day[1];
\r
80 $graph->SetData( $days_stored_files, 'bars', 'text-data' );
\r
81 $graph->SetGraphSize( 400, 230 );
\r
82 $graph->SetYTitle( "Files" );
85 $dbSql->tpl->assign('graph_stored_files', $graph->Get_Image_file() );
88 $query = "SELECT JobId, Level, JobFiles, JobBytes, JobStatus, StartTime, EndTime, Name ";
89 $query .= "FROM Job ";
\r
90 $query .= "WHERE Name = '$backupjob_name' ";
\r
91 $query .= "ORDER BY EndTime DESC ";
\r
92 $query .= "LIMIT 10 ";
\r
95 $joblevel = array( 'I' => 'Incr', 'D' => 'Diff', 'F' => 'Full' );
\r
96 $result = $dbSql->db_link->query( $query );
\r
98 if( ! PEAR::isError( $result ) )
\r
100 while( $job = $result->fetchRow( DB_FETCHMODE_ASSOC ) )
102 // Job level description
103 $job['Level'] = $joblevel[ $job['Level'] ];
105 // Job execution execution time
106 $job['ElapsedTime'] = CTimeUtils::Get_Elapsed_Time( $job['StartTime'], $job['EndTime'] );
109 if( count($jobs) % 2)
110 $job['row_class'] = 'odd';
112 array_push( $jobs, $job);
\r
115 die( "Unable to get last jobs from catalog " . $result->getMessage() );
\r
117 $dbSql->tpl->assign('jobs', $jobs );
118 $dbSql->tpl->assign('backupjob_name', $backupjob_name );
119 $dbSql->tpl->assign('backupjob_period', $backupjob_period );
120 $dbSql->tpl->assign('backupjob_bytes', $backupjob_bytes );
121 $dbSql->tpl->assign('backupjob_files', $backupjob_files );
123 // Process and display the template
\r
124 $dbSql->tpl->display('backupjob-report.tpl');