]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/index.php
dea1accf2ee8722ac4fef63cfd07fc34f98c1891
[bacula/bacula] / gui / bacula-web / index.php
1 <?php
2 /* 
3 +-------------------------------------------------------------------------+
4 | Copyright (C) 2004 Juan Luis Francés Jiménez                                                    |
5 | Copyright 2010-2011, Davide Franco                                              |
6 |                                                                         |
7 | This program is free software; you can redistribute it and/or           |
8 | modify it under the terms of the GNU General Public License             |
9 | as published by the Free Software Foundation; either version 2          |
10 | of the License, or (at your option) any later version.                  |
11 |                                                                         |
12 | This program is distributed in the hope that it will be useful,         |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
15 | GNU General Public License for more details.                            |
16 +-------------------------------------------------------------------------+ 
17 */
18 session_start();
19 include_once( 'config.inc.php' );
20
21 $dbSql = new Bweb();
22
23 // Stored files number 
24 $dbSql->tpl->assign('stored_files', $dbSql->GetStoredFiles( ALL ) );
25   
26 // Database size
27 $dbSql->tpl->assign('database_size', $dbSql->GetDbSize());
28
29 // Overall stored bytes
30 $result = $dbSql->GetStoredBytes( ALL );
31 $dbSql->tpl->assign('stored_bytes', CUtils::Get_Human_Size( $result['stored_bytes'] ) );
32
33 // Total stored bytes since last 24 hours
34 $result = $dbSql->GetStoredBytes( LAST_DAY );
35 $dbSql->tpl->assign('bytes_last', CUtils::Get_Human_Size( $result['stored_bytes'] ) );
36
37 // Total stored files since last 24 hours
38 $files_last = $dbSql->GetStoredFiles( LAST_DAY );
39 $dbSql->tpl->assign('files_last', $files_last );
40
41
42 // Number of clients
43 $nb_clients = $dbSql->Get_Nb_Clients();
44 $dbSql->tpl->assign('clientes_totales',$nb_clients["nb_client"] );
45
46 // Backup Job list for report.tpl and last_run_report.tpl
47 $dbSql->tpl->assign( 'jobs_list', $dbSql->Get_BackupJob_Names() );
48
49 // Get volumes list (volumes.tpl)
50 $dbSql->tpl->assign('pools', $dbSql->GetVolumeList() );
51
52 // Last 24 hours completed jobs number
53 $dbSql->tpl->assign( 'completed_jobs', $dbSql->CountJobs( LAST_DAY, 'completed' ) );
54
55 // Last 24 hours failed jobs number
56 $dbSql->tpl->assign( 'failed_jobs', $dbSql->CountJobs( LAST_DAY, 'failed' ) );
57
58 // Last 24 hours waiting jobs number
59 $dbSql->tpl->assign( 'waiting_jobs', $dbSql->CountJobs( LAST_DAY, 'waiting' ) );
60
61 // Last 24 hours Job Levels
62 $dbSql->tpl->assign( 'incr_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'I') );
63 $dbSql->tpl->assign( 'diff_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'D') );
64 $dbSql->tpl->assign( 'full_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'F') );
65
66 // Last 24 hours Job status graph
67 $data   = array();  
68 $status = array( 'completed', 'terminated_errors', 'failed', 'waiting', 'created', 'running', 'error' );
69
70 foreach( $status as $job_status ) {
71         array_push( $data, $dbSql->GetJobsStatistics( $job_status ) );
72 }
73
74 $graph = new BGraph( "graph.png" );
75 $graph->SetData( $data, 'pie', 'text-data-single' );
76 $graph->SetGraphSize( 400, 230 );
77
78 $graph->Render();
79 $dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() );
80 unset($graph);
81
82 // Pool and volumes graph
83 $data = array();
84 $graph = new BGraph( "graph1.png" );
85
86 $pools = $dbSql->Get_Pools_List();
87 while( $pool = $pools->fetchRow( ) )
88         array_push( $data, $pool );
89
90 $graph->SetData( $data, 'pie', 'text-data-single' );
91 $graph->SetGraphSize( 400, 230 );
92
93 $graph->Render();
94 $dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() );
95
96 // Last 7 days stored Bytes graph
97 $data  = array();
98 $graph = new BGraph( "graph2.png" );
99 $days  = array();
100
101 // Get the last 7 days interval (start and end)
102 for( $c = 6 ; $c >= 0 ; $c-- ) {
103         $today = ( mktime() - ($c * LAST_DAY) );
104         array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) );
105 }
106
107 $days_stored_bytes = array();
108
109 foreach( $days as $day ) {
110   array_push( $days_stored_bytes, $dbSql->GetStoredBytesByInterval( $day['start'], $day['end'] ) );
111 }
112
113 $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
114 $graph->SetGraphSize( 400, 230 );
115 $graph->SetYTitle( "GB" );
116
117 $graph->Render();
118 $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
119
120
121 // Last 15 used volumes
122 $vol_list = array();
123
124 $query  = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
125 $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
126 $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
127 $query .= "ORDER BY Job.JobId DESC ";
128 $query .= "LIMIT 10 ";
129
130 $result = $dbSql->db_link->query( $query );
131
132 if ( PEAR::isError( $result ) )
133         $this->TriggerDBError( 'Unable to get last used volumes from catalog' . $result );
134 else {
135         while ( $vol = $result->fetchRow() ) 
136                 array_push( $vol_list, $vol );
137 }
138 $dbSql->tpl->assign( 'volume_list', $vol_list );        
139
140 // Render template
141 $dbSql->tpl->display('index.tpl');
142 ?>