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\.-]+)$/;
34 my $pool_re = $client_re;
36 my $action = CGI::param('action') || 'begin';
38 if ($action eq 'restore') {
39 print CGI::header('text/brestore'); # specialy to run brestore.pl
42 print CGI::header('text/html');
46 my $conf = new Bweb::Config(config_file => '/etc/bweb/config');
49 my $bweb = new Bweb(info => $conf);
51 # just send data with text/brestore content
52 if ($action eq 'restore') {
57 my $arg = $bweb->get_form('jobid', 'limit', 'offset', 'age');
59 $bweb->display_begin();
61 # if no configuration, we send edit_conf
62 if ($action ne 'apply_conf' and !$bweb->{info}->{dbi}) {
63 $action = 'edit_conf';
66 if ($action eq 'begin') { # main display
67 print "<div style='left=0;'><table border='0'><tr><td valign='top' width='100%'>\n";
68 $bweb->display_general(age => $arg->{age});
69 $bweb->display_running_jobs(0);
70 print "</td><td valign='top'>";
72 <div class='titlediv'>
73 <h1 class='newstitle'> Statistics (last 48 hours)</h1>
76 <a href='?action=job;age=172800;jobtype=B'>
77 <img src='bgraph.pl?age=172800;width=600;height=250;graph=job_size;limit=100;action=graph;legend=off' alt='Nothing to display'>
80 print "</td></tr></table></div>";
81 $bweb->display_job(limit => 10);
83 } elsif ($action eq 'view_conf') {
86 } elsif ($action eq 'edit_conf') {
89 } elsif ($action eq 'apply_conf') {
92 } elsif ($action eq 'client') {
93 $bweb->display_clients();
95 } elsif ($action eq 'pool') {
96 $bweb->display_pool();
98 } elsif ($action eq 'location_edit') {
99 $bweb->location_edit();
101 } elsif ($action eq 'location_save') {
102 $bweb->location_save();
104 } elsif ($action eq 'location_add') {
105 $bweb->location_add();
107 } elsif ($action eq 'location_del') {
108 $bweb->del_location();
110 } elsif ($action eq 'media') {
111 $bweb->display_media();
113 } elsif ($action eq 'medias') {
114 $bweb->display_medias();
116 } elsif ($action eq 'eject') {
117 my $arg = $bweb->get_form("ach");
118 my $a = $bweb->ach_get($arg->{ach});
122 foreach my $slot (CGI::param('slot')) {
123 print $a->{error} unless $a->send_to_io($slot);
126 foreach my $media (CGI::param('media')) {
127 my $slot = $a->get_media_slot($media);
128 print $a->{error} unless $a->send_to_io($slot);
131 $a->display_content();
134 } elsif ($action eq 'eject_media') {
135 $bweb->eject_media();
137 } elsif ($action eq 'clear_io') {
138 my $arg = $bweb->get_form('ach');
140 my $a = $bweb->ach_get($arg->{ach});
144 $a->display_content();
147 } elsif ($action eq 'ach_edit') {
150 } elsif ($action eq 'ach_del') {
153 } elsif ($action eq 'ach_view') {
154 # TODO : get autochanger name and create it
156 my $arg = $bweb->get_form('ach');
158 my $a = $bweb->ach_get($arg->{ach});
161 $a->display_content();
164 } elsif ($action eq 'ach_add') {
167 } elsif ($action eq 'ach_load') {
168 my $arg = $bweb->get_form('ach', 'drive', 'slot');
170 my $a = $bweb->ach_get($arg->{ach});
172 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
174 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
175 # TODO : use template here
177 $b->send_cmd_with_drive("mount slot=$arg->{slot} storage=\"" . $a->get_drive_name($arg->{drive}) . '"',
181 $bweb->error("Can't get drive, slot or ach");
184 } elsif ($action eq 'ach_unload') {
185 my $arg = $bweb->get_form('drive', 'slot', 'ach');
187 my $a = $bweb->ach_get($arg->{ach});
189 if (defined $a and defined $arg->{drive} and defined $arg->{slot})
191 my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
192 # TODO : use template here
194 $b->send_cmd_with_drive("umount storage=\"" . $a->get_drive_name($arg->{drive}) . '"',
200 $bweb->error("Can't get drive, slot or ach");
202 } elsif ($action eq 'intern_media') {
203 $bweb->help_intern();
205 } elsif ($action eq 'compute_intern_media') {
206 $bweb->help_intern_compute();
208 } elsif ($action eq 'extern_media') {
209 $bweb->help_extern();
211 } elsif ($action eq 'compute_extern_media') {
212 $bweb->help_extern_compute();
214 } elsif ($action eq 'extern') {
215 print "TODO : Eject ", join(",", CGI::param('media'));
218 } elsif ($action eq 'change_location') {
219 $bweb->change_location();
221 } elsif ($action eq 'location') {
222 $bweb->display_location();
224 } elsif ($action eq 'about') {
225 $bweb->display($bweb, 'about.tpl');
227 } elsif ($action eq 'intern') {
228 $bweb->move_media(); # TODO : remove that
230 } elsif ($action eq 'move_media') {
233 } elsif ($action eq 'save_location') {
234 $bweb->save_location();
236 } elsif ($action eq 'update_location') {
237 $bweb->update_location();
239 } elsif ($action eq 'update_media') {
240 $bweb->update_media();
242 } elsif ($action eq 'do_update_media') {
243 $bweb->do_update_media();
245 } elsif ($action eq 'update_slots') {
246 $bweb->update_slots();
248 } elsif ($action eq 'graph') {
249 $bweb->display_graph();
251 } elsif ($action eq 'next_job') {
252 $bweb->director_show_sched();
254 } elsif ($action eq 'enable_job') {
255 $bweb->enable_disable_job(1);
257 } elsif ($action eq 'disable_job') {
258 $bweb->enable_disable_job(0);
260 } elsif ($action eq 'job') {
262 print "<div><table border='0'><tr><td valign='top'>\n";
263 my $fields = $bweb->get_form(qw/status level db_clients db_filesets
264 limit age offset qclients qfilesets
266 $bweb->display($fields, "display_form_job.tpl");
268 print "</td><td valign='top'>";
269 $bweb->display_job(age => $arg->{age}, # last 7 days
270 offset => $arg->{offset},
271 limit => $arg->{limit});
272 print "</td></tr></table></div>";
273 } elsif ($action eq 'client_stats') {
275 foreach my $client (CGI::param('client')) {
276 if ($client =~ m/$client_re/) {
277 $bweb->display_client_stats(clientname => $1,
282 } elsif ($action eq 'running') {
283 $bweb->display_running_jobs(1);
285 } elsif ($action eq 'dsp_cur_job') {
286 $bweb->display_running_job();
288 } elsif ($action eq 'update_from_pool') {
289 my $elt = $bweb->get_form(qw/media pool/);
290 unless ($elt->{media} || $elt->{pool}) {
291 $bweb->error("Can't get media or pool param");
293 my $b = new Bconsole(pref => $conf) ;
296 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
297 title => "Update pool",
298 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
302 $bweb->update_media();
304 } elsif ($action eq 'client_status') {
306 foreach my $client (CGI::param('client')) {
307 if ($client =~ m/$client_re/) {
309 $b = new Bconsole(pref => $conf)
313 content => $b->send_cmd("st client=$client"),
314 title => "Client status",
319 $bweb->error("Can't get client selection");
323 } elsif ($action eq 'cancel_job') {
326 } elsif ($action eq 'media_zoom') {
327 $bweb->display_media_zoom();
329 } elsif ($action eq 'job_zoom') {
331 $bweb->display_job_zoom($arg->{jobid});
332 $bweb->get_job_log();
334 } elsif ($action eq 'job_log') {
335 $bweb->get_job_log();
337 } elsif ($action eq 'prune') {
340 } elsif ($action eq 'purge') {
343 } elsif ($action eq 'run_job') {
346 } elsif ($action eq 'run_job_mod') {
347 $bweb->run_job_mod();
349 } elsif ($action eq 'run_job_now') {
350 $bweb->run_job_now();
352 } elsif ($action eq 'label_barcodes') {
353 $bweb->label_barcodes();
355 } elsif ($action eq 'delete') {
358 } elsif ($action eq 'fileset_view') {
359 $bweb->fileset_view();
362 $bweb->error("Sorry, this action don't exist");
365 $bweb->display_end();
372 o Affichage des job en cours, termines
373 o Affichage du detail d'un job (status client)
374 o Acces aux log d'une sauvegarde
378 o Affichage des medias (pool, cf bacweb)
379 o Affichage de la liste des cartouches
380 o Affichage d'un autochangeur
381 o Mise a jour des slots
383 o Affichage des medias qui ont besoin d'etre change
385 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
386 o Affichage des stats sur un type de job
387 o Affichage des infos de query.sql
389 - Affichage des du TapeAlert sur le site
390 - Recuperation des erreurs SCSI de /var/log/kern.log
395 o Configuration des autochanger a la main dans un hash dumper