6 Copyright (C) 2006 Eric Bollengier
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 my $client_re = qr/^([\w\d\.-]+)$/;
35 my $action = CGI::param('action') || 'begin';
37 if ($action eq 'restore') {
38 print CGI::header('text/brestore'); # specialy to run brestore.pl
41 print CGI::header('text/html');
45 my $conf = new Bweb::Config(config_file => '/etc/bweb/config');
48 my $bweb = new Bweb(info => $conf);
50 # just send data with text/brestore content
51 if ($action eq 'restore') {
56 my $arg = $bweb->get_form('jobid', 'limit', 'offset', 'age');
58 $bweb->display_begin();
60 # if no configuration, we send edit_conf
61 if ($action ne 'apply_conf' and !$bweb->{info}->{dbi}) {
62 $action = 'edit_conf';
65 if ($action eq 'begin') { # main display
66 print "<div style='left=0;'><table border='0'><tr><td valign='top' width='100%'>\n";
67 $bweb->display_general(age => $arg->{age});
68 $bweb->display_running_jobs(0);
69 print "</td><td valign='top'>";
71 <div class='titlediv'>
72 <h1 class='newstitle'> Statistics </h1>
75 <a href='?action=job;age=172800;jobtype=B'>
76 <img src='bgraph.pl?age=2678400;width=600;height=250;graph=job_sum_day;limit=300;action=graph;legend=off' alt='Nothing to display'>
79 print "</td></tr></table></div>";
80 $bweb->display_job(limit => 10);
82 } elsif ($action eq 'view_conf') {
85 } elsif ($action eq 'edit_conf') {
88 } elsif ($action eq 'apply_conf') {
91 } elsif ($action eq 'client') {
92 $bweb->display_clients();
94 } elsif ($action eq 'pool') {
95 $bweb->display_pool();
97 } elsif ($action eq 'location_edit') {
98 $bweb->location_edit();
100 } elsif ($action eq 'location_save') {
101 $bweb->location_save();
103 } elsif ($action eq 'location_add') {
104 $bweb->location_add();
106 } elsif ($action eq 'location_del') {
107 $bweb->location_del();
109 } elsif ($action eq 'media') {
110 $bweb->display_media();
112 } elsif ($action eq 'medias') {
113 $bweb->display_medias();
115 } elsif ($action eq 'eject') {
116 my $arg = $bweb->get_form("ach");
117 my $a = $bweb->ach_get($arg->{ach});
121 foreach my $slot (CGI::param('slot')) {
122 print $a->{error} unless $a->send_to_io($slot);
125 foreach my $media (CGI::param('media')) {
126 my $slot = $a->get_media_slot($media);
127 print $a->{error} unless $a->send_to_io($slot);
130 $a->display_content();
133 } elsif ($action eq 'eject_media') {
134 $bweb->eject_media();
136 } elsif ($action eq 'clear_io') {
137 my $arg = $bweb->get_form('ach');
139 my $a = $bweb->ach_get($arg->{ach});
143 $a->display_content();
146 } elsif ($action eq 'ach_edit') {
149 } elsif ($action eq 'ach_del') {
152 } elsif ($action eq 'ach_view') {
153 # TODO : get autochanger name and create it
155 my $arg = $bweb->get_form('ach');
157 my $a = $bweb->ach_get($arg->{ach});
160 $a->display_content();
163 } elsif ($action eq 'ach_add') {
166 } elsif ($action eq 'ach_load') {
167 my $arg = $bweb->get_form('ach', 'drive', 'slot');
169 my $a = $bweb->ach_get($arg->{ach});
171 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
173 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
174 # TODO : use template here
176 $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
179 $bweb->error("Can't get drive, slot or ach");
182 } elsif ($action eq 'ach_unload') {
183 my $arg = $bweb->get_form('drive', 'slot', 'ach');
185 my $a = $bweb->ach_get($arg->{ach});
187 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
189 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
190 # TODO : use template here
192 $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
196 $bweb->error("Can't get drive, slot or ach");
198 } elsif ($action eq 'intern_media') {
199 $bweb->help_intern();
201 } elsif ($action eq 'compute_intern_media') {
202 $bweb->help_intern_compute();
204 } elsif ($action eq 'extern_media') {
205 $bweb->help_extern();
207 } elsif ($action eq 'compute_extern_media') {
208 $bweb->help_extern_compute();
210 } elsif ($action eq 'extern') {
211 $bweb->eject_media();
214 } elsif ($action eq 'move_email') {
217 } elsif ($action eq 'change_location') {
218 $bweb->change_location();
220 } elsif ($action eq 'location') {
221 $bweb->display_location();
223 } elsif ($action eq 'about') {
224 $bweb->display($bweb, 'about.tpl');
226 } elsif ($action eq 'intern') {
227 $bweb->move_media(); # TODO : remove that
229 } elsif ($action eq 'move_media') {
232 } elsif ($action eq 'save_location') {
233 $bweb->save_location();
235 } elsif ($action eq 'update_location') {
236 $bweb->update_location();
238 } elsif ($action eq 'update_media') {
239 $bweb->update_media();
241 } elsif ($action eq 'do_update_media') {
242 $bweb->do_update_media();
244 } elsif ($action eq 'update_slots') {
245 $bweb->update_slots();
247 } elsif ($action eq 'graph') {
248 $bweb->display_graph();
250 } elsif ($action eq 'next_job') {
251 $bweb->director_show_sched();
253 } elsif ($action eq 'enable_job') {
254 $bweb->enable_disable_job(1);
256 } elsif ($action eq 'disable_job') {
257 $bweb->enable_disable_job(0);
259 } elsif ($action eq 'job') {
261 print "<div><table border='0'><tr><td valign='top'>\n";
262 my $fields = $bweb->get_form(qw/status level db_clients db_filesets
263 limit age offset qclients qfilesets
265 $bweb->display($fields, "display_form_job.tpl");
267 print "</td><td valign='top'>";
268 $bweb->display_job(age => $arg->{age}, # last 7 days
269 offset => $arg->{offset},
270 limit => $arg->{limit});
271 print "</td></tr></table></div>";
272 } elsif ($action eq 'client_stats') {
274 foreach my $client (CGI::param('client')) {
275 if ($client =~ m/$client_re/) {
276 $bweb->display_client_stats(clientname => $1,
281 } elsif ($action eq 'running') {
282 $bweb->display_running_jobs(1);
284 } elsif ($action eq 'dsp_cur_job') {
285 $bweb->display_running_job();
287 } elsif ($action eq 'update_from_pool') {
288 my $elt = $bweb->get_form(qw/media pool/);
289 unless ($elt->{media} || $elt->{pool}) {
290 $bweb->error("Can't get media or pool param");
292 my $b = new Bconsole(pref => $conf) ;
295 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
296 title => "Update pool",
297 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
301 $bweb->update_media();
303 } elsif ($action eq 'client_status') {
305 foreach my $client (CGI::param('client')) {
306 if ($client =~ m/$client_re/) {
308 $b = new Bconsole(pref => $conf)
312 content => $b->send_cmd("st client=$client"),
313 title => "Client status",
318 $bweb->error("Can't get client selection");
322 } elsif ($action eq 'cancel_job') {
325 } elsif ($action eq 'media_zoom') {
326 $bweb->display_media_zoom();
328 } elsif ($action eq 'job_zoom') {
330 $bweb->display_job_zoom($arg->{jobid});
331 $bweb->get_job_log();
333 } elsif ($action eq 'job_log') {
334 $bweb->get_job_log();
336 } elsif ($action eq 'prune') {
339 } elsif ($action eq 'purge') {
342 } elsif ($action eq 'run_job') {
345 } elsif ($action eq 'run_job_mod') {
346 $bweb->run_job_mod();
348 } elsif ($action eq 'run_job_now') {
349 $bweb->run_job_now();
351 } elsif ($action eq 'label_barcodes') {
352 $bweb->label_barcodes();
354 } elsif ($action eq 'delete') {
357 } elsif ($action eq 'fileset_view') {
358 $bweb->fileset_view();
361 $bweb->error("Sorry, this action don't exist");
364 $bweb->display_end();
371 o Affichage des job en cours, termines
372 o Affichage du detail d'un job (status client)
373 o Acces aux log d'une sauvegarde
377 o Affichage des medias (pool, cf bacweb)
378 o Affichage de la liste des cartouches
379 o Affichage d'un autochangeur
380 o Mise a jour des slots
382 o Affichage des medias qui ont besoin d'etre change
384 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
385 o Affichage des stats sur un type de job
386 o Affichage des infos de query.sql
388 - Affichage des du TapeAlert sur le site
389 - Recuperation des erreurs SCSI de /var/log/kern.log
394 o Configuration des autochanger a la main dans un hash dumper