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 $bweb->can_do('r_view_stat');
50 my $arg = $bweb->get_form(qw/qiso_begin qiso_end qusage qpools qpoolusage qnojob
51 jclient_groups db_client_groups qclient_groups/);
52 my ($filter1, undef) = $bweb->get_param('pool');
54 if (!$arg->{qiso_begin}) {
55 $arg->{qiso_begin} = strftime('\'%F %H:%M:00\'', localtime(time - 60*60*12));
56 $arg->{qiso_end} = strftime('\'%F %H:%M:00\'', localtime(time));
58 use Digest::MD5 qw(md5_hex);
59 my $md5_rep = md5_hex("$arg->{qiso_begin}:$arg->{qiso_end}:$arg->{qusage}:" .
60 "$arg->{jclient_groups}:$arg->{qpoolusage};$arg->{qnojob}") ;
62 print CGI::header('text/html');
63 $bweb->display_begin();
65 if ($arg->{qiso_begin} && -f "$conf->{fv_write_path}/$md5_rep.png") {
66 $arg->{result} = "/bweb/fv/$md5_rep.png";
67 $bweb->display($arg, 'btime.tpl');
74 debug => $conf->{debug},
83 my $sec = $bweb->{sql}->{STARTTIME_SEC};
84 $sec =~ s/Job.StartTime/Log.Time/;
85 my $reg = $bweb->{sql}->{MATCH};
89 end_job => ': Bacula',
90 start_job => ': Start Backup',
91 data_despool_time => ': Despooling elapsed time',
92 attr_despool_time => ': Sending spooled attrs',
93 get_drive => ': Using Device',
94 start_spool => ': Spooling',
95 end_spool => ': User specified spool',
96 end_spool2 => ': Committing spooled data to',
101 end_job => ': Bacula',
102 start_job => ': D.marrage du ',
103 data_despool_time => ': Temps du tran',
104 attr_despool_time => ': Transfert des attributs',
105 get_drive => ': Using Device',
106 start_spool => ': Spooling',
107 end_spool => ': Taille du spool',
108 end_spool2 => ': Transfert des donn',
111 my $filter = join(" OR ",
112 map { "Log.LogText $bweb->{sql}->{MATCH} '$_'" } values %regs);
115 SELECT " . $bweb->dbh_strcat('Job.Name', "'_'", 'Job.Level') . ",
117 substring(Log.LogText from 8 for 70),
121 FROM Log INNER JOIN Job USING (JobId) JOIN Pool USING (PoolId)
122 " . ($arg->{jclient_groups}?
123 " JOIN Client USING (ClientId)
124 JOIN client_group_member ON (Client.ClientId = client_group_member.clientid)
125 JOIN client_group USING (client_group_id)
126 WHERE client_group_name IN ($arg->{jclient_groups})
130 Job.StartTime > $arg->{qiso_begin}
131 AND Job.StartTime < $arg->{qiso_end}
135 ORDER BY Job.JobId,Log.LogId,Log.Time ";
138 print STDERR $query if ($conf->{debug});
139 my $all = $bweb->dbh_selectall_arrayref($query);
150 foreach my $elt (@$all)
152 if ($lastid && $lastid ne $elt->[3]) {
153 if (!$arg->{qnojob}) {
154 $top->add_job(label => $last_name,
161 if ($elt->[2] =~ /$regs{end_job}/) {
168 # } elsif ($elt->[2] =~ /$regs{attr_despool_time}/) {
177 } elsif ($elt->[2] =~ /$regs{get_drive} "([\w\d]+)"/) {
180 } elsif ($elt->[2] =~ /$regs{data_despool_time}.+? = (\d+):(\d+):(\d+)/) {
181 # on connait le temps de despool
182 my $t = $1*60*60+ $2*60 + $3;
184 if ($t > 10) { # en dessous de 10s on affiche pas
185 push @$data, { # temps d'attente du drive
189 end => parsedate($elt->[1]) - $t,
195 begin => parsedate($elt->[1]) - $t,
199 push @{$write->{$drive}}, { # display only write time
201 begin => parsedate($elt->[1]) - $t,
205 push @{$pool->{"$drive: $elt->[4]"}}, {
207 begin => parsedate($elt->[1]) - $t,
220 } elsif ($elt->[2] =~ /$regs{start_spool}/) {
232 } elsif ($elt->[2] =~ /($regs{end_spool}|$regs{end_spool2})/) {
240 } elsif ($elt->[2] =~ /$regs{start_job}/) {
248 $last_name = $elt->[0];
252 if (!$arg->{qnojob} && $last_name) {
253 $top->add_job(label => $last_name,
256 if ($arg->{qpoolusage}) {
257 foreach my $d (sort keys %$pool) {
258 $top->add_job(label => $d,
259 data => $pool->{$d});
263 if ($arg->{qusage}) {
264 foreach my $d (sort keys %$write) {
265 $top->add_job(label => "drive $d",
266 data => $write->{$d});
270 #print STDERR Data::Dumper::Dumper($top);
274 open(FP, ">$conf->{fv_write_path}/$md5_rep.png");
276 # Convert the image to PNG and print it on standard output
277 print FP $GTime::gd->png;
280 $arg->{result} = "/bweb/fv/$md5_rep.png";
281 $bweb->display( $arg, 'btime.tpl');
282 $bweb->display_end();