]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Added statistics graphs into client report page
authorDavide Franco <bacula-dev@dflc.ch>
Sun, 24 Jul 2011 10:58:37 +0000 (12:58 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:28 +0000 (14:49 +0200)
gui/bacula-web/client-report.php
gui/bacula-web/templates/client-report.tpl

index 69976459755efb62f4b5714960aa160e4ac62f7f..94c1a04b47d5be2f20783409a4f972ba9598322c 100644 (file)
 
        $dbSql = new Bweb();
        
-       $clientid               = '';
-    $client                    = '';
-       $client_jobs    = array();
-       $backup_jobs    = array();
+       $clientid                       = '';
+    $client                            = '';
+       $period                         = '';
+       $client_jobs            = array();
+       $backup_jobs            = array();
+       $days_stored_bytes  = array();
+       $days_stored_files  = array();
        
        $job_levels = array( 'D' => 'Differential', 'I' => 'Incremental', 'F' => 'Full' );
        
                $clientid = $http_get['client_id'];
        else
                die( "Application error: Client not specified " );
+
+       // Backup period
+       if( isset( $http_post['period'] ) )
+               $period = $http_post['period'];
+       else
+               die( "Please specify a backup period" );
                
        // Client informations
        $client = $dbSql->getClientInfos($clientid);
        }catch(PDOException $e) {
                CDBError::raiseError($e);
        }
+       
        $dbSql->tpl->assign( 'backup_jobs', $backup_jobs);
        
+       // Get the last 7 days interval (start and end)
+       $days = CTimeUtils::getLastDaysIntervals( $period );
+       
+       // ===============================================================
+       // Last 7 days stored Bytes graph
+       // ===============================================================  
+       $graph = new CGraph( "graph2.png" );
+
+       foreach( $days as $day ) {
+               $stored_bytes            = $dbSql->getStoredBytes( $day['start'], $day['end'], 'ALL', $clientid);
+               $stored_bytes            = CUtils::Get_Human_Size( $stored_bytes, 1, 'GB', false );
+               $days_stored_bytes[] = array( date("m-d", $day['start']), $stored_bytes );
+       }
+
+       $graph->SetData( $days_stored_bytes, 'bars', 'text-data' );
+       $graph->SetGraphSize( 400, 230 );
+       $graph->SetYTitle( "GB" );
+
+       $graph->Render();
+       $dbSql->tpl->assign('graph_stored_bytes', $graph->Get_Image_file() );   
+
+       // ===============================================================
+       // Getting last 7 days stored files graph
+       // ===============================================================
+       $graph = new CGraph("graph3.png" );
+
+       foreach( $days as $day ) {
+               $stored_files            = $dbSql->getStoredFiles( $day['start'], $day['end'],  'ALL', $clientid);
+               $days_stored_files[] = array( date("m-d", $day['start']), $stored_files );
+       }
+
+       $graph->SetData( $days_stored_files, 'bars', 'text-data' );
+       $graph->SetGraphSize( 400, 230 );
+       $graph->SetYTitle( "Files" );
+
+       $graph->Render();
+       $dbSql->tpl->assign('graph_stored_files', $graph->Get_Image_file() );
+       
+       $dbSql->tpl->assign( 'period', $period);
        $dbSql->tpl->assign( 'client_name', $client['name']);
        $dbSql->tpl->assign( 'client_os', $client['os']);
        $dbSql->tpl->assign( 'client_arch', $client['arch']);
index 6f93b146f825235cccbb7a26b59eddc809e9390e..96eb86a6fe2ac274251ebf46da3d3243b3b73add 100644 (file)
                {/foreach}
        </table>
        
+       <h4>Statistics - last {$period} days(s)</h4>
+       
+       <table>
+               <tr>
+                       <td> <img class="graph" src="{$graph_stored_bytes}" alt="" /> </td>
+                       <td> <img class="graph" src="{$graph_stored_files}" alt="" /> </td>
+               </tr>
+       </table>
+       
   </div> <!-- end div class=box -->
   
   </div> <!-- end div id=main_center -->