From ddb5b3482134c4a326ccf2417dd07523e19d2e94 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Mon, 14 Mar 2011 18:31:12 +0100 Subject: [PATCH] bacula-web: Added Job Level stats on main dashboard - 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 | 23 +++++++++++++++++++++++ gui/bacula-web/index.php | 11 ++++++++--- gui/bacula-web/templates/index.tpl | 7 +++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/gui/bacula-web/bweb.inc.php b/gui/bacula-web/bweb.inc.php index 95f6a77f0d..a8deebae6a 100644 --- a/gui/bacula-web/bweb.inc.php +++ b/gui/bacula-web/bweb.inc.php @@ -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
" . $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 "; diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index e9a0e4cc55..314ff87b8d 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -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' ); diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index b31f1d3a43..bbd7426ee0 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -107,6 +107,13 @@
+ + Job Level (Incr / Diff / Full) + {$incr_jobs} / {$diff_jobs} / {$full_jobs} + + +
+ Transferred Bytes {$bytes_last} -- 2.39.5