5 Bweb - A Bacula web interface
6 Bacula® - The Network Backup Solution
8 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
10 The main author of Bweb is Eric Bollengier.
11 The main author of Bacula is Kern Sibbald, with contributions from
12 many others, a complete list can be found in the file AUTHORS.
14 This program is Free Software; you can redistribute it and/or
15 modify it under the terms of version two of the GNU General Public
16 License as published by the Free Software Foundation plus additions
17 that are listed in the file LICENSE.
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 Bacula® is a registered trademark of John Walker.
30 The licensor of Bacula is the Free Software Foundation Europe
31 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
32 Switzerland, email:ftf@fsfeurope.org.
40 use Time::ParseDate qw/parsedate/;
43 my $conf = new Bweb::Config(config_file => $Bweb::config_file);
46 my $bweb = new Bweb(info => $conf);
47 my $arg = $bweb->get_form(qw/qiso_begin qiso_end qusage qpool qnojob
48 jclient_groups db_client_groups qclient_groups/);
50 use Digest::MD5 qw(md5_hex);
51 my $md5_rep = md5_hex("$arg->{qiso_begin}:$arg->{qiso_end}:$arg->{qusage}:" .
52 "$arg->{jclient_groups}:$arg->{qpool};$arg->{qnojob}") ;
54 print CGI::header('text/html');
55 $bweb->display_begin();
57 if ($arg->{qiso_begin} && -f "$conf->{fv_write_path}/$md5_rep.png") {
58 $arg->{result} = "/bweb/fv/$md5_rep.png";
59 $bweb->display($arg, 'btime.tpl');
66 debug => $conf->{debug},
75 my $sec = $bweb->{sql}->{STARTTIME_SEC};
76 $sec =~ s/Job.StartTime/Log.Time/;
77 my $reg = $bweb->{sql}->{MATCH};
81 end_job => ': Bacula [1-9]',
82 start_job => ': Start Backup',
83 data_despool_time => ': Despooling elapsed time',
84 attr_despool_time => ': Sending spooled attrs',
85 get_drive => ': Using Device',
86 start_spool => ': Spooling',
87 end_spool => ': User specified spool',
92 end_job => ': Bacula [1-9]',
93 start_job => ': D.marrage du ',
94 data_despool_time => ': Temps du tran',
95 attr_despool_time => ': Transfert des',
96 get_drive => ': Using Device',
97 start_spool => ': Spooling',
98 end_spool => ': Taille du spool',
101 my $filter = join(" OR ",
102 map { "Log.LogText $bweb->{sql}->{MATCH} '$_'" } values %regs);
105 SELECT " . $bweb->dbh_strcat('Job.Name', "'_'", 'Job.Level') . ",
107 substring(Log.LogText from 1 for 65),
111 FROM Log INNER JOIN Job USING (JobId) JOIN Pool USING (PoolId)
112 " . ($arg->{jclient_groups}?
113 " JOIN Client USING (ClientId)
114 JOIN client_group_member ON (Client.ClientId = client_group_member.clientid)
115 JOIN client_group USING (client_group_id)
116 WHERE client_group_name IN ($arg->{jclient_groups})
120 Job.StartTime > $arg->{qiso_begin}
121 AND Job.StartTime < $arg->{qiso_end}
124 ORDER BY Job.JobId,Log.Time
128 print STDERR $query if ($conf->{debug})
129 my $all = $bweb->dbh_selectall_arrayref($query);
140 foreach my $elt (@$all)
142 if ($lastid && $lastid ne $elt->[3]) {
143 if (!$arg->{qnojob}) {
144 $top->add_job(label => $last_name,
151 if ($elt->[2] =~ /$regs{start_job}/) {
158 } elsif ($elt->[2] =~ /$regs{attr_despool_time}/) {
166 } elsif ($elt->[2] =~ /$regs{get_drive} "([\w\d]+)"/) {
169 } elsif ($elt->[2] =~ /$regs{data_despool_time}.+? = (\d+):(\d+):(\d+)/) {
170 # on connait le temps de despool
171 my $t = $1*60*60+ $2*60 + $3;
173 if ($t > 10) { # en dessous de 10s on affiche pas
174 push @$data, { # temps d'attente du drive
177 end => parsedate($elt->[1]) - $t,
182 begin => parsedate($elt->[1]) - $t,
186 push @{$write->{$drive}}, { # display only write time
188 begin => parsedate($elt->[1]) - $t,
192 push @{$pool->{"$drive: $elt->[4]"}}, {
194 begin => parsedate($elt->[1]) - $t,
205 } elsif ($elt->[2] =~ /$regs{start_spool}/) {
217 } elsif ($elt->[2] =~ /($regs{end_spool}|$regs{attr_despool_time})/) {
224 } elsif ($elt->[2] =~ /$regs{end_job}/) {
232 $last_name = $elt->[0];
236 if (!$arg->{qnojob} && $last_name) {
237 $top->add_job(label => $last_name,
241 foreach my $d (sort keys %$pool) {
242 $top->add_job(label => $d,
243 data => $pool->{$d});
247 if ($arg->{qusage}) {
248 foreach my $d (sort keys %$write) {
249 $top->add_job(label => "drive $d",
250 data => $write->{$d});
257 open(FP, ">$conf->{fv_write_path}/$md5_rep.png");
259 # Convert the image to PNG and print it on standard output
260 print FP $GTime::gd->png;
263 $arg->{result} = "/bweb/fv/$md5_rep.png";
264 $bweb->display( $arg, 'btime.tpl');
265 $bweb->display_end();