From 28eefd5c70e6ed34fdfff811df1294033dc12784 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 25 Feb 2007 16:33:43 +0000 Subject: [PATCH] ebl Add a new stat_job_table option if user wants to improve statistics module git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4251 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/INSTALL | 18 +++++- gui/bweb/ReleaseNotes | 4 +- gui/bweb/cgi/bgraph.pl | 84 +++++++++++++++------------ gui/bweb/lang/es/tpl/config_edit.tpl | 2 + gui/bweb/lang/es/tpl/config_view.tpl | 1 + gui/bweb/lang/fr/tpl/config_edit.tpl | 3 + gui/bweb/lang/fr/tpl/config_view.tpl | 1 + gui/bweb/lang/fr/tpl/location_add.tpl | 2 +- gui/bweb/lib/Bweb.pm | 1 + gui/bweb/tpl/config_edit.tpl | 2 + gui/bweb/tpl/config_view.tpl | 1 + 11 files changed, 77 insertions(+), 42 deletions(-) diff --git a/gui/bweb/INSTALL b/gui/bweb/INSTALL index a45582757d..4ef27bc559 100644 --- a/gui/bweb/INSTALL +++ b/gui/bweb/INSTALL @@ -15,6 +15,7 @@ Bweb works well with 1.39 release or later. 9) using bfileview.pl 10) accessing to bweb 11) setting mysql read-only account +12) get more statistics ################ FILE COPY ##################################### # you must get bweb svn files @@ -271,12 +272,12 @@ To upgrade from an old installation, you can use : ALTER TABLE brestore_pathvisibility ADD Size int8; ALTER TABLE brestore_pathvisibility ADD Files int4; -################ ACCESSING TO BWEB ############################### +################ ACCESSING TO BWEB ############################ Now, you are able to launch firefox/mozilla and go on http://your-server/bweb -################ SETTING MYSQL ACCOUNT ########################### +################ SETTING MYSQL ACCOUNT ######################## At this time, Bweb needs a write access to : - Location @@ -296,6 +297,17 @@ GRANT INSERT,UPDATE,DELETE ON bacula.LocationLog GRANT UPDATE (LocationId,Comment,RecyclePoolId) ON bacula.Media TO 'bweb'@'%' IDENTIFIED BY 'password'; -################################################################### +################ GET MORE STATISTICS ########################### + +You keep Jobs informations across retention into a job_old table. +You have to setup stat_job_table = job_old in bweb configuration. + +CREATE TABLE job_old (LIKE Job); + +And run this on crontab when you want : +INSERT INTO job_old + (SELECT * FROM Job WHERE JobId NOT IN (SELECT JobId FROM job_old) ); + +################################################################ Enjoy ! diff --git a/gui/bweb/ReleaseNotes b/gui/bweb/ReleaseNotes index 63ad92a9d5..ca70e96503 100644 --- a/gui/bweb/ReleaseNotes +++ b/gui/bweb/ReleaseNotes @@ -1,7 +1,9 @@ Release Notes for bweb 2.0 - 2007/02/25 - Update INSTALL notes (GRANT options for mysql) + - You can choose a other table than Job to do your statistics + Job is purged by Media or Job retention, it's not very useful + to follow trends. 2007/02/14 - Add EndTime to display_job if you want add it to your tpl diff --git a/gui/bweb/cgi/bgraph.pl b/gui/bweb/cgi/bgraph.pl index c7540c7af9..2f1af39f2f 100755 --- a/gui/bweb/cgi/bgraph.pl +++ b/gui/bweb/cgi/bgraph.pl @@ -48,12 +48,18 @@ use File::Basename qw/basename dirname/; my $conf = new Bweb::Config(config_file => $Bweb::config_file); $conf->load(); - my $bweb = new Bweb(info => $conf); $bweb->connect_db(); my $dbh = $bweb->{dbh}; my $debug = $bweb->{debug}; +# Job table keep use Media or Job retention, so it's quite enought +# for good statistics +# CREATE TABLE job_old (LIKE Job); +# INSERT INTO job_old +# (SELECT * FROM Job WHERE JobId NOT IN (SELECT JobId FROM job_old) ); +my $jobt = $conf->{stat_job_table} || 'Job'; + my $graph = CGI::param('graph') || 'job_size'; my $legend = CGI::param('legend') || 'on' ; $legend = ($legend eq 'on')?1:0; @@ -64,17 +70,17 @@ my $arg = $bweb->get_form(qw/width height limit offset age where jobid my ($limitq, $label) = $bweb->get_limit(age => $arg->{age}, limit => $arg->{limit}, offset=> $arg->{offset}, - order => 'Job.StartTime ASC', + order => "$jobt.StartTime ASC", ); my $statusq=''; if ($arg->{status} and $arg->{status} ne 'Any') { - $statusq = " AND Job.JobStatus = '$arg->{status}' "; + $statusq = " AND $jobt.JobStatus = '$arg->{status}' "; } my $levelq=''; if ($arg->{level} and $arg->{level} ne 'Any') { - $levelq = " AND Job.Level = '$arg->{level}' "; + $levelq = " AND $jobt.Level = '$arg->{level}' "; } my $filesetq=''; @@ -84,7 +90,7 @@ if ($arg->{jfilesets}) { my $jobnameq=''; if ($arg->{jjobnames}) { - $jobnameq = " AND Job.Name IN ($arg->{jjobnames}) "; + $jobnameq = " AND $jobt.Name IN ($arg->{jjobnames}) "; } else { $arg->{jjobnames} = 'all'; # skip warning } @@ -187,14 +193,14 @@ if ($graph eq 'job_size') { my $query = " SELECT - UNIX_TIMESTAMP(Job.StartTime) AS starttime, + UNIX_TIMESTAMP($jobt.StartTime) AS starttime, Client.Name AS clientname, - Job.Name AS jobname, - Job.JobBytes AS jobbytes -FROM Job, Client, FileSet -WHERE Job.ClientId = Client.ClientId - AND Job.FileSetId = FileSet.FileSetId - AND Job.Type = 'B' + $jobt.Name AS jobname, + $jobt.JobBytes AS jobbytes +FROM $jobt, Client, FileSet +WHERE $jobt.ClientId = Client.ClientId + AND $jobt.FileSetId = FileSet.FileSetId + AND $jobt.Type = 'B' $clientq $statusq $filesetq @@ -224,14 +230,14 @@ if ($graph eq 'job_file') { my $query = " SELECT - UNIX_TIMESTAMP(Job.StartTime) AS starttime, + UNIX_TIMESTAMP($jobt.StartTime) AS starttime, Client.Name AS clientname, - Job.Name AS jobname, - Job.JobFiles AS jobfiles -FROM Job, Client, FileSet -WHERE Job.ClientId = Client.ClientId - AND Job.FileSetId = FileSet.FileSetId - AND Job.Type = 'B' + $jobt.Name AS jobname, + $jobt.JobFiles AS jobfiles +FROM $jobt, Client, FileSet +WHERE $jobt.ClientId = Client.ClientId + AND $jobt.FileSetId = FileSet.FileSetId + AND $jobt.Type = 'B' $clientq $statusq $filesetq @@ -257,6 +263,7 @@ $limitq } # it works only with postgresql at this time +# we dont use $jobt because we use File, so job is in Job table elsif ($graph eq 'file_histo' and $arg->{where}) { my $dir = $dbh->quote(dirname($arg->{where}) . '/'); @@ -356,19 +363,19 @@ elsif ($graph eq 'job_rate') { my $query = " SELECT - UNIX_TIMESTAMP(Job.StartTime) AS starttime, + UNIX_TIMESTAMP($jobt.StartTime) AS starttime, Client.Name AS clientname, - Job.Name AS jobname, - Job.JobBytes / + $jobt.Name AS jobname, + $jobt.JobBytes / ($bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime) - $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) + 0.01) AS rate -FROM Job, Client, FileSet -WHERE Job.ClientId = Client.ClientId - AND Job.FileSetId = FileSet.FileSetId - AND Job.Type = 'B' +FROM $jobt, Client, FileSet +WHERE $jobt.ClientId = Client.ClientId + AND $jobt.FileSetId = FileSet.FileSetId + AND $jobt.Type = 'B' $clientq $statusq $filesetq @@ -400,16 +407,16 @@ elsif ($graph eq 'job_duration') { my $query = " SELECT - UNIX_TIMESTAMP(Job.StartTime) AS starttime, + UNIX_TIMESTAMP($jobt.StartTime) AS starttime, Client.Name AS clientname, - Job.Name AS jobname, + $jobt.Name AS jobname, $bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime) - $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) AS duration -FROM Job, Client, FileSet -WHERE Job.ClientId = Client.ClientId - AND Job.FileSetId = FileSet.FileSetId - AND Job.Type = 'B' +FROM $jobt, Client, FileSet +WHERE $jobt.ClientId = Client.ClientId + AND $jobt.FileSetId = FileSet.FileSetId + AND $jobt.Type = 'B' $clientq $statusq $filesetq @@ -457,15 +464,18 @@ $limitq if ($t eq 'sum' or $t eq 'avg') { push @arg, ('y_number_format' => \&Bweb::human_size); } + + my $stime = $bweb->{sql}->{"STARTTIME_$d"}; + $stime =~ s/Job\./$jobt\./; my $query = " SELECT - " . ($per_t?"":"UNIX_TIMESTAMP") . "(" . $bweb->{sql}->{"STARTTIME_$d"} . ") AS A, + " . ($per_t?"":"UNIX_TIMESTAMP") . "($stime) AS A, $t(JobBytes) AS nb -FROM Job, Client, FileSet -WHERE Job.ClientId = Client.ClientId - AND Job.FileSetId = FileSet.FileSetId - AND Job.Type = 'B' +FROM $jobt, Client, FileSet +WHERE $jobt.ClientId = Client.ClientId + AND $jobt.FileSetId = FileSet.FileSetId + AND $jobt.Type = 'B' $clientq $statusq $filesetq diff --git a/gui/bweb/lang/es/tpl/config_edit.tpl b/gui/bweb/lang/es/tpl/config_edit.tpl index a385a406d4..97fbc397f7 100644 --- a/gui/bweb/lang/es/tpl/config_edit.tpl +++ b/gui/bweb/lang/es/tpl/config_edit.tpl @@ -38,6 +38,8 @@ fv_write_path : + stat_job_table : + bconsole : diff --git a/gui/bweb/lang/es/tpl/config_view.tpl b/gui/bweb/lang/es/tpl/config_view.tpl index e20ebc5267..f3db685f63 100644 --- a/gui/bweb/lang/es/tpl/config_view.tpl +++ b/gui/bweb/lang/es/tpl/config_view.tpl @@ -15,6 +15,7 @@ template_dir : graph_font : fv_write_path : + stat_job_table : Job bconsole : debug : diff --git a/gui/bweb/lang/fr/tpl/config_edit.tpl b/gui/bweb/lang/fr/tpl/config_edit.tpl index 9bdea5d36e..cd60610f21 100644 --- a/gui/bweb/lang/fr/tpl/config_edit.tpl +++ b/gui/bweb/lang/fr/tpl/config_edit.tpl @@ -38,6 +38,9 @@ fv_write_path : + stat_job_table : + + bconsole : diff --git a/gui/bweb/lang/fr/tpl/config_view.tpl b/gui/bweb/lang/fr/tpl/config_view.tpl index a028858e71..350b5512a6 100644 --- a/gui/bweb/lang/fr/tpl/config_view.tpl +++ b/gui/bweb/lang/fr/tpl/config_view.tpl @@ -15,6 +15,7 @@ template_dir : graph_font : fv_write_path : + stat_job_table : Job bconsole : debug : diff --git a/gui/bweb/lang/fr/tpl/location_add.tpl b/gui/bweb/lang/fr/tpl/location_add.tpl index f85c0090d1..49b5c5529f 100644 --- a/gui/bweb/lang/fr/tpl/location_add.tpl +++ b/gui/bweb/lang/fr/tpl/location_add.tpl @@ -14,7 +14,7 @@ - Enabled : + En ligne : diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 4e5f74a9a9..a3af7a5897 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -215,6 +215,7 @@ our %k_re = ( dbi => qr/^(dbi:(Pg|mysql):(?:\w+=[\w\d\.-]+;?)+)$/i, bconsole => qr!^(.+)?$!, syslog_file => qr!^(.+)?$!, log_dir => qr!^(.+)?$!, + stat_job_table => qr!^(\w*)$!, ); =head1 FUNCTION diff --git a/gui/bweb/tpl/config_edit.tpl b/gui/bweb/tpl/config_edit.tpl index 5bb3466983..b30a8bec19 100644 --- a/gui/bweb/tpl/config_edit.tpl +++ b/gui/bweb/tpl/config_edit.tpl @@ -37,6 +37,8 @@ fv_write_path : + stat_job_table : + bconsole : diff --git a/gui/bweb/tpl/config_view.tpl b/gui/bweb/tpl/config_view.tpl index a505b03759..f3c40546d6 100644 --- a/gui/bweb/tpl/config_view.tpl +++ b/gui/bweb/tpl/config_view.tpl @@ -15,6 +15,7 @@ template_dir : graph_font : fv_write_path : + stat_job_table : Job bconsole : debug : -- 2.39.2