From: Eric Bollengier Date: Sun, 21 Sep 2008 21:18:12 +0000 (+0000) Subject: ebl X-Git-Tag: Release-3.0.0~960 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7593f4ecaa12c43ee0b969b70937cba05c2a84f1;p=bacula%2Fbacula ebl bfileview: - Add error message for pruned of uncomputed jobs - Bugfix for looking / Bweb.pm - Add support for age=1w2d40m - Add new configuration variable to modify default age general.tpl - Add hyperlink to failed job count git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7617 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/INSTALL b/gui/bweb/INSTALL index 8a54949b6a..1650a8984c 100644 --- a/gui/bweb/INSTALL +++ b/gui/bweb/INSTALL @@ -267,6 +267,9 @@ chown www-data /var/spool/bweb You have to remove "" from tpl/en/display_job_zoom.tpl. +Add (or configure) a writable location to the parameters in bweb.conf + 'fv_write_path' => '/var/spool/bweb', + You MUST use brestore.pl -b to initialize the database, and you CAN use bfileview.pl mode=batch jobid=xxx where=/ to compute tree size. diff --git a/gui/bweb/cgi/bfileview.pl b/gui/bweb/cgi/bfileview.pl index dddffd4d67..7196ea7ac7 100755 --- a/gui/bweb/cgi/bfileview.pl +++ b/gui/bweb/cgi/bfileview.pl @@ -78,12 +78,14 @@ $bweb->display_job_zoom($jobid); unless ($jobid) { $bweb->error("Can't get where or jobid"); + $bweb->display_end(); exit 0; } unless ($base_fich and -w $base_fich) { $bweb->error("fv_write_path ($base_fich) is not writable." . " See Bweb configuration."); + $bweb->display_end(); exit 0; } @@ -94,6 +96,19 @@ if (-f "$base_fich/$md5_rep.png" and -f "$base_fich/$md5_rep.tpl") exit 0; } +my $r = $bweb->dbh_selectrow_hashref("SELECT PurgedFiles AS ok FROM Job WHERE JobId = $jobid"); +if (!$r || $r->{ok}) { + $bweb->error("File information for job $jobid has been pruned from catalog"); + $bweb->display_end(); + exit 0; +} + +$r = $bweb->dbh_selectrow_hashref("SELECT JobId AS ok FROM brestore_knownjobid WHERE JobId = $jobid"); +if (!$r || !$r->{ok}) { # TODO: compute information + $bweb->error("Path information for job $jobid has not been updated in the catalog"); + $bweb->display_end(); + exit 0; +} # if it's a file, display it if ($fnid and $pathid) @@ -266,8 +281,14 @@ sub fv_get_file_attribute { my ($jobid, $full_name) = @_; - my $filename = $bweb->dbh_quote(basename($full_name)); - my $path = $bweb->dbh_quote(dirname($full_name) . "/"); + # default to / + my $path = "'/'"; + my $filename = "''"; + + if ($full_name ne '/') { + $filename = $bweb->dbh_quote(basename($full_name)); + $path = $bweb->dbh_quote(dirname($full_name) . "/"); + } my $attr = $bweb->dbh_selectrow_hashref(" SELECT 1 AS found, @@ -277,8 +298,8 @@ sub fv_get_file_attribute base64_decode_lstat(12, LStat) AS mtime, base64_decode_lstat(13, LStat) AS ctime - FROM File INNER JOIN Filename USING (FilenameId) - INNER JOIN Path USING (PathId) + FROM File JOIN Filename USING (FilenameId) + JOIN Path USING (PathId) WHERE Name = $filename AND Path = $path AND JobId = $jobid diff --git a/gui/bweb/cgi/bgraph.pl b/gui/bweb/cgi/bgraph.pl index f44e73e292..80c26ca83e 100755 --- a/gui/bweb/cgi/bgraph.pl +++ b/gui/bweb/cgi/bgraph.pl @@ -103,7 +103,7 @@ if ($arg->{jclients}) { } my $groupf=''; # from clause -my $groupq=''; # whre clause +my $groupq=''; # where clause if ($arg->{jclient_groups}) { $groupf = " JOIN client_group_member ON (Client.ClientId = client_group_member.clientid) JOIN client_group USING (client_group_id)"; @@ -231,6 +231,7 @@ sub make_tab my $ret = {}; foreach my $row (@$all_row) { + # Todo, add Level to label if option is set ->[4] my $label = $row->[1] . "/" . $row->[2] ; # client/backup name $ret->{date}->[$i] = $row->[0]; @@ -277,7 +278,8 @@ SELECT UNIX_TIMESTAMP(Job.StartTime) AS starttime, Client.Name AS clientname, Job.Name AS jobname, - Job.JobBytes AS jobbytes + Job.JobBytes AS jobbytes, + Job.Level AS joblevel FROM $jobt AS Job, FileSet, Client $filter $groupf WHERE Job.ClientId = Client.ClientId AND Job.FileSetId = FileSet.FileSetId @@ -315,7 +317,8 @@ SELECT UNIX_TIMESTAMP(Job.StartTime) AS starttime, Client.Name AS clientname, Job.Name AS jobname, - Job.JobFiles AS jobfiles + Job.JobFiles AS jobfiles, + Job.Level AS joblevel FROM $jobt AS Job, FileSet, Client $filter $groupf WHERE Job.ClientId = Client.ClientId AND Job.FileSetId = FileSet.FileSetId @@ -356,7 +359,8 @@ elsif ($graph eq 'file_histo' and $arg->{where}) { SELECT UNIX_TIMESTAMP(Job.StartTime) AS starttime, Client.Name AS client, Job.Name AS jobname, - base64_decode_lstat(8,LStat) AS lstat + base64_decode_lstat(8,LStat) AS lstat, + Job.Level AS joblevel FROM Job, FileSet, Filename, Path, File, Client $filter WHERE Job.ClientId = Client.ClientId @@ -406,7 +410,8 @@ elsif ($graph eq 'rep_histo' and $arg->{where}) { SELECT UNIX_TIMESTAMP(Job.StartTime) AS starttime, Client.Name AS client, Job.Name AS jobname, - brestore_pathvisibility.size AS size + brestore_pathvisibility.size AS size, + Job.Level AS joblevel FROM Job, Client $filter, FileSet, Path, brestore_pathvisibility WHERE Job.ClientId = Client.ClientId @@ -453,7 +458,8 @@ SELECT ($bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime) - $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) + 0.01) - AS rate + AS rate, + Job.Level AS joblevel FROM $jobt AS Job, FileSet, Client $filter $groupf WHERE Job.ClientId = Client.ClientId @@ -496,7 +502,9 @@ SELECT Job.Name AS jobname, $bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime) - $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) - AS duration + AS duration, + Job.Level AS joblevel + FROM $jobt AS Job, FileSet, Client $filter $groupf WHERE Job.ClientId = Client.ClientId AND Job.FileSetId = FileSet.FileSetId diff --git a/gui/bweb/html/bweb.css b/gui/bweb/html/bweb.css index 0009dec5ab..82c509aa1d 100644 --- a/gui/bweb/html/bweb.css +++ b/gui/bweb/html/bweb.css @@ -10,6 +10,8 @@ button.formulaire { border: 0px; font-size: 9pt; background-color: transparent; button.bp { border: 0px; background-color: transparent; } td.joberr { background-color: red; color: white;} +.joberr a:link { color: white; } +.joberr a:visited { color: #ffe0c0; } .pSlice, .pSliceFull, .pSliceError, .pSliceAppend, .pSlicePurged, .pSliceRecycle, .pSliceArchive, .pSliceUsed, .pSliceRead_Only, .pSliceDisabled, diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 2fb9da05e9..7d201d1219 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -234,6 +234,7 @@ our %k_re = ( dbi => qr/^(dbi:(Pg|mysql):(?:\w+=[\w\d\.-]+;?)+)$/i, display_log_time => qr!^(on)?$!, enable_security => qr/^(on)?$/, enable_security_acl => qr/^(on)?$/, + default_age => qr/^(?:\d+(?:[ywdhms]\s*)?)+\s*$/, ); =head1 FUNCTION @@ -273,6 +274,9 @@ sub load return $self->error("If you update from an old bweb install, your must reload this page and if it's fail again, you have to configure bweb again...") ; } + # set default values + $self->{default_age} = '7d'; + foreach my $k (keys %$VAR1) { $self->{$k} = $VAR1->{$k}; } @@ -1271,7 +1275,6 @@ use DBI; use POSIX qw/strftime/; our $config_file='/etc/bacula/bweb.conf'; - our $cur_id=0; =head1 VARIABLE @@ -1425,6 +1428,25 @@ sub human_size return sprintf($format, $val, $unit[$i]); } +sub human_sec_unit +{ + my $val = shift; + my $orig = $val; + if ($val =~ /^(?:\d+(?:[ywdhms]\s*)?)+\s*$/) { + for ($val) { + s/y/*52w/g; + s/w/*7d/g; + s/d/*24h/g; + s/h/*60m/g; + s/m/*60s/g; + s/s(\d)/+$1/g; + s/s//; + } + $val = eval $val; + } + return int($val); +} + # display Day, Hour, Year sub human_sec { @@ -1740,7 +1762,7 @@ sub get_form slot => 0, drive => 0, priority => 10, - age => 60*60*24*7, + age => $self->{info}->{default_age}, days => 1, maxvoljobs => 0, maxvolbytes => 0, @@ -1798,6 +1820,10 @@ sub get_form my $value = CGI::param($i) || $opt_i{$i} ; if ($value =~ /^(\d+)$/) { $ret{$i} = $1; + } elsif ($value eq 'age' && # can have unit + $i =~ /^(?:\d+(?:[ywdhms]\s*)?)+\s*$/) # 2y1h2m34s + { + $ret{$i} = human_sec_unit($i); } } elsif ($opt_s{$i}) { # simple string param my $value = CGI::param($i) || ''; @@ -2212,6 +2238,7 @@ SELECT $row->{db_size} = human_size($row->{db_size}); $row->{label} = $label; + $row->{age} = $arg{age}; $self->display($row, "general.tpl"); } @@ -3618,6 +3645,7 @@ GROUP BY Client.Name $row->{ID} = $cur_id++; $row->{label} = $label; $row->{grapharg} = "client"; + $row->{age} = $arg{age}; $self->display($row, "display_client_stats.tpl"); } diff --git a/gui/bweb/technotes-2.3 b/gui/bweb/technotes-2.3 index 973d33aa66..d61e392ae0 100644 --- a/gui/bweb/technotes-2.3 +++ b/gui/bweb/technotes-2.3 @@ -1,3 +1,15 @@ +21Sep08 +ebl + bfileview: + - Add error message for pruned of uncomputed jobs + - Bugfix for looking / + Bweb.pm + - Add support for age=1w2d40m + - Add new configuration variable to modify default age + general.tpl + - Add hyperlink to failed job count + TODO: add C.png (with something like zzZZzzz) + 25Aug08 ebl Fix #1132 about typo in directory creation in install_bweb diff --git a/gui/bweb/tpl/config_edit.tpl b/gui/bweb/tpl/config_edit.tpl index 38a940ea15..92d48f278c 100644 --- a/gui/bweb/tpl/config_edit.tpl +++ b/gui/bweb/tpl/config_edit.tpl @@ -53,6 +53,9 @@ + __default_age:__ + + display_log_time: checked='checked' value='on' > diff --git a/gui/bweb/tpl/config_view.tpl b/gui/bweb/tpl/config_view.tpl index b784aa75d2..d2ef93e06d 100644 --- a/gui/bweb/tpl/config_view.tpl +++ b/gui/bweb/tpl/config_view.tpl @@ -19,6 +19,7 @@ wiki_url: template_dir: __language:__ + __default_age:__ display_log_time: __security:__ __security acl:__ diff --git a/gui/bweb/tpl/display_client_stats.tpl b/gui/bweb/tpl/display_client_stats.tpl index 00a1dc7de5..27babe9edc 100644 --- a/gui/bweb/tpl/display_client_stats.tpl +++ b/gui/bweb/tpl/display_client_stats.tpl @@ -5,9 +5,9 @@
- Not enough data   - Not enough data   - Not enough data   + Not enough data   + Not enough data   + Not enough data