]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/index.php
bacula-web: Removed useless lang.php file
[bacula/bacula] / gui / bacula-web / index.php
1 <?php
2 /* 
3 +-------------------------------------------------------------------------+
4 | Copyright (C) 2004 Juan Luis Francés Jiménez                            |
5 |                                                                         |
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.                  |
10 |                                                                         |
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 +-------------------------------------------------------------------------+ 
16 */
17 session_start();
18 require_once('paths.php');
19 include_once( 'bweb.inc.php' );
20
21 $dbSql = new Bweb();
22
23 $mode = "";                             
24
25 /*
26 // Getting mode from config file
27 $mode = $dbSql->get_config_param("mode");
28 if( $mode == false )
29         $mode = "Lite";
30
31 $smarty->assign( "mode", $mode );
32 */
33
34 // Assign to template catalogs number
35 $dbSql->tpl->assign( "dbs", $dbSql->Get_Nb_Catalogs() );
36
37 //Assign dbs
38 /*
39 if ( count($dbSql->dbs) >1 ) {
40   $smarty->assign("dbs", $dbSql->dbs);
41   $smarty->assign("dbs_now", $_SESSION['DATABASE']);
42 }
43 */
44
45 // Stored files number 
46 $totalfiles = $dbSql->GetStoredFiles( ALL );
47 $dbSql->tpl->assign('stored_files',$totalfiles);
48   
49 // Database size
50 $dbSql->tpl->assign('database_size', $dbSql->GetDbSize());
51
52 // Overall stored bytes
53 $result = $dbSql->GetStoredBytes( ALL );
54 $dbSql->tpl->assign('stored_bytes', $dbSql->human_file_size($result['stored_bytes']) );
55
56 // Total stored bytes since last 24 hours
57 $result = $dbSql->GetStoredBytes( LAST_DAY );
58 $dbSql->tpl->assign('bytes_last', $dbSql->human_file_size($result['stored_bytes']) );
59
60 // Total stored files since last 24 hours
61 $files_last = $dbSql->GetStoredFiles( LAST_DAY );
62 $dbSql->tpl->assign('files_last', $files_last );
63
64
65 // Number of clients
66 $nb_clients = $dbSql->Get_Nb_Clients();
67 $dbSql->tpl->assign('clientes_totales',$nb_clients["nb_client"] );
68
69 // Backup Job list for report.tpl and last_run_report.tpl
70 $dbSql->tpl->assign( 'jobs_list', $dbSql->Get_BackupJob_Names() );
71
72 // Get volumes list (volumes.tpl)
73 $dbSql->tpl->assign('pools', $dbSql->GetVolumeList() );
74
75 // Last 24 hours completed jobs number
76 $dbSql->tpl->assign( 'completed_jobs', $dbSql->CountJobs( LAST_DAY, 'completed' ) );
77
78 // Last 24 hours failed jobs number
79 $dbSql->tpl->assign( 'failed_jobs', $dbSql->CountJobs( LAST_DAY, 'failed' ) );
80
81 // Last 24 hours waiting jobs number
82 $dbSql->tpl->assign( 'waiting_jobs', $dbSql->CountJobs( LAST_DAY, 'waiting' ) );
83
84 // Last 24 hours elapsed time (last_run_report.tpl)
85 //$smarty->assign( 'elapsed_jobs', $dbSql->Get_ElapsedTime_Job() );
86
87 // Last 24 hours Job Levels
88 $dbSql->tpl->assign( 'incr_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'I') );
89 $dbSql->tpl->assign( 'diff_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'D') );
90 $dbSql->tpl->assign( 'full_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'F') );
91
92 // Last 24 hours Job status graph
93 $data   = array();  
94 $status = array( 'completed', 'terminated_errors', 'failed', 'waiting', 'created', 'running', 'error' );
95
96 foreach( $status as $job_status ) {
97         array_push( $data, $dbSql->GetJobsStatistics( $job_status ) );
98 }
99
100 $graph = new BGraph( "graph.png" );
101 $graph->SetData( $data, 'pie', 'text-data-single' );
102 $graph->SetGraphSize( 400, 230 );
103
104 $graph->Render();
105 $dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() );
106 unset($graph);
107
108 // Pool and volumes graph
109 $data = array();
110 $graph = new BGraph( "graph1.png" );
111
112 $pools = $dbSql->Get_Pools_List();
113
114 foreach( $pools as $pool ) {
115         array_push( $data, $dbSql->GetPoolsStatistics( $pool ) );
116 }
117
118 $graph->SetData( $data, 'pie', 'text-data-single' );
119 $graph->SetGraphSize( 400, 230 );
120
121 $graph->Render();
122 $dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() );
123
124 // Last 7 days stored Bytes graph
125 $data  = array();
126 $graph = new BGraph( "graph2.png" );
127 $days  = array();
128
129 // Get the last 7 days interval (start and end)
130 for( $c = 6 ; $c >= 0 ; $c-- ) {
131         $today = ( mktime() - ($c * LAST_DAY) );
132         array_push( $days, array( 'start' => date( "Y-m-d 00:00:00", $today ), 'end' => date( "Y-m-d 23:59:00", $today ) ) );
133 }
134
135 $days_stored_bytes = array();
136
137 foreach( $days as $day ) {
138   array_push( $days_stored_bytes, $dbSql->GetStoredBytesByInterval( $day['start'], $day['end'] ) );
139 }
140
141 $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
142 $graph->SetGraphSize( 400, 230 );
143
144 $graph->Render();
145 $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
146
147 // Last 15 used volumes
148 $vol_list = array();
149
150 $query  = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
151 $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
152 $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
153 $query .= "ORDER BY Job.JobId DESC ";
154 $query .= "LIMIT 10 ";
155
156 $result = $dbSql->db_link->query( $query );
157
158 if ( PEAR::isError( $result ) )
159         die( "Unable to get last used volumes from catalog \n " . $result->getMessage() );
160 else {
161         while ( $vol = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) 
162                 array_push( $vol_list, $vol );
163 }
164 $dbSql->tpl->assign( 'volume_list', $vol_list );        
165
166 //if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes")
167 //        $smarty->display('full_popup.tpl');
168 //else
169
170 // Render template
171 $dbSql->tpl->display('index.tpl');
172 ?>