]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/index.php
bacula-web: New INSTALL file
[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/global.inc.php' );
20
21         $dbSql                          = new Bweb();
22         $days_stored_bytes      = array();
23
24         // Stored files number 
25         $dbSql->tpl->assign('stored_files', number_format($dbSql->getStoredFiles( FIRST_DAY, NOW ), 0, '.', "'" ) );
26           
27         // Database size
28         $dbSql->tpl->assign('database_size', $dbSql->GetDbSize());
29
30         // Overall stored bytes
31         $stored_bytes = CUtils::Get_Human_Size( $dbSql->getStoredBytes( FIRST_DAY, NOW ) );
32         $dbSql->tpl->assign('stored_bytes', $stored_bytes);
33
34         // Total bytes and files for last 24 hours
35         $dbSql->tpl->assign('bytes_last', CUtils::Get_Human_Size( $dbSql->getStoredBytes( LAST_DAY, NOW ) ) );
36         $dbSql->tpl->assign('files_last', number_format($dbSql->getStoredFiles( LAST_DAY, NOW ), 0, '.', "'" ) );
37
38         // Number of clients
39         $nb_clients = $dbSql->Get_Nb_Clients();
40         $dbSql->tpl->assign('clientes_totales',$nb_clients["nb_client"] );
41
42         // Backup Job list
43         $dbSql->tpl->assign( 'jobs_list', $dbSql->Get_BackupJob_Names() );
44         
45         // Clients list
46
47         $dbSql->tpl->assign( 'clients_list', $dbSql->getClients() );
48
49         // Last 24 hours status (completed, failed and waiting jobs)
50         $dbSql->tpl->assign( 'completed_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'completed' ) );
51         $dbSql->tpl->assign( 'failed_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'failed' ) );
52         $dbSql->tpl->assign( 'waiting_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'waiting' ) );
53
54         // Last 24 hours jobs Level
55         $dbSql->tpl->assign( 'incr_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'ALL', J_INCR) );
56         $dbSql->tpl->assign( 'diff_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'ALL', J_DIFF) );
57         $dbSql->tpl->assign( 'full_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'ALL', J_FULL) );
58
59         // Last 24 hours Job status graph
60         $jobs_status_data = array();
61         $jobs_status      = array( 'Running', 'Completed', 'Failed', 'Canceled', 'Waiting' );
62
63         foreach( $jobs_status as $status )
64                 $jobs_status_data[] = array( $status, $dbSql->countJobs(LAST_DAY, NOW, $status) );
65
66         $graph = new CGraph( "graph.png" );
67         $graph->SetData( $jobs_status_data, 'pie', 'text-data-single' );
68         $graph->SetGraphSize( 400, 230 );
69
70         $graph->Render();
71         $dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() );
72         unset($graph);
73
74         // Volumes by pools graph
75         $vols_by_pool = array();
76         $graph        = new CGraph( "graph1.png" );
77
78         foreach( $dbSql->getPools() as $pool )
79                 $vols_by_pool[] = array( $pool['name'], $dbSql->countVolumes( $pool['poolid'] ) );
80
81         $graph->SetData( $vols_by_pool, 'pie', 'text-data-single' );
82         $graph->SetGraphSize( 400, 230 );
83
84         $graph->Render();
85         $dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() );
86
87         // Last 7 days stored Bytes graph
88         $days = CTimeUtils::getLastDaysIntervals( 7 );
89         foreach( $days as $day ) {
90                 $stored_bytes            = $dbSql->getStoredBytes( $day['start'], $day['end']);
91                 $stored_bytes            = CUtils::Get_Human_Size( $stored_bytes, 1, 'GB', false );
92                 $days_stored_bytes[] = array( date("m-d", $day['start']), $stored_bytes );  
93         }
94
95         $graph = new CGraph( "graph2.png" );
96         $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
97         $graph->SetGraphSize( 400, 230 );
98         $graph->SetYTitle( "GB" );
99
100         $graph->Render();
101         $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
102
103
104         // Last 15 used volumes
105         $vol_list = array();
106
107         $query  = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
108         $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
109         $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
110         $query .= "ORDER BY Job.JobId DESC ";
111         $query .= "LIMIT 10 ";
112         
113         try {
114                 $result = $dbSql->db_link->runQuery($query);
115                 foreach($result->fetchall() as $vol)
116                         $vol_list[] = $vol;
117         }catch(PDOException $e) {
118                 CDBError::raiseError($e);
119         }
120
121         $dbSql->tpl->assign( 'volume_list', $vol_list );        
122
123         // Render template
124         $dbSql->tpl->display('index.tpl');
125 ?>