5 eval '(exit $?0)' && eval 'exec @PERL@ -S $0 ${1+"$@"}'
6 & eval 'exec @PERL@ -S $0 $argv:q'
9 require "newgetopt.pl";
12 $confdir="@CONFIG_DIR@";
14 $prefix=$prefix; # avoid warnings about possible typo
15 $exec_prefix="@exec_prefix@";
16 $exec_prefix=$exec_prefix; # ditto
19 $USE_VERSION_SUFFIXES='@USE_VERSION_SUFFIXES@';
21 if ( $USE_VERSION_SUFFIXES =~ /^yes$/i ) {
25 $result = &NGetOpt ( "summary",
28 "waitdumping|wdumping",
35 "gestimate|gettingestimate",
44 if( defined $opt_config ) {
56 if ( ! -d "$confdir/$conf" ) {
57 die "amstatus$suf: could not find directory $confdir/$conf";
62 chdir "$confdir/$conf";
64 $logdir=`$sbindir/amgetconf$suf logdir`;
67 $errfile="$logdir/amdump";
69 $nb_options = defined( $opt_summary ) +
70 defined( $opt_stats ) +
71 defined( $opt_dumping ) +
72 defined( $opt_waitdumping ) +
73 defined( $opt_waittaper ) +
74 defined( $opt_dumpingtape ) +
75 defined( $opt_writingtape ) +
76 defined( $opt_finished ) +
77 defined( $opt_estimate ) +
78 defined( $opt_gestimate ) +
79 defined( $opt_failed );
81 if($nb_options == 0 ) {
95 $unit=`$sbindir/amgetconf$suf displayunit`;
102 elsif($unit eq 'M') {
106 elsif($unit eq 'G') {
107 $unitdivisor = 1024*1024;
110 elsif($unit eq 'T') {
111 $unitdivisor = 1024*1024*1024;
116 if( defined $opt_file) {
117 if( $opt_file =~ m,^/, ) {
118 $errfile = $opt_file;
120 $errfile = "$pwd/$opt_file";
121 $errfile = "$logdir/$opt_file" if ( ! (-f $errfile ));
125 $errfile="$logdir/amflush" if(! (-f $errfile));
127 if (-f "$logdir/amflush.1" && -f "$logdir/amdump.1" &&
128 -M "$logdir/amflush.1" < -M "$logdir/amdump.1") {
129 $errfile="$logdir/amflush.1";
131 $errfile="$logdir/amdump.1";
136 open(AMDUMP,"<$errfile") || die("$errfile: $!");
137 print "Using $errfile";
139 $start_degraded_mode = 0;
141 $label = ""; # -w fodder
142 $origsize = 0; # -w fodder
149 @dumpers_active = ();
151 $ntpartition{$nb_tape} = 0;
152 $ntsize{$nb_tape} = 0;
153 $ntesize{$nb_tape} = 0;
158 if(/(amdump|amflush): start at (.*)/) {
160 $starttime=&unctime(split(/[ ]+/,$2));
162 elsif(/amdump: datestamp (\S+)/) {
164 if(!defined $datestamp{$gdatestamp}) {
165 $datestamp{$gdatestamp} = 1;
166 push @datestamp, $gdatestamp;
169 elsif(/setup_estimate: (\S+):(\S+): command .*, options: *(\S+) *last_level -?\d+ next_level0 -?\d+ level_days \d+ *getting estimates (-?\d) \(-2\) (-?\d) \(-2\) (-?\d) \(-2\)/) {
172 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
173 $estimate{$hostpart}=0;
176 $dump_started{$hostpart}=0;
177 $dump_finished{$hostpart}=0;
178 $taper_started{$hostpart}=0;
179 $taper_finished{$hostpart}=0;
180 $partialestimate{$hostpart}=0;
181 $error{$hostpart}="";
182 if($4 != -1) { $getest{$hostpart} .= ":$4:" };
183 if($5 != -1) { $getest{$hostpart} .= ":$5:" };
184 if($6 != -1) { $getest{$hostpart} .= ":$6:" };
186 elsif(/setup_estimate: (\S+):(\S+): command .*, options:/) {
189 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
190 $estimate{$hostpart}=0;
193 $dump_started{$hostpart}=0;
194 $dump_finished{$hostpart}=0;
195 $taper_started{$hostpart}=0;
196 $taper_finished{$hostpart}=0;
197 $partialestimate{$hostpart}=0;
198 $error{$hostpart}="";
200 while (! /getting estimates/) { $_ = <AMDUMP>; }
202 if(/getting estimates (-?\d) \(-2\) (-?\d) \(-2\) (-?\d) \(-2\)/) {
203 if($1 != -1) { $getest{$hostpart} .= ":$1:" };
204 if($2 != -1) { $getest{$hostpart} .= ":$2:" };
205 if($3 != -1) { $getest{$hostpart} .= ":$3:" };
211 elsif(/got result for host (\S+) disk (\S+): (\d+) -> (\d+)K,/) {
214 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
215 $estimate{$hostpart}=1;
216 $level{$hostpart}=$3;
217 $esize{$hostpart}=$4 / $unitdivisor;
218 $partialestimate{$hostpart}=0;
219 $getest{$hostpart} = "";
221 elsif(/got partial result for host (\S+) disk (\S+): (-?\d+) -> (-?\d+)K, (-?\d+) -> (-?\d+)K, (-?\d+) -> (-?\d+)K/) {
224 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
225 if($4 > 0 || $6 > 0 || $8 > 0) {
226 $estimate{$hostpart}=1;
227 $level{$hostpart}=$3;
228 $esize{$hostpart}=$4 / $unitdivisor;
229 $partialestimate{$hostpart}=1;
230 if($4 > 0) { $getest{$hostpart} =~ s/:$3://; }
231 if($6 > 0) { $getest{$hostpart} =~ s/:$5://; }
232 if($8 > 0) { $getest{$hostpart} =~ s/:$7://; }
234 if($getest{$hostpart} eq "") { $partialestimate{$hostpart}=0; }
237 elsif(/getting estimates took/) {
243 elsif(/GENERATING SCHEDULE:/) {
244 $generating_schedule=1;
246 elsif(/^(\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+/) {
247 if($generating_schedule == 1 ) {
250 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
251 $level{"$hostpart"}=$4;
253 $esize=32 if $esize<32;
254 $esize{$hostpart}=$esize / $unitdivisor;
255 $degr_level{$hostpart}=-1;
258 elsif(/^DUMP (\S+) (\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+/) {
259 if($generating_schedule == 1 ) {
263 $hostpart=&make_hostpart($host,$partition,$datestamp);
264 $level{"$hostpart"}=$5;
266 $esize=32 if $esize<32;
267 $esize{$hostpart}=$esize / $unitdivisor;
268 $degr_level{$hostpart}=-1;
271 elsif(/^DUMP (\S+) (\S+) (\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+/) {
272 if($generating_schedule == 1 ) {
278 $hostpart=&make_hostpart($host,$partition,$datestamp);
279 $level{"$hostpart"}=$6;
281 $esize=32 if $esize<32;
282 $esize{$hostpart}=$esize / $unitdivisor;
283 $degr_level{$hostpart}=-1;
286 elsif(/^(\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+ (\d+) \d+:\d+:\d+:\d+:\d+:\d+ ([-]*\d+) \d+/) {
287 if($generating_schedule == 1 ) {
290 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
291 $level{$hostpart}=$4;
293 $esize=32 if $esize<32;
294 $esize{$hostpart}=$esize / $unitdivisor;
295 $degr_level{$hostpart}=$6;
296 $degr_size{$hostpart}=$7 / $unitdivisor;
297 $degr_size{$hostpart}=32 if ($7 < 32);
300 elsif(/^DUMP (\S+) (\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+ (\d+) \d+:\d+:\d+:\d+:\d+:\d+ ([-]*\d+) \d+/) {
301 if($generating_schedule == 1 ) {
305 $hostpart=&make_hostpart($host,$partition,$datestamp);
306 $level{$hostpart}=$5;
308 $esize=32 if $esize<32;
309 $esize{$hostpart}=$esize / $unitdivisor;
310 $degr_level{$hostpart}=$7;
311 $degr_size{$hostpart}=$8 / $unitdivisor;
312 $degr_size{$hostpart}=32 if ($8 < 32);
315 elsif(/^FLUSH (\S+) (\S+) (\S+) (\d+) (\S+)/) {
321 $hostpart=&make_hostpart($host,$partition,$datestamp);
323 $holding_file{$hostpart}=$holding_file;
324 $level{$hostpart}=$level;
326 elsif(/^driver: start time (\S+)/) {
329 $dumpers_active[0]=0;
333 elsif(/^driver: tape size (\d+)/) {
334 $tape_size = $1 / $unitdivisor;
336 elsif(/^driver: adding holding disk \d+ dir \S+ size (\d+)/) {
337 $holding_space += $1;
339 elsif(/driver: send-cmd time (\S+) to (dumper\d*): (FILE-DUMP|PORT-DUMP) (\d+-\d+) (\S+) (\S+) (\S+) (\d+)/) {
343 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
345 $serial{$serial}=$hostpart;
346 $dump_started{$hostpart}=1;
347 $dump_time{$hostpart}=$1;
348 $dump_finished{$hostpart}=0;
349 $holding_file{$hostpart}=$5;
350 if( $level{$hostpart} != $8 &&
351 $degr_level{$hostpart} == $8) {
352 $level{$hostpart}=$degr_level{$hostpart};
353 $esize{$hostpart}=$degr_size{$hostpart};
355 if(! defined($busy_time{$2})) {
358 $running_dumper{$2} = $hostpart;
359 $error{$hostpart}="";
361 if(! defined($dumpers_active[$dumpers_active])) {
362 $dumpers_active[$dumpers_active]=0;
364 if(! defined($dumpers_held[$dumpers_active])) {
365 $dumpers_held[$dumpers_active]={};
368 elsif(/driver: send-cmd time (\S+) to (dumper\d*): (FILE-DUMP|PORT-DUMP) (\d+-\d+) (\S+) (\S+) (\S+) (\S+) (\d+)/) {
374 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
376 $serial{$serial}=$hostpart;
377 $dump_started{$hostpart}=1;
378 $dump_time{$hostpart}=$1;
379 $dump_finished{$hostpart}=0;
380 $holding_file{$hostpart}=$5 if $3 eq "FILE-DUMP";
381 if( $level{$hostpart} != $9 &&
382 $degr_level{$hostpart} == $9) {
383 $level{$hostpart}=$degr_level{$hostpart};
384 $esize{$hostpart}=$degr_size{$hostpart};
386 if(! defined($busy_time{$2})) {
389 $running_dumper{$2} = $hostpart;
390 $error{$hostpart}="";
392 if(! defined($dumpers_active[$dumpers_active])) {
393 $dumpers_active[$dumpers_active]=0;
395 if(! defined($dumpers_held[$dumpers_active])) {
396 $dumpers_held[$dumpers_active]={};
399 elsif(/driver: send-cmd time (\S+) to (dumper\d*): (FILE-DUMP|PORT-DUMP) (\d+-\d+) (\S+) (\S+) (\S+) (\S+) (\S+) (\d+)/) {
407 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
409 $serial{$serial}=$hostpart;
410 $dump_started{$hostpart}=1;
411 $dump_time{$hostpart}=$1;
412 $dump_finished{$hostpart}=0;
413 $holding_file{$hostpart}=$5 if $3 eq "FILE-DUMP";
414 if( $level{$hostpart} != $10 &&
415 $degr_level{$hostpart} == $10) {
416 $level{$hostpart}=$degr_level{$hostpart};
417 $esize{$hostpart}=$degr_size{$hostpart};
419 if(! defined($busy_time{$2})) {
422 $running_dumper{$2} = $hostpart;
423 $error{$hostpart}="";
425 if(! defined($dumpers_active[$dumpers_active])) {
426 $dumpers_active[$dumpers_active]=0;
428 if(! defined($dumpers_held[$dumpers_active])) {
429 $dumpers_held[$dumpers_active]={};
432 elsif(/driver: send-cmd time (\S+) to (dumper\d*): CONTINUE (\d+-\d+) (\S+) (\d+) (\d+)/) {
435 $hostpart=$serial{$serial};
436 if($hostpart ne "") {
437 $dump_roomq{$hostpart}=undef;
438 $error{$hostpart}="";
441 elsif(/driver: result time (\S+) from (dumper\d+): FAILED (\d+-\d+) (.*)/) {
445 $hostpart=$serial{$serial};
446 $dump_finished{$hostpart}=-1;
447 $busy_time{$2}+=($1-$dump_time{$hostpart});
448 $running_dumper{$2} = "0";
449 $dump_time{$hostpart}=$1;
450 $error{$hostpart}="driver: $error";
453 elsif(/driver: result time (\S+) from (dumper\d+): TRY-AGAIN (\d+-\d+) (.*)/) {
457 $hostpart=$serial{$serial};
458 $dump_started{$hostpart}=0;
459 $dump_finished{$hostpart}=0;
460 $busy_time{$2}+=($1-$dump_time{$hostpart});
461 $running_dumper{$2} = "0";
462 $dump_time{$hostpart}=$1;
463 $error{$hostpart}="driver: (aborted:$error)";
466 elsif(/driver: result time (\S+) from (dumper\d+): DONE (\d+-\d+) (\d+) (\d+) (\d+) \[.*\]/) {
469 $origsize=$4 / $unitdivisor;
470 $outputsize=$5 / $unitdivisor;
471 $hostpart=$serial{$serial};
472 $size{$hostpart}=$outputsize;
473 $dump_finished{$hostpart}=1;
474 $busy_time{$2}+=($1-$dump_time{$hostpart});
475 $running_dumper{$2} = "0";
476 $dump_time{$hostpart}=$1;
477 $error{$hostpart}="";
480 elsif(/driver: result time (\S+) from (dumper\d+): ABORT-FINISHED (\d+-\d+)/) {
483 $hostpart=$serial{$serial};
484 $dump_started{$hostpart}=0;
485 $dump_finished{$hostpart}=0;
486 $busy_time{$2}+=($1-$dump_time{$hostpart});
487 $running_dumper{$2} = "0";
488 $dump_time{$hostpart}=$1;
489 $error{$hostpart}="driver: (aborted)";
492 elsif(/driver: result time (\S+) from (dumper\d+): RQ-MORE-DISK (\d+-\d+)/) {
495 $hostpart=$serial{$serial};
496 $dump_roomq{$hostpart}=1;
497 $error{$hostpart}="(waiting for holding disk space)";
499 elsif(/driver: finished-cmd time (\S+) dumper\d+ dumped (\S+):(\S+)/){
502 elsif(/driver: send-cmd time (\S+) to taper: START-TAPER (\S+)/) {
503 if(!defined $gdatestamp) {
505 if(!defined $datestamp{$gdatestamp}) {
506 $datestamp{$gdatestamp} = 1;
507 push @datestamp, $gdatestamp;
511 elsif(/driver: send-cmd time (\S+) to taper: FILE-WRITE (\d+-\d+) (\S+) (\S+) (\S+) (\d*) (\S+)/){
518 if(!defined $datestamp{$ldatestamp}) {
519 $datestamp{$ldatestamp} = 1;
520 push @datestamp, $ldatestamp;
522 $hostpart=&make_hostpart($host,$partition,$ldatestamp);
523 $serial{$serial}=$hostpart;
524 if(!defined $level{$hostpart}) {
525 $level{$hostpart} = $level;
527 $serial{$serial}=$hostpart;
528 $taper_started{$hostpart}=1;
529 $taper_finished{$hostpart}=0;
530 $taper_time{$hostpart}=$1;
532 #features (maybe missing features)
533 elsif(/driver: send-cmd time (\S+) to taper: FILE-WRITE (\d+-\d+) (\S+) (\S+) (\S*) (\S+) (\d*) (\S+)/){
542 if(!defined $datestamp{$ldatestamp}) {
543 $datestamp{$ldatestamp} = 1;
544 push @datestamp, $ldatestamp;
546 $hostpart=&make_hostpart($host,$partition,$ldatestamp);
547 $serial{$serial}=$hostpart;
548 if(!defined $level{$hostpart}) {
549 $level{$hostpart} = $level;
551 $serial{$serial}=$hostpart;
552 $taper_started{$hostpart}=1;
553 $taper_finished{$hostpart}=0;
554 $taper_time{$hostpart}=$1;
556 elsif(/driver: send-cmd time (\S+) to taper: PORT-WRITE (\d+-\d+) (\S+) (\S+) \d+( \d+|)/){
561 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
562 $serial{$serial}=$hostpart;
563 $taper_started{$hostpart}=1;
564 $taper_finished{$hostpart}=0;
565 $taper_time{$hostpart}=$1;
567 elsif(/driver: send-cmd time (\S+) to taper: PORT-WRITE (\d+-\d+) (\S+) (\S+) (\S+) \d+ \d+/){
573 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
574 $serial{$serial}=$hostpart;
575 $taper_started{$hostpart}=1;
576 $taper_finished{$hostpart}=0;
577 $taper_time{$hostpart}=$1;
579 elsif(/driver: result time (\S+) from taper: DONE (\d+-\d+) (\S+) (\d+) \[sec (\S+) kb (\d+) kps/) {
583 $size=$6 / $unitdivisor;
584 $hostpart=$serial{$serial};
585 $taper_finished{$hostpart}=1;
586 $busy_time{"taper"}+=($1-$taper_time{$hostpart});
587 $taper_time{$hostpart}=$1;
588 if(!defined $size{$hostpart}) {
589 $size{$hostpart}=$size;
591 $ntpartition{$nb_tape}++;
592 $ntsize{$nb_tape} += $size{$hostpart};
593 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
594 $ntesize{$nb_tape} += $esize{$hostpart};
597 $ntesize{$nb_tape} += $size{$hostpart};
600 elsif(/driver: result time (\S+) from taper: (TRY-AGAIN|TAPE-ERROR) (\d+-\d+) (.+)/) {
604 $hostpart=$serial{$serial};
605 $taper_finished{$hostpart}= $2 eq 'TAPE-ERROR' ? -2 : -1;
606 $busy_time{"taper"}+=($1-$taper_time{$hostpart});
607 $taper_time{$hostpart}=$1;
608 $error{$hostpart}="driver: $error";
610 elsif(/driver: dump failed (\S+) (\S+) (\S+), too many dumper retry/) {
612 $hostpart=$serial{$serial};
613 $dump_started{$hostpart}=-1;
614 $dump_finished{$hostpart}=-2;
615 $error{$hostpart} .= "(too many dumper retry)";
617 elsif(/driver: tape failed (\S+) (\S+) (\S+), too many taper retry/) {
619 $hostpart=$serial{$serial};
620 $taper_started{$hostpart}=-1;
621 $taper_finished{$hostpart}=-2;
622 $error{$hostpart} .= "(too many taper retry)";
624 elsif(/planner: FAILED (\S+) (\S+) (\S+) (-?\d+) (.*)/) {
628 $hostpart=&make_hostpart($host,$partition,$datestamp);
629 $dump_started{$hostpart}=-1;
630 $level{$hostpart}=$4;
631 $error{$hostpart}="planner: $5";
633 elsif(/dump of driver schedule after start degraded mode:/) {
634 $start_degraded_mode=1;
636 elsif(/driver: state time (\S+) free (.*) taper: (\S+) idle-dumpers: (\d+) qlen (.*) driver-idle: (\S+)/) {
641 %free = split (/ +/, $2);
642 %qlen = split (/ +/, $5);
644 if($status_driver ne "") {
645 $dumpers_active[$dumpers_active_prev]
646 +=$current_time-$state_time_prev;
647 $dumpers_held[$dumpers_active_prev]{$status_driver}
648 +=$current_time-$state_time_prev;
650 $state_time_prev=$current_time;
651 $dumpers_active_prev=$dumpers_active;
653 if(! defined($dumpers_held[$dumpers_active]{$status_driver})) {
654 $dumpers_held[$dumpers_active]{$status_driver}=0;
657 elsif(/taper: wrote label `(\S*)'/) {
659 $ntlabel{$nb_tape} = $1;
660 $ntpartition{$nb_tape} = 0;
661 $ntsize{$nb_tape} = 0;
662 $ntesize{$nb_tape} = 0;
665 #print "Ignoring: $_\n";
671 if(defined $current_time) {
672 for ($d = 0; $d < $#dumpers_active; $d++) {
673 $the_dumper = "dumper$d";
674 if(defined($running_dumper{$the_dumper}) &&
675 $running_dumper{$the_dumper} ne "0") {
676 $busy_time{$the_dumper}+=($current_time-$dump_time{$running_dumper{$the_dumper}});
720 foreach $host (sort @hosts) {
721 foreach $partition (sort @$host) {
722 foreach $datestamp (sort @datestamp) {
723 $hostpart=&make_hostpart($host,$partition,$datestamp);
724 next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
725 if(length("$host:$partition") > $maxnamelength) {
726 $maxnamelength = length("$host:$partition");
732 foreach $host (sort @hosts) {
733 foreach $partition (sort @$host) {
734 foreach $datestamp (sort @datestamp) {
735 $hostpart=&make_hostpart($host,$partition,$datestamp);
736 next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
738 if( !defined $size{$hostpart} && defined $holding_file{$hostpart}) {
739 $size{$hostpart} = &dump_size($holding_file{$hostpart}) / (1024 * $unitdivisor);
742 if($estimate_done != 1 && !defined $flush{$hostpart}) {
743 if(defined $estimate{$hostpart}) {
744 if($estimate{$hostpart} != 1) {
745 if( defined $opt_gestimate) {
746 printf "%8s ", $datestamp if defined $opt_date;
747 printf "%-${maxnamelength}s", "$host:$partition";
748 print " getting estimate\n";
752 if(defined $opt_estimate ||
753 (defined $opt_gestimate && $partialestimate{$hostpart} == 1)) {
754 printf "%8s ", $datestamp if defined $opt_date;
755 printf "%-${maxnamelength}s", "$host:$partition";
756 printf "%2d", $level{$hostpart};
757 printf "%9d$unit", $esize{$hostpart};
758 if($partialestimate{$hostpart} == 1) {
761 print " estimate done\n";
764 $estsize += $esize{$hostpart};
769 if(defined $estimate{$hostpart}) {
770 if($estimate{$hostpart} == 1) {
772 $estsize += $esize{$hostpart};
774 elsif (!defined $dump_started{$hostpart} || $dump_started{$hostpart} == 0) {
775 if( defined $opt_failed) {
776 printf "%8s ", $datestamp if defined $opt_date;
777 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
778 printf " no estimate\n";
785 $flsize += $size{$hostpart};
788 if(defined $taper_started{$hostpart} &&
789 $taper_started{$hostpart}==1) {
790 if(defined $dump_started{$hostpart}) {
792 if(defined($size{$hostpart})) {
793 $dsize += $size{$hostpart};
796 $dsize += $esize{$hostpart};
798 $desize += $esize{$hostpart};
800 if(defined $dump_started{$hostpart} &&
801 $dump_started{$hostpart} == 1 &&
802 $dump_finished{$hostpart} == 0 &&
803 $taper_started{$hostpart} == 1) {
804 if( defined $opt_dumpingtape ) {
805 printf "%8s ", $datestamp if defined $opt_date;
806 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
807 printf "%9d$unit", $esize{$hostpart};
808 print " dumping to tape";
809 if( defined $starttime ) {
810 print " (", &showtime($taper_time{$hostpart}), ")";
815 $dtesize += $esize{$hostpart};
817 elsif($taper_finished{$hostpart} == 0) {
818 if( defined $opt_writingtape ) {
819 printf "%8s ", $datestamp if defined $opt_date;
820 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
821 printf "%9d$unit", $size{$hostpart};
823 print " writing to tape";
826 print " flushing to tape";
828 if( defined $starttime ) {
829 print " (", &showtime($taper_time{$hostpart}), ")";
834 $tasize += $size{$hostpart};
835 if(defined $esize{$hostpart}) {
836 $taesize += $esize{$hostpart};
839 $taesize += $size{$hostpart};
842 elsif($taper_finished{$hostpart} < 0) {
844 if(defined $size{$hostpart}) {
845 $xsize = $size{$hostpart};
847 elsif(defined $esize{$hostpart}) {
848 $xsize = $esize{$hostpart};
854 if(defined $esize{$hostpart}) {
855 $exsize += $esize{$hostpart};
861 if( defined $opt_failed ||
862 (defined $opt_waittaper && ($taper_finished{$hostpart} == -1))) {
863 printf "%8s ", $datestamp if defined $opt_date;
864 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
865 printf "%9d$unit", $xsize;
867 print " failed to tape";
870 print " failed to flush";
872 print " (will retry)" unless $taper_finished{$hostpart} < -1;
873 if( defined $starttime ) {
874 print " (", &showtime($taper_time{$hostpart}), ")";
893 elsif($taper_finished{$hostpart} == 1) {
894 if( defined $opt_finished ) {
895 printf "%8s ", $datestamp if defined $opt_date;
896 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
897 printf "%9d$unit", $size{$hostpart};
904 if( defined $starttime ) {
905 print " (", &showtime($taper_time{$hostpart}), ")";
910 $tsize += $size{$hostpart};
911 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
912 $tesize += $esize{$hostpart};
915 $tesize += $size{$hostpart};
919 printf "%8s ", $datestamp if defined $opt_date;
920 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
921 print " unknown state TAPER\n";
924 elsif(defined $dump_started{$hostpart}) {
925 if($dump_started{$hostpart} == -1) {
926 if( defined $opt_failed ) {
927 printf "%8s ", $datestamp if defined $opt_date;
928 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
929 printf " " . $error{$hostpart} . "\n";
932 $fsize+=$esize{$hostpart};
934 elsif($dump_started{$hostpart} == 0) {
935 if($estimate{$hostpart} == 1) {
936 if( defined $opt_waitdumping ) {
937 printf "%8s ", $datestamp if defined $opt_date;
938 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
939 printf "%9d$unit", $esize{$hostpart};
940 print " wait for dumping $error{$hostpart}\n";
943 $wsize += $esize{$hostpart};
946 elsif($dump_started{$hostpart} == 1 &&
947 $dump_finished{$hostpart} == -1) {
948 if( defined $opt_failed ) {
949 printf "%8s ", $datestamp if defined $opt_date;
950 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
951 print " ", $error{$hostpart};
952 if( defined $starttime ) {
953 print " (", &showtime($dump_time{$hostpart}), ")";
958 $fsize+=$esize{$hostpart};
960 elsif($dump_started{$hostpart} == 1 &&
961 $dump_finished{$hostpart} != 1) {
962 if( defined $opt_dumping ) {
963 printf "%8s ", $datestamp if defined $opt_date;
964 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
965 printf "%9d$unit", $esize{$hostpart};
966 printf " dumping %8d$unit", $size{$hostpart};
967 if($size{$hostpart} != 0) {
968 printf " (%6.2f%%)", (100.0*$size{$hostpart})/$esize{$hostpart};
970 if( defined $starttime ) {
971 print " (", &showtime($dump_time{$hostpart}), ")";
973 if(defined $dump_roomq{$hostpart}) {
974 print " " . $error{$hostpart};
979 $dusize += $size{$hostpart};
980 $duesize += $esize{$hostpart};
982 elsif($dump_finished{$hostpart} == 1 &&
983 $taper_started{$hostpart} != 1) {
984 if( defined $opt_waittaper ) {
985 printf "%8s ", $datestamp if defined $opt_date;
986 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
987 printf "%9d$unit", $size{$hostpart};
989 if( defined $starttime ) {
990 print " (", &showtime($dump_time{$hostpart}), ")";
992 print ", wait for writing to tape\n";
995 $dsize += $size{$hostpart};
996 $desize += $esize{$hostpart};
998 $twsize += $size{$hostpart};
999 $twesize += $esize{$hostpart};
1002 printf "%8s ", $datestamp if defined $opt_date;
1003 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
1004 print " unknown state DUMPER\n";
1007 elsif(defined $flush{$hostpart}) {
1008 if( defined $opt_waittaper ) {
1009 printf "%8s ", $datestamp if defined $opt_date;
1010 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
1011 printf "%9d$unit", $size{$hostpart};
1012 print " waiting to flush\n";
1015 $wfsize += $size{$hostpart};
1017 elsif(defined $level{$hostpart}) {
1018 printf "%8s ", $datestamp if defined $opt_date;
1019 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
1020 print " unknown state\n";
1027 if (defined $opt_summary) {
1029 print "SUMMARY part real estimated\n";
1030 print " size size\n";
1031 printf "partition : %3d\n", $nb_partition;
1032 printf "estimated : %3d %20d$unit\n", $epartition , $estsize;
1033 printf "flush : %3d %9d$unit\n", $flpartition, $flsize;
1034 printf "failed : %3d %20d$unit (%6.2f%%)\n",
1035 $fpartition , $fsize,
1036 $estsize ? ($fsize * 1.0 / $estsize) * 100 : 0.0;
1037 printf "wait for dumping: %3d %20d$unit (%6.2f%%)\n",
1038 $wpartition , $wsize,
1039 $estsize ? ($wsize * 1.0 / $estsize) * 100 : 0.0;
1040 printf "dumping to tape : %3d %20d$unit (%6.2f%%)\n",
1041 $dtpartition, $dtesize,
1042 $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
1043 printf "dumping : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1044 $dupartition, $dusize, $duesize,
1045 $duesize ? ($dusize * 1.0 / $duesize) * 100 : 0.0,
1046 $estsize ? ($dusize * 1.0 / $estsize) * 100 : 0.0;
1047 printf "dumped : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1048 $dpartition , $dsize , $desize,
1049 $desize ? ($dsize * 1.0 / $desize) * 100 : 0.0,
1050 $estsize ? ($dsize * 1.0 / $estsize) * 100 : 0.0;
1051 printf "wait for writing: %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1052 $twpartition, $twsize, $twesize,
1053 $twesize ? ($twsize * 1.0 / $twesize) * 100 : 0.0,
1054 $estsize ? ($twsize * 1.0 / $estsize) * 100 : 0.0;
1055 printf "wait to flush : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1056 $wfpartition, $wfsize, $wfsize, 100, 0;
1057 printf "writing to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1058 $tapartition, $tasize, $taesize,
1059 $taesize ? ($tasize * 1.0 / $taesize) * 100 : 0.0,
1060 $estsize ? ($tasize * 1.0 / $estsize) * 100 : 0.0;
1061 printf "failed to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1062 $tfpartition, $tfsize, $tfesize,
1063 $tfesize ? ($tfsize * 1.0 / $tfesize) * 100 : 0.0,
1064 $estsize ? ($tfsize * 1.0 / $estsize) * 100 : 0.0;
1065 printf "taped : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
1066 $tpartition , $tsize , $tesize,
1067 $tesize ? ($tsize * 1.0 / $tesize) * 100 : 0.0,
1068 ($estsize+$flsize) ? ($tsize * 1.0 / ($estsize + $flsize)) * 100 : 0.0;
1069 if($nb_tape > 1 || $tape_size != 0) {
1070 for($i=1; $i <= $nb_tape; $i++) {
1071 if($tape_size != 0) {
1072 printf " tape %-3d : %3d %9d$unit %9d$unit (%6.2f%%) %s\n",
1073 $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, 100*$ntsize{$i}/$tape_size, $ntlabel{$i};
1076 printf " tape %-3d : %3d %9d$unit %9d$unit %s\n",
1077 $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, $ntlabel{$i};
1081 if($idle_dumpers ==0) {
1082 printf "all dumpers active\n";
1085 $c1 = ($idle_dumpers == 1) ? "" : "s";
1086 $c2 = ($idle_dumpers < 10) ? " " : "";
1087 $c3 = ($idle_dumpers == 1) ? " " : "";
1088 printf "%d dumper%s idle%s %s: %s\n", $idle_dumpers, $c1, $c2, $c3, $status_driver;
1090 if($status_taper eq "writing" && defined($qlen{"tapeq:"})) {
1091 printf "taper writing, tapeq: %d\n", $qlen{"tapeq:"};
1094 printf "taper idle\n";
1096 if (defined ($free{"kps:"})) {
1097 printf "network free kps: %9d\n", $free{"kps:"};
1099 if (defined ($free{"space:"})) {
1100 if ($holding_space) {
1101 $hs = ($free{"space:"} * 1.0 / $holding_space) * 100;
1105 printf "holding space : %9d$unit (%6.2f%%)\n", ($free{"space:"}/$unitdivisor), $hs;
1109 if(defined $opt_stats) {
1110 if(defined($current_time) && $current_time != $start_time) {
1111 $total_time=$current_time-$start_time;
1112 foreach $key (sort byprocess keys %busy_time) {
1113 printf "%8s busy : %8s (%6.2f%%)\n",
1114 $key, &busytime($busy_time{$key}),
1115 ($busy_time{$key} * 1.0 / $total_time) * 100;
1117 for ($d = 0; $d <= $#dumpers_active; $d++) {
1118 $l = sprintf "%2d dumper%s busy%s : %8s (%6.2f%%)",
1119 $d, ($d == 1) ? "" : "s", ($d == 1) ? " " : "",
1120 &busytime($dumpers_active[$d]),
1121 ($dumpers_active[$d] * 1.0 / $total_time) * 100;
1124 $s2 = " " x length($l);
1125 $r = $dumpers_held[$d];
1126 foreach $key (sort valuesort keys %$r) {
1128 unless $dumpers_held[$d]{$key} >= 1;
1129 printf "%s%20s: %8s (%6.2f%%)\n",
1132 &busytime($dumpers_held[$d]{$key}),
1133 ($dumpers_held[$d]{$key} * 1.0 / $dumpers_active[$d]) * 100;
1143 sub make_hostpart() {
1144 local($host,$partition,$datestamp) = @_;
1146 if(! defined($hosts{$host})) {
1151 foreach $pp (sort @$host) {
1152 $new_part = 0 if ($pp eq $partition);
1154 push @$host, $partition if $new_part==1;
1156 my($hostpart) = "$host$partition$datestamp";
1157 if(!defined $datestamp{$datestamp}) {
1158 $datestamp{$datestamp} = 1;
1159 push @datestamp, $datestamp;
1165 my(@tmp_a) = split(/(\d*)$/, $a, 2);
1166 my(@tmp_b) = split(/(\d*)$/, $b, 2);
1167 return ($tmp_a[0] cmp $tmp_b[0]) || ($tmp_a[1] <=> $tmp_b[1]);
1171 $r->{$b} <=> $r->{$a};
1175 local($filename) = @_;
1178 local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1179 $atime,$mtime,$ctime,$blksize,$blocks);
1180 while ($filename ne "") {
1181 $filename = "$filename.tmp" if (!(-e "$filename"));
1182 $filename = "/dev/null" if (!(-e "$filename"));
1183 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1184 $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
1185 $size=$size-32768 if $size > 32768;
1187 open(DUMP,$filename);
1190 if(/^CONT_FILENAME=(.*)$/) { $filename = $1; last }
1191 last if /^To restore, position tape at start of file and run/;
1206 @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
1207 'Jul','Aug','Sep','Oct','Nov','Dec');
1209 # Preset an array of values in case some parts are not passed as
1210 # arguments. This lets the date, etc, be omitted and default to
1219 # See if this argument looks like a month name.
1225 $month = $month + 1;
1232 # See if this is a day of the month.
1234 if ($a =~ /^\d+$/ && $a >= 1 && $a <= 32) {
1239 # See if the next argument looks like a time.
1241 if ($a =~ /^(\d+):(\d+)/) {
1244 if ($a =~ /^(\d+):(\d+):(\d+)/) {
1250 # See if this is a year.
1252 if ($a =~ /^\d\d\d\d$/ && $a >= 1900) {
1258 $time = &timelocal (@tl);
1265 my($oneday)=24*60*60;
1267 @now=localtime($starttime+$delta);
1268 if($delta > $oneday) {
1269 $result=sprintf("%d+",$delta/$oneday);
1273 $result.=sprintf("%d:%02d:%02d",$now[2],$now[1],$now[0]);
1279 my($oneday)=24*60*60;
1281 if($busy > $oneday) {
1282 $days=int($busy/$oneday);
1283 $result=sprintf("%d+",$busy/$oneday);
1284 $busy-=$days*$oneday;
1288 $hours=int($busy/60/60);
1289 $busy-=$hours*60*60;
1290 $minutes=int($busy/60);
1293 $result.=sprintf("%d:%02d:%02d",$hours,$minutes,$seconds);
1298 print "amstatus [--config] config [--file amdump_file]\n";
1299 print " [--summary] [--dumping] [--waitdumping] [--waittaper]\n";
1300 print " [--dumpingtape] [--writingtape] [--finished] [--failed]\n";
1301 print " [--estimate] [--gestimate] [--stats] [--date]\n";