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 unless ($bweb->{info}->{dbi}) {
63 $action = 'edit_conf';
66 if ($action eq 'begin') { # main display
67 print "<table border='0'><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=450;height=250;graph=job_size;limit=100;action=graph;legend=off' alt='Nothing to display'>
80 print "</td></table>";
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 'del_location') {
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 $a = Bweb::Autochanger::get('S1_L80', $bweb);
120 foreach my $slot (CGI::param('slot')) {
121 print $a->{error} unless $a->send_to_io($slot);
124 foreach my $media (CGI::param('media')) {
125 my $slot = $a->get_media_slot($media);
126 print $a->{error} unless $a->send_to_io($slot);
129 $a->display_content();
131 } elsif ($action eq 'eject_media') {
132 $bweb->eject_media();
134 } elsif ($action eq 'clear_io') {
135 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
138 $a->display_content();
140 } elsif ($action eq 'ach_view') {
141 # TODO : get autochanger name and create it
143 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
145 $a->display_content();
147 } elsif ($action eq 'ach_load') {
148 my $arg = $bweb->get_form('ach', 'drive', 'slot');
150 if (defined $arg->{ach} and defined $arg->{drive} and defined $arg->{slot})
152 my $b = new Bconsole(pref => $conf, log_stdout => 1) ;
153 # TODO : use template here
155 $b->send_cmd_with_drive("mount slot=$arg->{slot} storage='$arg->{ach}'",
159 $bweb->error("Can't get drive, slot or ach");
162 } elsif ($action eq 'ach_unload') {
163 my $arg = $bweb->get_form('drive', 'slot', 'ach');
164 if (defined $arg->{ach} and defined $arg->{drive} and defined $arg->{slot})
166 my $b = new Bconsole(pref => $conf, log_stdout => 1) ;
167 # TODO : use template here
169 $b->send_cmd_with_drive("umount storage='$arg->{ach}'",
174 $bweb->error("Can't get drive, slot or ach");
176 } elsif ($action eq 'intern_media') {
177 $bweb->help_intern();
179 } elsif ($action eq 'compute_intern_media') {
180 $bweb->help_intern_compute();
182 } elsif ($action eq 'extern_media') {
183 $bweb->help_extern();
185 } elsif ($action eq 'compute_extern_media') {
186 $bweb->help_extern_compute();
188 } elsif ($action eq 'extern') {
189 print "TODO : Eject ", join(",", CGI::param('media'));
192 } elsif ($action eq 'change_location') {
193 $bweb->change_location();
195 } elsif ($action eq 'location') {
196 $bweb->display_location();
198 } elsif ($action eq 'about') {
199 $bweb->display($bweb, 'about.tpl');
201 } elsif ($action eq 'intern') {
202 $bweb->move_media(); # TODO : remove that
204 } elsif ($action eq 'move_media') {
207 } elsif ($action eq 'save_location') {
208 $bweb->save_location();
210 } elsif ($action eq 'update_location') {
211 $bweb->update_location();
213 } elsif ($action eq 'update_media') {
214 $bweb->update_media();
216 } elsif ($action eq 'do_update_media') {
217 $bweb->do_update_media();
219 } elsif ($action eq 'update_slots') {
220 $bweb->update_slots();
222 } elsif ($action eq 'graph') {
223 $bweb->display_graph();
225 } elsif ($action eq 'next_job') {
226 $bweb->director_show_sched();
228 } elsif ($action eq 'enable_job') {
229 $bweb->enable_disable_job(1);
231 } elsif ($action eq 'disable_job') {
232 $bweb->enable_disable_job(0);
234 } elsif ($action eq 'job') {
236 print "<table border='0'><td valign='top'>\n";
237 my $fields = $bweb->get_form(qw/status level db_clients db_filesets
238 limit age offset qclients qfilesets
240 $bweb->display($fields, "display_form_job.tpl");
242 print "</td><td valign='top'>";
243 $bweb->display_job(age => $arg->{age}, # last 7 days
244 offset => $arg->{offset},
245 limit => $arg->{limit});
246 print "</td></table>";
247 } elsif ($action eq 'client_stats') {
249 foreach my $client (CGI::param('client')) {
250 if ($client =~ m/$client_re/) {
251 $bweb->display_client_stats(clientname => $1,
258 } elsif ($action eq 'running') {
259 $bweb->display_running_jobs(1);
261 } elsif ($action eq 'dsp_cur_job') {
262 $bweb->display_running_job();
264 } elsif ($action eq 'update_from_pool') {
265 my $elt = $bweb->get_form(qw/media pool/);
266 unless ($elt->{media} || $elt->{pool}) {
267 $bweb->error("Can't get media or pool param");
269 my $b = new Bconsole(pref => $conf) ;
272 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
273 title => "Update pool",
274 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
278 $bweb->update_media();
280 } elsif ($action eq 'client_status') {
282 foreach my $client (CGI::param('client')) {
283 if ($client =~ m/$client_re/) {
285 $b = new Bconsole(pref => $conf)
289 content => $b->send_cmd("st client=$client"),
290 title => "Client status",
295 $bweb->error("Can't get client selection");
299 } elsif ($action eq 'cancel_job') {
302 } elsif ($action eq 'media_zoom') {
303 $bweb->display_media_zoom();
305 } elsif ($action eq 'job_zoom') {
307 $bweb->display_job_zoom($arg->{jobid});
308 $bweb->get_job_log();
310 } elsif ($action eq 'job_log') {
311 $bweb->get_job_log();
313 } elsif ($action eq 'prune') {
316 } elsif ($action eq 'purge') {
319 } elsif ($action eq 'run_job') {
322 } elsif ($action eq 'run_job_mod') {
323 $bweb->run_job_mod();
325 } elsif ($action eq 'run_job_now') {
326 $bweb->run_job_now();
328 } elsif ($action eq 'label_barcodes') {
329 $bweb->label_barcodes();
331 } elsif ($action eq 'delete') {
335 $bweb->error("Sorry, this action don't exist");
338 $bweb->display_end();
345 o Affichage des job en cours, termines
346 o Affichage du detail d'un job (status client)
347 o Acces aux log d'une sauvegarde
351 o Affichage des medias (pool, cf bacweb)
352 o Affichage de la liste des cartouches
353 o Affichage d'un autochangeur
354 o Mise a jour des slots
356 o Affichage des medias qui ont besoin d'etre change
358 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
359 o Affichage des stats sur un type de job
360 o Affichage des infos de query.sql
362 - Affichage des du TapeAlert sur le site
363 - Recuperation des erreurs SCSI de /var/log/kern.log
368 - Configuration des autochanger a la main dans un hash dumper
373 drive_name => ['SDLT-1', 'STLD-2'],
376 device => '/dev/changer',