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 ($action eq 'begin') { # main display
62 print "<table border='0'><td valign='top' width='100%'>\n";
63 $bweb->display_general(age => $arg->{age});
64 $bweb->display_running_jobs(0);
65 print "</td><td valign='top'>";
67 <div class='titlediv'>
68 <h1 class='newstitle'> Statistics (last 48 hours)</h1>
71 <a href='?action=job;age=172800;jobtype=B'>
72 <img src='bgraph.pl?age=172800;width=450;height=250;graph=job_size;limit=100;action=graph;legend=off' alt='Nothing to display'>
75 print "</td></table>";
76 $bweb->display_job(limit => 10);
78 } elsif ($action eq 'view_conf') {
81 } elsif ($action eq 'edit_conf') {
84 } elsif ($action eq 'apply_conf') {
87 } elsif ($action eq 'client') {
88 $bweb->display_clients();
90 } elsif ($action eq 'pool') {
91 $bweb->display_pool();
93 } elsif ($action eq 'location_edit') {
94 $bweb->location_edit();
96 } elsif ($action eq 'location_save') {
97 $bweb->location_save();
99 } elsif ($action eq 'location_add') {
100 $bweb->location_add();
102 #} elsif ($action eq 'del_location') {
103 # $bweb->del_location();
105 } elsif ($action eq 'media') {
106 $bweb->display_media();
108 } elsif ($action eq 'medias') {
109 $bweb->display_medias();
111 } elsif ($action eq 'eject') {
112 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
115 foreach my $slot (CGI::param('slot')) {
116 print $a->{error} unless $a->send_to_io($slot);
119 foreach my $media (CGI::param('media')) {
120 my $slot = $a->get_media_slot($media);
121 print $a->{error} unless $a->send_to_io($slot);
124 $a->display_content();
126 } elsif ($action eq 'eject_media') {
127 $bweb->eject_media();
129 } elsif ($action eq 'clear_io') {
130 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
133 $a->display_content();
135 } elsif ($action eq 'ach_view') {
136 # TODO : get autochanger name and create it
138 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
140 $a->display_content();
142 } elsif ($action eq 'ach_load') {
143 my $arg = $bweb->get_form('drive', 'slot');
144 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
146 $a->load($arg->{drive}, $arg->{slot}) ;
148 } elsif ($action eq 'ach_unload') {
149 my $arg = $bweb->get_form('drive', 'slot');
150 my $a = Bweb::Autochanger::get('S1_L80', $bweb);
152 $a->unload($arg->{drive}, $arg->{slot}) ;
154 } elsif ($action eq 'intern_media') {
155 $bweb->help_intern();
157 } elsif ($action eq 'compute_intern_media') {
158 $bweb->help_intern_compute();
160 } elsif ($action eq 'extern_media') {
161 $bweb->help_extern();
163 } elsif ($action eq 'compute_extern_media') {
164 $bweb->help_extern_compute();
166 } elsif ($action eq 'extern') {
167 print "TODO : Eject ", join(",", CGI::param('media'));
170 } elsif ($action eq 'change_location') {
171 $bweb->change_location();
173 } elsif ($action eq 'location') {
174 $bweb->display_location();
176 } elsif ($action eq 'about') {
177 $bweb->display($bweb, 'about.tpl');
179 } elsif ($action eq 'intern') {
180 $bweb->move_media(); # TODO : remove that
182 } elsif ($action eq 'move_media') {
185 } elsif ($action eq 'save_location') {
186 $bweb->save_location();
188 } elsif ($action eq 'update_location') {
189 $bweb->update_location();
191 } elsif ($action eq 'update_media') {
192 $bweb->update_media();
194 } elsif ($action eq 'do_update_media') {
195 $bweb->do_update_media();
197 } elsif ($action eq 'update_slots') {
198 $bweb->update_slots();
200 } elsif ($action eq 'graph') {
201 $bweb->display_graph();
203 } elsif ($action eq 'next_job') {
204 $bweb->director_show_sched();
206 } elsif ($action eq 'enable_job') {
207 $bweb->enable_disable_job(1);
209 } elsif ($action eq 'disable_job') {
210 $bweb->enable_disable_job(0);
212 } elsif ($action eq 'job') {
214 print "<table border='0'><td valign='top'>\n";
215 my $fields = $bweb->get_form(qw/status level db_clients db_filesets
216 limit age offset qclients qfilesets
218 $bweb->display($fields, "display_form_job.tpl");
220 print "</td><td valign='top'>";
221 $bweb->display_job(age => $arg->{age}, # last 7 days
222 offset => $arg->{offset},
223 limit => $arg->{limit});
224 print "</td></table>";
225 } elsif ($action eq 'client_stats') {
227 foreach my $client (CGI::param('client')) {
228 if ($client =~ m/$client_re/) {
229 $bweb->display_client_stats(clientname => $1,
236 } elsif ($action eq 'running') {
237 $bweb->display_running_jobs(1);
239 } elsif ($action eq 'dsp_cur_job') {
240 $bweb->display_running_job();
242 } elsif ($action eq 'update_from_pool') {
243 my $elt = $bweb->get_form(qw/media pool/);
244 unless ($elt->{media} || $elt->{pool}) {
245 $bweb->error("Can't get media or pool param");
247 my $b = new Bconsole(pref => $conf) ;
250 content => $b->send_cmd("update volume=$elt->{media} fromPool=$elt->{pool}"),
251 title => "Update pool",
252 name => "update volume=$elt->{media} fromPool=$elt->{pool}",
256 $bweb->update_media();
258 } elsif ($action eq 'client_status') {
260 foreach my $client (CGI::param('client')) {
261 if ($client =~ m/$client_re/) {
263 $b = new Bconsole(pref => $conf)
267 content => $b->send_cmd("st client=$client"),
268 title => "Client status",
273 $bweb->error("Can't get client selection");
277 } elsif ($action eq 'cancel_job') {
280 } elsif ($action eq 'media_zoom') {
281 $bweb->display_media_zoom();
283 } elsif ($action eq 'job_zoom') {
285 $bweb->display_job_zoom($arg->{jobid});
286 $bweb->get_job_log();
288 } elsif ($action eq 'job_log') {
289 $bweb->get_job_log();
291 } elsif ($action eq 'prune') {
294 } elsif ($action eq 'purge') {
297 } elsif ($action eq 'run_job') {
300 } elsif ($action eq 'run_job_mod') {
301 $bweb->run_job_mod();
303 } elsif ($action eq 'run_job_now') {
304 $bweb->run_job_now();
306 } elsif ($action eq 'label_barcodes') {
307 $bweb->label_barcodes();
309 } elsif ($action eq 'delete') {
313 $bweb->error("Sorry, this action don't exist");
316 $bweb->display_end();
323 o Affichage des job en cours, termines
324 o Affichage du detail d'un job (status client)
325 o Acces aux log d'une sauvegarde
329 o Affichage des medias (pool, cf bacweb)
330 o Affichage de la liste des cartouches
331 o Affichage d'un autochangeur
332 o Mise a jour des slots
334 o Affichage des medias qui ont besoin d'etre change
336 o Affichage des stats sur les dernieres sauvegardes (cf bacula-web)
337 o Affichage des stats sur un type de job
338 o Affichage des infos de query.sql
340 - Affichage des du TapeAlert sur le site
341 - Recuperation des erreurs SCSI de /var/log/kern.log
346 - Configuration des autochanger a la main dans un hash dumper
351 drive_name => ['SDLT-1', 'STLD-2'],
354 device => '/dev/changer',