12 Bweb - A Bacula web interface
13 Bacula® - The Network Backup Solution
15 Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
17 The main author of Bweb is Eric Bollengier.
18 The main author of Bacula is Kern Sibbald, with contributions from
19 many others, a complete list can be found in the file AUTHORS.
21 This program is Free Software; you can redistribute it and/or
22 modify it under the terms of version two of the GNU General Public
23 License as published by the Free Software Foundation plus additions
24 that are listed in the file LICENSE.
26 This program is distributed in the hope that it will be useful, but
27 WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 General Public License for more details.
31 You should have received a copy of the GNU General Public License
32 along with this program; if not, write to the Free Software
33 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
36 Bacula® is a registered trademark of John Walker.
37 The licensor of Bacula is the Free Software Foundation Europe
38 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
39 Switzerland, email:ftf@fsfeurope.org.
50 my $conf = new Bweb::Config(config_file => $Bweb::config_file);
52 my $bweb = new Bweb(info => $conf);
54 my $b = $bweb->get_bconsole();
55 my $ret = $b->director_get_sched(1);
57 if (CGI::param('client')) {
63 # check for next backup that client are online
64 foreach my $elt (@$ret) {
65 next unless ($elt->{name});
67 my $job = $b->send_cmd("show job=\"$elt->{name}\"");
68 my $obj = $bweb->run_parse_job($job);
70 # print "I: test $obj->{client}\n" if $verbose;
71 next unless ($obj->{client});
72 my $out = $b->send_cmd("st client=\"$obj->{client}\"");
73 if ($out !~ /Daemon started/m or $out !~ /^ Heap:/m) {
74 print "E: Can't connect to $obj->{client}\n";
82 ---------------------\n";
84 my $arg = $bweb->get_form('age', 'since');
85 my ($limit, $label) = $bweb->get_limit(age => $arg->{age},
86 since => $arg->{since});
88 SELECT Job.ClientId AS c0, Job.Name AS c1,
90 FROM Job JOIN Client USING (ClientId)
95 GROUP BY Job.Name,Job.ClientId,Client.Name
98 my $old = $bweb->dbh_selectall_arrayref($query);
100 foreach my $elt (@$old) {
101 $elt->[1] = $bweb->dbh_quote($elt->[1]);
103 SELECT JobId AS jobid, JobBytes AS jobbytes
108 AND Job.ClientId = $elt->[0]
109 AND Job.Name = $elt->[1]
111 ORDER BY StartTime DESC
115 my $last_bkp = $bweb->dbh_selectrow_hashref($query);
118 SELECT COUNT(1) as nbjobs, AVG(JobBytes) as nbbytes
120 (SELECT StartTime,JobBytes
122 WHERE JobId < $last_bkp->{jobid}
126 AND ClientId = $elt->[0]
127 AND Job.Name = $elt->[1]
133 my $avg_bkp = $bweb->dbh_selectrow_hashref($query);
135 if ($avg_bkp->{nbjobs} > 3) {
136 if ($last_bkp->{jobbytes} > ($avg_bkp->{nbbytes} * 1.2)) {
137 print "W: Last backup $elt->[1] on $elt->[2] is greater than 20% (last=",
138 &Bweb::human_size($last_bkp->{jobbytes}), " avg=",
139 &Bweb::human_size($avg_bkp->{nbbytes}), ")\n";
141 if ($last_bkp->{jobbytes} < ($avg_bkp->{nbbytes} * 0.8)) {
142 print "W: Last backup $elt->[1] on $elt->[2] is lower than 20% (last=",
143 &Bweb::human_size($last_bkp->{jobbytes}), " avg=",
144 &Bweb::human_size($avg_bkp->{nbbytes}), ")\n";
149 Check missing backup for 2 weeks
150 ---------------------------------\n";
152 # we check that each job have been run one time for 2 weeks
153 my @jobs = $b->list_job();
154 ($limit, $label) = $bweb->get_limit(age => 2*7*24*60*60);
156 foreach my $j (@jobs) {
158 $j = $bweb->dbh_quote($j);
168 my $row = $bweb->dbh_selectrow_hashref($query);
172 SELECT StartTime AS starttime, Level AS level
179 $row = $bweb->dbh_selectrow_hashref($query);
180 print "W: No job for $j ";
182 print "($row->{level} $row->{starttime})";