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