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/;
41 use POSIX qw/strftime/;
44 my $conf = new Bweb::Config(config_file => $Bweb::config_file);
47 my $bweb = new Bweb(info => $conf);
48 my $arg = $bweb->get_form(qw/qiso_begin qiso_end qusage qpool qnojob
49 jclient_groups db_client_groups qclient_groups/);
51 if (!$arg->{qiso_begin}) {
52 $arg->{qiso_begin} = strftime('\'%F %H:%M:00\'', localtime(time - 60*60*12));
53 $arg->{qiso_end} = strftime('\'%F %H:%M:00\'', localtime(time));
55 use Digest::MD5 qw(md5_hex);
56 my $md5_rep = md5_hex("$arg->{qiso_begin}:$arg->{qiso_end}:$arg->{qusage}:" .
57 "$arg->{jclient_groups}:$arg->{qpool};$arg->{qnojob}") ;
59 print CGI::header('text/html');
60 $bweb->display_begin();
62 if ($arg->{qiso_begin} && -f "$conf->{fv_write_path}/$md5_rep.png") {
63 $arg->{result} = "/bweb/fv/$md5_rep.png";
64 $bweb->display($arg, 'btime.tpl');
71 debug => $conf->{debug},
80 my $sec = $bweb->{sql}->{STARTTIME_SEC};
81 $sec =~ s/Job.StartTime/Log.Time/;
82 my $reg = $bweb->{sql}->{MATCH};
86 end_job => ': Bacula',
87 start_job => ': Start Backup',
88 data_despool_time => ': Despooling elapsed time',
89 attr_despool_time => ': Sending spooled attrs',
90 get_drive => ': Using Device',
91 start_spool => ': Spooling',
92 end_spool => ': User specified spool',
93 end_spool2 => ': Committing spooled data to',
98 end_job => ': Bacula',
99 start_job => ': D.marrage du ',
100 data_despool_time => ': Temps du tran',
101 attr_despool_time => ': Transfert des attributs',
102 get_drive => ': Using Device',
103 start_spool => ': Spooling',
104 end_spool => ': Taille du spool',
105 end_spool2 => ': Transfert des donn',
108 my $filter = join(" OR ",
109 map { "Log.LogText $bweb->{sql}->{MATCH} '$_'" } values %regs);
112 SELECT " . $bweb->dbh_strcat('Job.Name', "'_'", 'Job.Level') . ",
114 substring(Log.LogText from 8 for 70),
118 FROM Log INNER JOIN Job USING (JobId) JOIN Pool USING (PoolId)
119 " . ($arg->{jclient_groups}?
120 " JOIN Client USING (ClientId)
121 JOIN client_group_member ON (Client.ClientId = client_group_member.clientid)
122 JOIN client_group USING (client_group_id)
123 WHERE client_group_name IN ($arg->{jclient_groups})
127 Job.StartTime > $arg->{qiso_begin}
128 AND Job.StartTime < $arg->{qiso_end}
131 ORDER BY Job.JobId,Log.LogId,Log.Time
135 print STDERR $query if ($conf->{debug});
136 my $all = $bweb->dbh_selectall_arrayref($query);
147 foreach my $elt (@$all)
149 if ($lastid && $lastid ne $elt->[3]) {
150 if (!$arg->{qnojob}) {
151 $top->add_job(label => $last_name,
158 if ($elt->[2] =~ /$regs{end_job}/) {
165 # } elsif ($elt->[2] =~ /$regs{attr_despool_time}/) {
174 } elsif ($elt->[2] =~ /$regs{get_drive} "([\w\d]+)"/) {
177 } elsif ($elt->[2] =~ /$regs{data_despool_time}.+? = (\d+):(\d+):(\d+)/) {
178 # on connait le temps de despool
179 my $t = $1*60*60+ $2*60 + $3;
181 if ($t > 10) { # en dessous de 10s on affiche pas
182 push @$data, { # temps d'attente du drive
186 end => parsedate($elt->[1]) - $t,
192 begin => parsedate($elt->[1]) - $t,
196 push @{$write->{$drive}}, { # display only write time
198 begin => parsedate($elt->[1]) - $t,
202 push @{$pool->{"$drive: $elt->[4]"}}, {
204 begin => parsedate($elt->[1]) - $t,
217 } elsif ($elt->[2] =~ /$regs{start_spool}/) {
229 } elsif ($elt->[2] =~ /($regs{end_spool}|$regs{end_spool2})/) {
237 } elsif ($elt->[2] =~ /$regs{start_job}/) {
245 $last_name = $elt->[0];
249 if (!$arg->{qnojob} && $last_name) {
250 $top->add_job(label => $last_name,
254 foreach my $d (sort keys %$pool) {
255 $top->add_job(label => $d,
256 data => $pool->{$d});
260 if ($arg->{qusage}) {
261 foreach my $d (sort keys %$write) {
262 $top->add_job(label => "drive $d",
263 data => $write->{$d});
267 #print STDERR Data::Dumper::Dumper($top);
271 open(FP, ">$conf->{fv_write_path}/$md5_rep.png");
273 # Convert the image to PNG and print it on standard output
274 print FP $GTime::gd->png;
277 $arg->{result} = "/bweb/fv/$md5_rep.png";
278 $bweb->display( $arg, 'btime.tpl');
279 $bweb->display_end();