12 Bweb - A Bacula web interface
13 Bacula® - The Network Backup Solution
15 Copyright (C) 2000-2010 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.
20 This program is Free Software; you can redistribute it and/or
21 modify it under the terms of version three of the GNU Affero General Public
22 License as published by the Free Software Foundation and included
25 This program is distributed in the hope that it will be useful, but
26 WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 Affero General Public License for more details.
30 You should have received a copy of the GNU Affero General Public License
31 along with this program; if not, write to the Free Software
32 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
35 Bacula® is a registered trademark of Kern Sibbald.
36 The licensor of Bacula is the Free Software Foundation Europe
37 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
38 Switzerland, email:ftf@fsfeurope.org.
49 my $conf = new Bweb::Config(config_file => $Bweb::config_file);
51 my $bweb = new Bweb(info => $conf);
53 my $b = $bweb->get_bconsole();
54 my $ret = $b->director_get_sched(1);
56 if (CGI::param('client')) {
62 # check for next backup that client are online
63 foreach my $elt (@$ret) {
64 next unless ($elt->{name});
66 my $job = $b->send_cmd("show job=\"$elt->{name}\"");
67 my $obj = $bweb->run_parse_job($job);
69 # print "I: test $obj->{client}\n" if $verbose;
70 next unless ($obj->{client});
71 my $out = $b->send_cmd("st client=\"$obj->{client}\"");
72 if ($out !~ /Daemon started/m or $out !~ /^ Heap:/m) {
73 print "E: Can't connect to $obj->{client}\n";
81 ---------------------\n";
83 my $arg = $bweb->get_form('age', 'since');
84 my ($limit, $label) = $bweb->get_limit(age => $arg->{age},
85 since => $arg->{since});
87 SELECT Job.ClientId AS c0, Job.Name AS c1,
89 FROM Job JOIN Client USING (ClientId)
94 GROUP BY Job.Name,Job.ClientId,Client.Name
97 my $old = $bweb->dbh_selectall_arrayref($query);
99 foreach my $elt (@$old) {
100 $elt->[1] = $bweb->dbh_quote($elt->[1]);
102 SELECT JobId AS jobid, JobBytes AS jobbytes
107 AND Job.ClientId = $elt->[0]
108 AND Job.Name = $elt->[1]
110 ORDER BY StartTime DESC
114 my $last_bkp = $bweb->dbh_selectrow_hashref($query);
117 SELECT COUNT(1) as nbjobs, AVG(JobBytes) as nbbytes
119 (SELECT StartTime,JobBytes
121 WHERE JobId < $last_bkp->{jobid}
125 AND ClientId = $elt->[0]
126 AND Job.Name = $elt->[1]
132 my $avg_bkp = $bweb->dbh_selectrow_hashref($query);
134 if ($avg_bkp->{nbjobs} > 3) {
135 if ($last_bkp->{jobbytes} > ($avg_bkp->{nbbytes} * 1.2)) {
136 print "W: Last backup $elt->[1] on $elt->[2] is greater than 20% (last=",
137 &Bweb::human_size($last_bkp->{jobbytes}), " avg=",
138 &Bweb::human_size($avg_bkp->{nbbytes}), ")\n";
140 if ($last_bkp->{jobbytes} < ($avg_bkp->{nbbytes} * 0.8)) {
141 print "W: Last backup $elt->[1] on $elt->[2] is lower than 20% (last=",
142 &Bweb::human_size($last_bkp->{jobbytes}), " avg=",
143 &Bweb::human_size($avg_bkp->{nbbytes}), ")\n";
148 Check missing backup for 2 weeks
149 ---------------------------------\n";
151 # we check that each job have been run one time for 2 weeks
152 my @jobs = $b->list_job();
153 ($limit, $label) = $bweb->get_limit(age => 2*7*24*60*60);
155 foreach my $j (@jobs) {
157 $j = $bweb->dbh_quote($j);
167 my $row = $bweb->dbh_selectrow_hashref($query);
171 SELECT StartTime AS starttime, Level AS level
178 $row = $bweb->dbh_selectrow_hashref($query);
179 print "W: No job for $j ";
181 print "($row->{level} $row->{starttime})";