]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Added Job Level stats on main dashboard
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 14 Mar 2011 17:31:12 +0000 (18:31 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 2 Aug 2011 09:56:14 +0000 (11:56 +0200)
 - New function CountJobsbyLevel() in bweb.inc.php which retrieve how many jobs of specific Level for custom interval
 - Added to main dashboard Job Level stats (for last 24 hours)

gui/bacula-web/bweb.inc.php
gui/bacula-web/index.php
gui/bacula-web/templates/index.tpl

index 95f6a77f0d56e0795d4d93cad9f4936a9a2cee63..a8deebae6ac5dc982e5a874f0957596f1b34164d 100644 (file)
@@ -376,6 +376,29 @@ class Bweb extends DB {
                                return $volumes;
         } // end function GetVolumeList()
                
+               public function CountJobsbyLevel( $delay = LAST_DAY, $level = 'F' )
+               {
+                       $end_date    = mktime();
+                       $start_date  = $end_date - $delay;
+                       
+                       $start_date  = date( "Y-m-d H:i:s", $start_date );
+                       $end_date    = date( "Y-m-d H:i:s", $end_date );
+                       
+                       $query   = "SELECT COUNT(JobId) as jobs FROM Job ";
+                       $query  .= "WHERE (EndTime BETWEEN '$start_date' AND '$end_date') AND ";
+                       $query  .= "Level = '$level' ";
+                       
+                       $result  = $this->db_link->query( $query );
+                       
+                       if (PEAR::isError( $result ) ) {
+                               die( "Unable to get number of jobs with $level status from catalog <br />" . $result->getMessage() );
+                       }else {
+                               $jobs = $result->fetchRow( DB_FETCHMODE_ASSOC ); 
+                               return $jobs['jobs'];
+                       }
+                       
+               }
+               
                public function CountJobs( $delay = LAST_DAY, $status = 'any' )
                {
                        $query                  = "SELECT COUNT(JobId) AS job_nb FROM Job ";
index e9a0e4cc555e862d718bf4d46b9ded912d4eeddd..314ff87b8d81870a1100b3cbac66bc6fbaa9ea64 100644 (file)
@@ -30,12 +30,12 @@ $smarty->compile_check = true;
 $smarty->debugging = false;
 $smarty->force_compile = true;
 
-$smarty->template_dir = "./templates";
-$smarty->compile_dir = "./templates_c";
+$smarty->template_dir  = "./templates";
+$smarty->compile_dir   = "./templates_c";
 $smarty->config_dir     = "./configs";
 
 /*
-$smarty->config_load("bacula.conf");                                                                                    // Load config file
+$smarty->config_load("bacula.conf");                                        // Load config file
 $mode = $smarty->get_config_vars("mode");     
 */                                                                          // Lite o Extend?
 
@@ -112,6 +112,11 @@ $smarty->assign( 'waiting_jobs', $dbSql->CountJobs( LAST_DAY, 'waiting' ) );
 // Last 24 hours elapsed time (last_run_report.tpl)
 //$smarty->assign( 'elapsed_jobs', $dbSql->Get_ElapsedTime_Job() );
 
+// Last 24 hours Job Levels
+$smarty->assign( 'incr_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'I') );
+$smarty->assign( 'diff_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'D') );
+$smarty->assign( 'full_jobs', $dbSql->CountJobsbyLevel( LAST_DAY, 'F') );
+
 // Last 24 hours Job status graph
 $data   = array();  
 $status = array( 'completed', 'terminated_errors', 'failed', 'waiting', 'created', 'running', 'error' );
index b31f1d3a43d968f215d94192fc38780bc202b1d4..bbd7426ee099914b567e7592ffda57537a0ad0ac 100644 (file)
                        <tr>
                                <td colspan="2" class="label"><hr></td>
                        </tr>
+                       <tr>
+                               <td class="label">Job Level (Incr / Diff / Full)</td>
+                               <td class="info">{$incr_jobs} / {$diff_jobs} / {$full_jobs}</td>
+                       </tr>
+                       <tr>
+                               <td colspan="2" class="label"><hr></td>
+                       </tr>
                        <tr>
                                <td class="label">Transferred Bytes</td> 
                                <td class="info">{$bytes_last}</td>