]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Add a new stat_job_table option if user wants to improve statistics module
authorEric Bollengier <eric@eb.homelinux.org>
Sun, 25 Feb 2007 16:33:43 +0000 (16:33 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Sun, 25 Feb 2007 16:33:43 +0000 (16:33 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4251 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bweb/INSTALL
gui/bweb/ReleaseNotes
gui/bweb/cgi/bgraph.pl
gui/bweb/lang/es/tpl/config_edit.tpl
gui/bweb/lang/es/tpl/config_view.tpl
gui/bweb/lang/fr/tpl/config_edit.tpl
gui/bweb/lang/fr/tpl/config_view.tpl
gui/bweb/lang/fr/tpl/location_add.tpl
gui/bweb/lib/Bweb.pm
gui/bweb/tpl/config_edit.tpl
gui/bweb/tpl/config_view.tpl

index a45582757d44cde6d54b7e7bd040227859cc34b6..4ef27bc559da3b34f7c0639ffb8e805d33657de6 100644 (file)
@@ -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 !
index 63ad92a9d5e7ce9a2e3c078e2aaffa71a09f5cbf..ca70e96503ddf10ac1798419fc61f73471d883c6 100644 (file)
@@ -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
index c7540c7af93b3ca3afe629b9eb9387366331b8e0..2f1af39f2fb14a98f8caf6bd9b908952defb5d21 100755 (executable)
@@ -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
index a385a406d46399d78be650b4c42ff9bb0006cc0c..97fbc397f717aa3097639a8309bfbfcedf724250 100644 (file)
@@ -38,6 +38,8 @@
      <tr><td>fv_write_path :</td> 
          <td> <input class="formulaire" title="Este directorio debe tener permisos de escritura para el usuario apache y debe ser accesible en /bweb/fv" type='text' value='<TMPL_VAR fv_write_path>' size='64' name='fv_write_path'> 
          </td></tr>
+     <tr><td>stat_job_table :</td> 
+         <td> <input class="formulaire" title="You can choose the Job table that you want to use to get statistics" type='text' value='<TMPL_IF stat_job_table><TMPL_VAR stat_job_table><TMPL_ELSE>Job</TMPL_IF>' size='64' name='stat_job_table'>
      <tr><td>bconsole :</td> 
          <td> <input class="formulaire" type='text' value='<TMPL_VAR bconsole>' size='64' name='bconsole'> 
          </td></tr>
index e20ebc526730d811f174b48e755cf8a6f40744b0..f3db685f63c458335f187b10a3a225fc07e6e387 100644 (file)
@@ -15,6 +15,7 @@
     <tr><td title="/path/a/tu/template_dir">template_dir :</td> <td> <TMPL_VAR template_dir> </td></tr>
     <tr><td title="/path/a/a/font.ttf">graph_font :</td> <td> <TMPL_VAR graph_font> </td></tr>
     <tr><td title="Este directorio debe tener permisos de escritura para el usuario apache y debe ser accesible en /bweb/fv">fv_write_path :</td> <td> <TMPL_VAR fv_write_path> </td></tr>
+    <tr><td title="You can choose the Job table that you want to use to get statistics">stat_job_table :</td> <td> <TMPL_IF stat_job_table><TMPL_VAR stat_job_table><TMPL_ELSE>Job</TMPL_IF> </td></tr>
     <tr><td title="/path/a/bconsole -n -c /path/to/bconsole.conf">bconsole :</td> <td> <TMPL_VAR bconsole> </td></tr>
     <tr><td>debug :</td> <td> <TMPL_VAR debug> </td></tr>
     <TMPL_IF achs>
index 9bdea5d36eaaafb11de4503d72eb82aaa29ccb25..cd60610f21592e7df82ddc627ace81e090565392 100644 (file)
@@ -38,6 +38,9 @@
      <tr><td>fv_write_path :</td> 
          <td> <input class="formulaire" title="Ce répertoire doit être accessible en écriture pour apache et être sous /bweb/fv" type='text' value='<TMPL_VAR fv_write_path>' size='64' name='fv_write_path'> 
          </td></tr>
+     <tr><td>stat_job_table :</td> 
+         <td> <input class="formulaire" title="Vous pouvez choisir une autre table que Job pour calculer vos statisques" type='text' value='<TMPL_IF stat_job_table><TMPL_VAR stat_job_table><TMPL_ELSE>Job</TMPL_IF>' size='64' name='stat_job_table'> 
+         </td></tr>
      <tr><td>bconsole :</td> 
          <td> <input class="formulaire" title="/chemin/vers/bconsole -n -c /chemin/vers/bconsole.conf" type='text' value='<TMPL_VAR NAME=bconsole>' size='64' name='bconsole'> 
          </td></tr>
index a028858e71a12bf577ff44788617a013f676997e..350b5512a6aa67fe8651e4ec08b78b3cef0c977b 100644 (file)
@@ -15,6 +15,7 @@
     <tr><td title="/chemin/vers/votre/template_dir">template_dir :</td> <td> <TMPL_VAR template_dir> </td></tr>
     <tr><td title="/chemin/vers/une/font.ttf">graph_font :</td> <td> <TMPL_VAR graph_font> </td></tr>
     <tr><td title="Ce répertoire doit être accessible en ecriture pour apache et être sous /bweb/fv">fv_write_path :</td> <td> <TMPL_VAR fv_write_path> </td></tr>
+    <tr><td title="Vous pouvez utiliser une autre table que Job pour vos statistiques">stat_job_table :</td> <td> <TMPL_IF stat_job_table><TMPL_VAR stat_job_table><TMPL_ELSE>Job</TMPL_IF> </td></tr>
     <tr><td title="/chemin/vers/bconsole -n -c /chemin/vers/bconsole.conf">bconsole :</td> <td> <TMPL_VAR bconsole> </td></tr>
     <tr><td>debug :</td> <td> <TMPL_VAR debug> </td></tr>
     <TMPL_IF achs>
index f85c0090d191ee1e0b96e1c1ea3758e4f01fb0fc..49b5c5529fcb95a5a8bca51ffc0626a1c3a48ee1 100644 (file)
@@ -14,7 +14,7 @@
          <td> <input class="formulaire" type='text' value='10' name='cost' size='3'>
          </td>
      </tr>
-     <tr><td>Enabled :</td> 
+     <tr><td>En ligne :</td> 
          <td> <input class="formulaire" type='checkbox' value='10' name='enabled'>
          </td>
      </tr>
index 4e5f74a9a995519545628c25172b2b1255983113..a3af7a5897d3378267970a19c41272cfa08feecf 100644 (file)
@@ -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
index 5bb34669834726182dae34176001d2c3d3c3382d..b30a8bec196fb55b4be2c2c501cea2e60d6d5134 100644 (file)
@@ -37,6 +37,8 @@
          </td></tr>
      <tr><td>fv_write_path :</td> 
          <td> <input class="formulaire" title="This folder must be writable by apache user and must be accessible on /bweb/fv" type='text' value='<TMPL_VAR fv_write_path>' size='64' name='fv_write_path'> 
+     <tr><td>stat_job_table :</td> 
+         <td> <input class="formulaire" title="You can choose the Job table that you want to use to get statistics" type='text' value='<TMPL_IF stat_job_table><TMPL_VAR stat_job_table><TMPL_ELSE>Job</TMPL_IF>' size='64' name='stat_job_table'> 
          </td></tr>
      <tr><td>bconsole :</td> 
          <td> <input class="formulaire" type='text' value='<TMPL_VAR bconsole>' size='64' name='bconsole'> 
index a505b0375948e3de8c3fd75ac460270fe3eba10a..f3c40546d61fd8b414ad6ade8e234a825d9dba75 100644 (file)
@@ -15,6 +15,7 @@
     <tr><td title="/path/to/your/template_dir">template_dir :</td> <td> <TMPL_VAR template_dir> </td></tr>
     <tr><td title="/path/to/a/font.ttf">graph_font :</td> <td> <TMPL_VAR graph_font> </td></tr>
     <tr><td title="This folder must be writable by apache user and must be accessible on /bweb/fv">fv_write_path :</td> <td> <TMPL_VAR fv_write_path> </td></tr>
+    <tr><td title="You can choose the Job table that you want to use to get statistics">stat_job_table :</td> <td> <TMPL_IF stat_job_table><TMPL_VAR stat_job_table><TMPL_ELSE>Job</TMPL_IF> </td></tr>
     <tr><td title="/path/to/bconsole -n -c /path/to/bconsole.conf">bconsole :</td> <td> <TMPL_VAR bconsole> </td></tr>
     <tr><td>debug :</td> <td> <TMPL_VAR debug> </td></tr>
     <TMPL_IF achs>