]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/index.php
bacula-web: Removed file includes/db/cpgsqldb.class.php
[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 for report.tpl and last_run_report.tpl
43 $dbSql->tpl->assign( 'jobs_list', $dbSql->Get_BackupJob_Names() );
44
45 // Last 24 hours status (completed, failed and waiting jobs)
46 $dbSql->tpl->assign( 'completed_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'completed' ) );
47 $dbSql->tpl->assign( 'failed_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'failed' ) );
48 $dbSql->tpl->assign( 'waiting_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'waiting' ) );
49
50 // Last 24 hours jobs Level
51 $dbSql->tpl->assign( 'incr_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'ALL', J_INCR) );
52 $dbSql->tpl->assign( 'diff_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'ALL', J_DIFF) );
53 $dbSql->tpl->assign( 'full_jobs', $dbSql->countJobs( LAST_DAY, NOW, 'ALL', J_FULL) );
54
55 // Last 24 hours Job status graph
56 $jobs_status_data = array();
57 $jobs_status      = array( 'Running', 'Completed', 'Failed', 'Canceled', 'Waiting' );
58
59 foreach( $jobs_status as $status )
60         $jobs_status_data[] = array( $status, $dbSql->countJobs(LAST_DAY, NOW, $status) );
61
62 $graph = new CGraph( "graph.png" );
63 $graph->SetData( $jobs_status_data, 'pie', 'text-data-single' );
64 $graph->SetGraphSize( 400, 230 );
65
66 $graph->Render();
67 $dbSql->tpl->assign('graph_jobs', $graph->Get_Image_file() );
68 unset($graph);
69
70 // Volumes by pools graph
71 $vols_by_pool = array();
72 $graph        = new CGraph( "graph1.png" );
73
74 foreach( $dbSql->getPools() as $pool )
75         $vols_by_pool[] = array( $pool['name'], $dbSql->countVolumes( $pool['poolid'] ) );
76
77 $graph->SetData( $vols_by_pool, 'pie', 'text-data-single' );
78 $graph->SetGraphSize( 400, 230 );
79
80 $graph->Render();
81 $dbSql->tpl->assign('graph_pools', $graph->Get_Image_file() );
82
83 // Last 7 days stored Bytes graph
84 $days = CTimeUtils::getLastDaysIntervals( 7 );
85 foreach( $days as $day ) {
86         $stored_bytes            = $dbSql->getStoredBytes( $day['start'], $day['end']);
87         $stored_bytes            = CUtils::Get_Human_Size( $stored_bytes, 1, 'GB', false );
88         $days_stored_bytes[] = array( date("m-d", $day['start']), $stored_bytes );  
89 }
90
91 $graph = new CGraph( "graph2.png" );
92 $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
93 $graph->SetGraphSize( 400, 230 );
94 $graph->SetYTitle( "GB" );
95
96 $graph->Render();
97 $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );
98
99
100 // Last 15 used volumes
101 $vol_list = array();
102
103 $query  = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
104 $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
105 $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
106 $query .= "ORDER BY Job.JobId DESC ";
107 $query .= "LIMIT 10 ";
108
109 $result = $dbSql->db_link->query( $query );
110
111 if ( PEAR::isError( $result ) )
112         $this->TriggerDBError( 'Unable to get last used volumes from catalog' . $result );
113 else {
114         while ( $vol = $result->fetchRow() ) 
115                 array_push( $vol_list, $vol );
116 }
117 $dbSql->tpl->assign( 'volume_list', $vol_list );        
118
119 // Render template
120 $dbSql->tpl->display('index.tpl');
121 ?>