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 if( defined $opt_file) {
96 if( $opt_file =~ m,^/, ) {
99 $errfile = "$pwd/$opt_file";
100 $errfile = "$logdir/$opt_file" if ( ! (-f $errfile ));
104 $errfile="$logdir/amflush" if(! (-f $errfile));
106 if (-f "$logdir/amflush.1" && -f "$logdir/amdump.1" &&
107 -M "$logdir/amflush.1" < -M "$logdir/amdump.1") {
108 $errfile="$logdir/amflush.1";
110 $errfile="$logdir/amdump.1";
115 open(AMDUMP,"<$errfile") || die("$errfile: $!");
116 print "Using $errfile";
118 $start_degraded_mode = 0;
120 $label = ""; # -w fodder
121 $origsize = 0; # -w fodder
128 @dumpers_active = ();
130 $ntpartition{$nb_tape} = 0;
131 $ntsize{$nb_tape} = 0;
132 $ntesize{$nb_tape} = 0;
137 if(/(amdump|amflush): start at (.*)/) {
139 $starttime=&unctime(split(/[ ]+/,$2));
141 elsif(/amdump: datestamp (\S+)/) {
143 if(!defined $datestamp{$gdatestamp}) {
144 $datestamp{$gdatestamp} = 1;
145 push @datestamp, $gdatestamp;
148 elsif(/setup_estimate: (\S+):(\S+): command .*, options:/) {
151 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
152 $estimate{$hostpart}=0;
155 $dump_started{$hostpart}=0;
156 $dump_finished{$hostpart}=0;
157 $taper_started{$hostpart}=0;
158 $taper_finished{$hostpart}=0;
159 $error{$hostpart}="";
161 elsif(/got result for host (\S+) disk (\S+): (\d+) -> (\d+)K,/) {
164 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
165 $estimate{$hostpart}=1;
166 $level{$hostpart}=$3;
167 $esize{$hostpart}=$4;
169 elsif(/getting estimates took/) {
175 elsif(/GENERATING SCHEDULE:/) {
176 $generating_schedule=1;
178 elsif(/^(\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+/) {
179 if($generating_schedule == 1 ) {
182 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
183 $level{"$hostpart"}=$4;
185 $esize=32 if $esize<32;
186 $esize{$hostpart}=$esize;
187 $degr_level{$hostpart}=-1;
190 elsif(/^DUMP (\S+) (\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+/) {
191 if($generating_schedule == 1 ) {
195 $hostpart=&make_hostpart($host,$partition,$datestamp);
196 $level{"$hostpart"}=$5;
198 $esize=32 if $esize<32;
199 $esize{$hostpart}=$esize;
200 $degr_level{$hostpart}=-1;
203 elsif(/^DUMP (\S+) (\S+) (\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+/) {
204 if($generating_schedule == 1 ) {
210 $hostpart=&make_hostpart($host,$partition,$datestamp);
211 $level{"$hostpart"}=$6;
213 $esize=32 if $esize<32;
214 $esize{$hostpart}=$esize;
215 $degr_level{$hostpart}=-1;
218 elsif(/^(\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+ (\d+) \d+:\d+:\d+:\d+:\d+:\d+ ([-]*\d+) \d+/) {
219 if($generating_schedule == 1 ) {
222 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
223 $level{$hostpart}=$4;
225 $esize=32 if $esize<32;
226 $esize{$hostpart}=$esize;
227 $degr_level{$hostpart}=$6;
228 $degr_size{$hostpart}=$7;
229 $degr_size{$hostpart}=32 if ($7 < 32);
232 elsif(/^DUMP (\S+) (\S+) (\S+) (\d+) (\d+) \d+:\d+:\d+:\d+:\d+:\d+ (\d+) \d+ (\d+) \d+:\d+:\d+:\d+:\d+:\d+ ([-]*\d+) \d+/) {
233 if($generating_schedule == 1 ) {
237 $hostpart=&make_hostpart($host,$partition,$datestamp);
238 $level{$hostpart}=$5;
240 $esize=32 if $esize<32;
241 $esize{$hostpart}=$esize;
242 $degr_level{$hostpart}=$7;
243 $degr_size{$hostpart}=$8;
244 $degr_size{$hostpart}=32 if ($8 < 32);
247 elsif(/^FLUSH (\S+) (\S+) (\S+) (\d+) (\S+)/) {
253 $hostpart=&make_hostpart($host,$partition,$datestamp);
255 $holding_file{$hostpart}=$holding_file;
256 $level{$hostpart}=$level;
258 elsif(/^driver: start time (\S+)/) {
261 $dumpers_active[0]=0;
265 elsif(/^driver: tape size (\d+)/) {
268 elsif(/^driver: adding holding disk \d+ dir \S+ size (\d+)/) {
269 $holding_space += $1;
271 elsif(/driver: send-cmd time (\S+) to (dumper\d*): (FILE-DUMP|PORT-DUMP) (\d+-\d+) (\S+) (\S+) (\S+) (\d+)/) {
275 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
277 $serial{$serial}=$hostpart;
278 $dump_started{$hostpart}=1;
279 $dump_time{$hostpart}=$1;
280 $dump_finished{$hostpart}=0;
281 $holding_file{$hostpart}=$5;
282 if( $level{$hostpart} != $8 &&
283 $degr_level{$hostpart} == $8) {
284 $level{$hostpart}=$degr_level{$hostpart};
285 $esize{$hostpart}=$degr_size{$hostpart};
287 if(! defined($busy_time{$2})) {
290 $running_dumper{$2} = $hostpart;
291 $error{$hostpart}="";
293 if(! defined($dumpers_active[$dumpers_active])) {
294 $dumpers_active[$dumpers_active]=0;
296 if(! defined($dumpers_held[$dumpers_active])) {
297 $dumpers_held[$dumpers_active]={};
300 elsif(/driver: send-cmd time (\S+) to (dumper\d*): (FILE-DUMP|PORT-DUMP) (\d+-\d+) (\S+) (\S+) (\S+) (\S+) (\d+)/) {
306 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
308 $serial{$serial}=$hostpart;
309 $dump_started{$hostpart}=1;
310 $dump_time{$hostpart}=$1;
311 $dump_finished{$hostpart}=0;
312 $holding_file{$hostpart}=$5 if $3 eq "FILE-DUMP";
313 if( $level{$hostpart} != $9 &&
314 $degr_level{$hostpart} == $9) {
315 $level{$hostpart}=$degr_level{$hostpart};
316 $esize{$hostpart}=$degr_size{$hostpart};
318 if(! defined($busy_time{$2})) {
321 $running_dumper{$2} = $hostpart;
322 $error{$hostpart}="";
324 if(! defined($dumpers_active[$dumpers_active])) {
325 $dumpers_active[$dumpers_active]=0;
327 if(! defined($dumpers_held[$dumpers_active])) {
328 $dumpers_held[$dumpers_active]={};
331 elsif(/driver: send-cmd time (\S+) to (dumper\d*): (FILE-DUMP|PORT-DUMP) (\d+-\d+) (\S+) (\S+) (\S+) (\S+) (\S+) (\d+)/) {
339 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
341 $serial{$serial}=$hostpart;
342 $dump_started{$hostpart}=1;
343 $dump_time{$hostpart}=$1;
344 $dump_finished{$hostpart}=0;
345 $holding_file{$hostpart}=$5 if $3 eq "FILE-DUMP";
346 if( $level{$hostpart} != $10 &&
347 $degr_level{$hostpart} == $10) {
348 $level{$hostpart}=$degr_level{$hostpart};
349 $esize{$hostpart}=$degr_size{$hostpart};
351 if(! defined($busy_time{$2})) {
354 $running_dumper{$2} = $hostpart;
355 $error{$hostpart}="";
357 if(! defined($dumpers_active[$dumpers_active])) {
358 $dumpers_active[$dumpers_active]=0;
360 if(! defined($dumpers_held[$dumpers_active])) {
361 $dumpers_held[$dumpers_active]={};
364 elsif(/driver: result time (\S+) from (dumper\d+): FAILED (\d+-\d+) (.*)/) {
368 $hostpart=$serial{$serial};
369 $dump_finished{$hostpart}=-1;
370 $busy_time{$2}+=($1-$dump_time{$hostpart});
371 $running_dumper{$2} = "0";
372 $dump_time{$hostpart}=$1;
373 $error{$hostpart}="driver: $error";
376 elsif(/driver: result time (\S+) from (dumper\d+): TRY-AGAIN (\d+-\d+) (.*)/) {
380 $hostpart=$serial{$serial};
381 $dump_started{$hostpart}=0;
382 $dump_finished{$hostpart}=0;
383 $busy_time{$2}+=($1-$dump_time{$hostpart});
384 $running_dumper{$2} = "0";
385 $dump_time{$hostpart}=$1;
386 $error{$hostpart}="driver: (aborted:$error)";
389 elsif(/driver: result time (\S+) from (dumper\d+): DONE (\d+-\d+) (\d+) (\d+) (\d+) \[.*\]/) {
394 $hostpart=$serial{$serial};
395 $size{$hostpart}=$outputsize;
396 $dump_finished{$hostpart}=1;
397 $busy_time{$2}+=($1-$dump_time{$hostpart});
398 $running_dumper{$2} = "0";
399 $dump_time{$hostpart}=$1;
400 $error{$hostpart}="";
403 elsif(/driver: result time (\S+) from (dumper\d+): ABORT-FINISHED (\d+-\d+)/) {
406 $hostpart=$serial{$serial};
407 $dump_started{$hostpart}=0;
408 $dump_finished{$hostpart}=0;
409 $busy_time{$2}+=($1-$dump_time{$hostpart});
410 $running_dumper{$2} = "0";
411 $dump_time{$hostpart}=$1;
412 $error{$hostpart}="driver: (aborted)";
415 elsif(/driver: finished-cmd time (\S+) dumper\d+ dumped (\S+):(\S+)/){
418 elsif(/driver: send-cmd time (\S+) to taper: START-TAPER (\S+)/) {
419 if(!defined $gdatestamp) {
421 if(!defined $datestamp{$gdatestamp}) {
422 $datestamp{$gdatestamp} = 1;
423 push @datestamp, $gdatestamp;
427 elsif(/driver: send-cmd time (\S+) to taper: FILE-WRITE (\d+-\d+) (\S+) (\S+) (\S+) (\d*) (\S+)/){
434 if(!defined $datestamp{$ldatestamp}) {
435 $datestamp{$ldatestamp} = 1;
436 push @datestamp, $ldatestamp;
438 $hostpart=&make_hostpart($host,$partition,$ldatestamp);
439 $serial{$serial}=$hostpart;
440 if(!defined $level{$hostpart}) {
441 $level{$hostpart} = $level;
443 $serial{$serial}=$hostpart;
444 $taper_started{$hostpart}=1;
445 $taper_finished{$hostpart}=0;
446 $taper_time{$hostpart}=$1;
448 #features (maybe missing features)
449 elsif(/driver: send-cmd time (\S+) to taper: FILE-WRITE (\d+-\d+) (\S+) (\S+) (\S*) (\S+) (\d*) (\S+)/){
458 if(!defined $datestamp{$ldatestamp}) {
459 $datestamp{$ldatestamp} = 1;
460 push @datestamp, $ldatestamp;
462 $hostpart=&make_hostpart($host,$partition,$ldatestamp);
463 $serial{$serial}=$hostpart;
464 if(!defined $level{$hostpart}) {
465 $level{$hostpart} = $level;
467 $serial{$serial}=$hostpart;
468 $taper_started{$hostpart}=1;
469 $taper_finished{$hostpart}=0;
470 $taper_time{$hostpart}=$1;
472 elsif(/driver: send-cmd time (\S+) to taper: PORT-WRITE (\d+-\d+) (\S+) (\S+) \d+( \d+|)/){
477 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
478 $serial{$serial}=$hostpart;
479 $taper_started{$hostpart}=1;
480 $taper_finished{$hostpart}=0;
481 $taper_time{$hostpart}=$1;
483 elsif(/driver: send-cmd time (\S+) to taper: PORT-WRITE (\d+-\d+) (\S+) (\S+) (\S+) \d+ \d+/){
489 $hostpart=&make_hostpart($host,$partition,$gdatestamp);
490 $serial{$serial}=$hostpart;
491 $taper_started{$hostpart}=1;
492 $taper_finished{$hostpart}=0;
493 $taper_time{$hostpart}=$1;
495 elsif(/driver: result time (\S+) from taper: DONE (\d+-\d+) (\S+) (\d+) \[sec (\S+) kb (\d+) kps/) {
500 $hostpart=$serial{$serial};
501 $taper_finished{$hostpart}=1;
502 $busy_time{"taper"}+=($1-$taper_time{$hostpart});
503 $taper_time{$hostpart}=$1;
504 if(!defined $size{$hostpart}) {
505 $size{$hostpart}=$size;
507 $ntpartition{$nb_tape}++;
508 $ntsize{$nb_tape} += $size{$hostpart};
509 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
510 $ntesize{$nb_tape} += $esize{$hostpart};
513 $ntesize{$nb_tape} += $size{$hostpart};
516 elsif(/driver: result time (\S+) from taper: (TRY-AGAIN|TAPE-ERROR) (\d+-\d+) (.+)/) {
520 $hostpart=$serial{$serial};
521 $taper_finished{$hostpart}= $2 eq 'TAPE-ERROR' ? -2 : -1;
522 $busy_time{"taper"}+=($1-$taper_time{$hostpart});
523 $taper_time{$hostpart}=$1;
524 $error{$hostpart}="driver: $error";
526 elsif(/planner: FAILED (\S+) (\S+) (\S+) (\d+) (.*)/) {
530 $hostpart=&make_hostpart($host,$partition,$datestamp);
531 $dump_started{$hostpart}=-1;
532 $level{$hostpart}=$4;
533 $error{$hostpart}="planner: $5";
535 elsif(/dump of driver schedule after start degraded mode:/) {
536 $start_degraded_mode=1;
538 elsif(/driver: state time (\S+) free (.*) taper: (\S+) idle-dumpers: (\d+) qlen (.*) driver-idle: (\S+)/) {
543 %free = split (/ +/, $2);
544 %qlen = split (/ +/, $5);
546 if($status_driver ne "") {
547 $dumpers_active[$dumpers_active_prev]
548 +=$current_time-$state_time_prev;
549 $dumpers_held[$dumpers_active_prev]{$status_driver}
550 +=$current_time-$state_time_prev;
552 $state_time_prev=$current_time;
553 $dumpers_active_prev=$dumpers_active;
555 if(! defined($dumpers_held[$dumpers_active]{$status_driver})) {
556 $dumpers_held[$dumpers_active]{$status_driver}=0;
559 elsif(/taper: wrote label `(\S*)'/) {
561 $ntlabel{$nb_tape} = $1;
562 $ntpartition{$nb_tape} = 0;
563 $ntsize{$nb_tape} = 0;
564 $ntesize{$nb_tape} = 0;
570 if(defined $current_time) {
571 for ($d = 0; $d < $#dumpers_active; $d++) {
572 $the_dumper = "dumper$d";
573 if(defined($running_dumper{$the_dumper}) &&
574 $running_dumper{$the_dumper} ne "0") {
575 $busy_time{$the_dumper}+=($current_time-$dump_time{$running_dumper{$the_dumper}});
619 foreach $host (sort @hosts) {
620 foreach $partition (sort @$host) {
621 foreach $datestamp (sort @datestamp) {
622 $hostpart=&make_hostpart($host,$partition,$datestamp);
623 next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
624 if(length("$host:$partition") > $maxnamelength) {
625 $maxnamelength = length("$host:$partition");
631 foreach $host (sort @hosts) {
632 foreach $partition (sort @$host) {
633 foreach $datestamp (sort @datestamp) {
634 $hostpart=&make_hostpart($host,$partition,$datestamp);
635 next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
637 if( !defined $size{$hostpart} && defined $holding_file{$hostpart}) {
638 $size{$hostpart} = &dump_size($holding_file{$hostpart}) / 1024;
641 if($estimate_done != 1) {
642 if(defined $estimate{$hostpart}) {
643 if($estimate{$hostpart} != 1) {
644 if( defined $opt_gestimate) {
645 printf "%8s ", $datestamp if defined $opt_date;
646 printf "%-${maxnamelength}s", "$host:$partition";
647 print " getting estimate\n";
651 if(defined $opt_estimate) {
652 printf "%8s ", $datestamp if defined $opt_date;
653 printf "%-${maxnamelength}s", "$host:$partition";
654 printf "%2d", $level{$hostpart};
655 printf "%9dk", $esize{$hostpart};
656 print " estimate done\n";
659 $estsize += $esize{$hostpart};
664 if(defined $estimate{$hostpart}) {
665 if($estimate{$hostpart} == 1) {
667 $estsize += $esize{$hostpart};
669 elsif (!defined $dump_started{$hostpart} || $dump_started{$hostpart} == 0) {
670 if( defined $opt_failed) {
671 printf "%8s ", $datestamp if defined $opt_date;
672 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
673 printf " no estimate\n";
680 $flsize += $size{$hostpart};
683 if(defined $taper_started{$hostpart} &&
684 $taper_started{$hostpart}==1) {
685 if(defined $dump_started{$hostpart}) {
687 if(defined($size{$hostpart})) {
688 $dsize += $size{$hostpart};
691 $dsize += $esize{$hostpart};
693 $desize += $esize{$hostpart};
695 if(defined $dump_started{$hostpart} &&
696 $dump_started{$hostpart} == 1 &&
697 $dump_finished{$hostpart} == 0 &&
698 $taper_started{$hostpart} == 1) {
699 if( defined $opt_dumpingtape ) {
700 printf "%8s ", $datestamp if defined $opt_date;
701 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
702 printf "%9dk", $esize{$hostpart};
703 print " dumping to tape";
704 if( defined $starttime ) {
705 print " (", &showtime($taper_time{$hostpart}), ")";
710 $dtesize += $esize{$hostpart};
712 elsif($taper_finished{$hostpart} == 0) {
713 if( defined $opt_writingtape ) {
714 printf "%8s ", $datestamp if defined $opt_date;
715 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
716 printf "%9dk", $size{$hostpart};
718 print " writing to tape";
721 print " flushing to tape";
723 if( defined $starttime ) {
724 print " (", &showtime($taper_time{$hostpart}), ")";
729 $tasize += $size{$hostpart};
730 if(defined $esize{$hostpart}) {
731 $taesize += $esize{$hostpart};
734 $taesize += $size{$hostpart};
737 elsif($taper_finished{$hostpart} < 0) {
738 if( defined $opt_failed ||
739 (defined $opt_waittaper && ($taper_finished{$hostpart} == -1))) {
740 printf "%8s ", $datestamp if defined $opt_date;
741 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
742 printf "%9dk", $size{$hostpart};
744 print " failed to tape";
747 print " failed to flush";
749 print " (will retry)" unless $taper_finished{$hostpart} < -1;
750 if( defined $starttime ) {
751 print " (", &showtime($taper_time{$hostpart}), ")";
757 $tfsize += $size{$hostpart};
758 if(defined $esize{$hostpart}) {
759 $tfesize += $esize{$hostpart};
762 $tfesize += $size{$hostpart};
767 $twsize += $size{$hostpart};
768 if(defined $esize{$hostpart}) {
769 $twesize += $esize{$hostpart};
772 $twesize += $size{$hostpart};
777 $wfsize += $size{$hostpart};
778 if(defined $esize{$hostpart}) {
779 $wfesize += $esize{$hostpart};
782 $wfesize += $size{$hostpart};
786 elsif($taper_finished{$hostpart} == 1) {
787 if( defined $opt_finished ) {
788 printf "%8s ", $datestamp if defined $opt_date;
789 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
790 printf "%9dk", $size{$hostpart};
797 if( defined $starttime ) {
798 print " (", &showtime($taper_time{$hostpart}), ")";
803 $tsize += $size{$hostpart};
804 if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
805 $tesize += $esize{$hostpart};
808 $tesize += $size{$hostpart};
812 printf "%8s ", $datestamp if defined $opt_date;
813 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
814 print " unknown state TAPER\n";
817 elsif(defined $dump_started{$hostpart}) {
818 if($dump_started{$hostpart} == -1) {
819 if( defined $opt_failed ) {
820 printf "%8s ", $datestamp if defined $opt_date;
821 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
822 printf " " . $error{$hostpart} . "\n";
825 $fsize+=$esize{$hostpart};
827 elsif($dump_started{$hostpart} == 0) {
828 if($estimate{$hostpart} == 1) {
829 if( defined $opt_waitdumping ) {
830 printf "%8s ", $datestamp if defined $opt_date;
831 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
832 printf "%9dk", $esize{$hostpart};
833 print " wait for dumping $error{$hostpart}\n";
836 $wsize += $esize{$hostpart};
839 elsif($dump_started{$hostpart} == 1 &&
840 $dump_finished{$hostpart} == -1) {
841 if( defined $opt_failed ) {
842 printf "%8s ", $datestamp if defined $opt_date;
843 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
844 print " ", $error{$hostpart};
845 if( defined $starttime ) {
846 print " (", &showtime($dump_time{$hostpart}), ")";
851 $fsize+=$esize{$hostpart};
853 elsif($dump_started{$hostpart} == 1 &&
854 $dump_finished{$hostpart} != 1) {
855 if( defined $opt_dumping ) {
856 printf "%8s ", $datestamp if defined $opt_date;
857 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
858 printf "%9dk", $esize{$hostpart};
859 printf " dumping %8dk", $size{$hostpart};
860 if($size{$hostpart} != 0) {
861 printf " (%6.2f%%)", (100.0*$size{$hostpart})/$esize{$hostpart};
863 if( defined $starttime ) {
864 print " (", &showtime($dump_time{$hostpart}), ")";
869 $dusize += $size{$hostpart};
870 $duesize += $esize{$hostpart};
872 elsif($dump_finished{$hostpart} == 1 &&
873 $taper_started{$hostpart} != 1) {
874 if( defined $opt_waittaper ) {
875 printf "%8s ", $datestamp if defined $opt_date;
876 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
877 printf "%9dk", $size{$hostpart};
879 if( defined $starttime ) {
880 print " (", &showtime($dump_time{$hostpart}), ")";
882 print ", wait for writing to tape\n";
885 $dsize += $size{$hostpart};
886 $desize += $esize{$hostpart};
888 $twsize += $size{$hostpart};
889 $twesize += $esize{$hostpart};
892 printf "%8s ", $datestamp if defined $opt_date;
893 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
894 print " unknown state DUMPER\n";
897 elsif(defined $flush{$hostpart}) {
898 if( defined $opt_waittaper ) {
899 printf "%8s ", $datestamp if defined $opt_date;
900 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
901 printf "%9dk", $size{$hostpart};
902 print " waiting to flush\n";
905 $wfsize += $size{$hostpart};
907 elsif(defined $level{$hostpart}) {
908 printf "%8s ", $datestamp if defined $opt_date;
909 printf "%-${maxnamelength}s%2d", "$host:$partition", $level{$hostpart};
910 print " unknown state\n";
917 if (defined $opt_summary) {
919 print "SUMMARY part real estimated\n";
920 print " size size\n";
921 printf "partition : %3d\n", $nb_partition;
922 printf "estimated : %3d %20dk\n", $epartition , $estsize;
923 printf "flush : %3d %9dk\n", $flpartition, $flsize;
924 printf "failed : %3d %20dk (%6.2f%%)\n",
925 $fpartition , $fsize,
926 $estsize ? ($fsize * 1.0 / $estsize) * 100 : 0.0;
927 printf "wait for dumping: %3d %20dk (%6.2f%%)\n",
928 $wpartition , $wsize,
929 $estsize ? ($wsize * 1.0 / $estsize) * 100 : 0.0;
930 printf "dumping to tape : %3d %20dk (%6.2f%%)\n",
931 $dtpartition, $dtesize,
932 $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
933 printf "dumping : %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
934 $dupartition, $dusize, $duesize,
935 $duesize ? ($dusize * 1.0 / $duesize) * 100 : 0.0,
936 $estsize ? ($dusize * 1.0 / $estsize) * 100 : 0.0;
937 printf "dumped : %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
938 $dpartition , $dsize , $desize,
939 $desize ? ($dsize * 1.0 / $desize) * 100 : 0.0,
940 $estsize ? ($dsize * 1.0 / $estsize) * 100 : 0.0;
941 printf "wait for writing: %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
942 $twpartition, $twsize, $twesize,
943 $twesize ? ($twsize * 1.0 / $twesize) * 100 : 0.0,
944 $estsize ? ($twsize * 1.0 / $estsize) * 100 : 0.0;
945 printf "wait to flush : %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
946 $wfpartition, $wfsize, $wfsize, 100, 0;
947 printf "writing to tape : %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
948 $tapartition, $tasize, $taesize,
949 $taesize ? ($tasize * 1.0 / $taesize) * 100 : 0.0,
950 $estsize ? ($tasize * 1.0 / $estsize) * 100 : 0.0;
951 printf "failed to tape : %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
952 $tfpartition, $tfsize, $tfesize,
953 $tfesize ? ($tfsize * 1.0 / $tfesize) * 100 : 0.0,
954 $estsize ? ($tfsize * 1.0 / $estsize) * 100 : 0.0;
955 printf "taped : %3d %9dk %9dk (%6.2f%%) (%6.2f%%)\n",
956 $tpartition , $tsize , $tesize,
957 $tesize ? ($tsize * 1.0 / $tesize) * 100 : 0.0,
958 ($estsize+$flsize) ? ($tsize * 1.0 / ($estsize + $flsize)) * 100 : 0.0;
959 if($nb_tape > 1 || $tape_size != 0) {
960 for($i=1; $i <= $nb_tape; $i++) {
961 if($tape_size != 0) {
962 printf " tape %-3d : %3d %9dk %9dk (%6.2f%%) %s\n",
963 $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, 100*$ntsize{$i}/$tape_size, $ntlabel{$i};
966 printf " tape %-3d : %3d %9dk %9dk %s\n",
967 $i, $ntpartition{$i}, $ntsize{$i}, $ntesize{$i}, $ntlabel{$i};
971 if($idle_dumpers ==0) {
972 printf "all dumpers active\n";
975 $c1 = ($idle_dumpers == 1) ? "" : "s";
976 $c2 = ($idle_dumpers < 10) ? " " : "";
977 $c3 = ($idle_dumpers == 1) ? " " : "";
978 printf "%d dumper%s idle%s %s: %s\n", $idle_dumpers, $c1, $c2, $c3, $status_driver;
980 if($status_taper eq "writing" && defined($qlen{"tapeq:"})) {
981 printf "taper writing, tapeq: %d\n", $qlen{"tapeq:"};
984 printf "taper idle\n";
986 if (defined ($free{"kps:"})) {
987 printf "network free kps: %9d\n", $free{"kps:"};
989 if (defined ($free{"space:"})) {
990 if ($holding_space) {
991 $hs = ($free{"space:"} * 1.0 / $holding_space) * 100;
995 printf "holding space : %9dk (%6.2f%%)\n", $free{"space:"}, $hs;
999 if(defined $opt_stats) {
1000 if(defined($current_time) && $current_time != $start_time) {
1001 $total_time=$current_time-$start_time;
1002 foreach $key (sort byprocess keys %busy_time) {
1003 printf "%8s busy : %8s (%6.2f%%)\n",
1004 $key, &busytime($busy_time{$key}),
1005 ($busy_time{$key} * 1.0 / $total_time) * 100;
1007 for ($d = 0; $d <= $#dumpers_active; $d++) {
1008 $l = sprintf "%2d dumper%s busy%s : %8s (%6.2f%%)",
1009 $d, ($d == 1) ? "" : "s", ($d == 1) ? " " : "",
1010 &busytime($dumpers_active[$d]),
1011 ($dumpers_active[$d] * 1.0 / $total_time) * 100;
1014 $s2 = " " x length($l);
1015 $r = $dumpers_held[$d];
1016 foreach $key (sort valuesort keys %$r) {
1018 unless $dumpers_held[$d]{$key} >= 1;
1019 printf "%s%20s: %8s (%6.2f%%)\n",
1022 &busytime($dumpers_held[$d]{$key}),
1023 ($dumpers_held[$d]{$key} * 1.0 / $dumpers_active[$d]) * 100;
1033 sub make_hostpart() {
1034 local($host,$partition,$datestamp) = @_;
1036 if(! defined($hosts{$host})) {
1041 foreach $pp (sort @$host) {
1042 $new_part = 0 if ($pp eq $partition);
1044 push @$host, $partition if $new_part==1;
1046 my($hostpart) = "$host$partition$datestamp";
1047 if(!defined $datestamp{$datestamp}) {
1048 $datestamp{$datestamp} = 1;
1049 push @datestamp, $datestamp;
1055 my(@tmp_a) = split(/(\d*)$/, $a, 2);
1056 my(@tmp_b) = split(/(\d*)$/, $b, 2);
1057 return ($tmp_a[0] cmp $tmp_b[0]) || ($tmp_a[1] <=> $tmp_b[1]);
1061 $r->{$b} <=> $r->{$a};
1065 local($filename) = @_;
1068 local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1069 $atime,$mtime,$ctime,$blksize,$blocks);
1070 while ($filename ne "") {
1071 $filename = "$filename.tmp" if (!(-e "$filename"));
1072 $filename = "/dev/null" if (!(-e "$filename"));
1073 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1074 $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
1075 $size=$size-32768 if $size > 32768;
1077 open(DUMP,$filename);
1080 if(/^CONT_FILENAME=(.*)$/) { $filename = $1; last }
1081 last if /^To restore, position tape at start of file and run/;
1096 @MoY = ('Jan','Feb','Mar','Apr','May','Jun',
1097 'Jul','Aug','Sep','Oct','Nov','Dec');
1099 # Preset an array of values in case some parts are not passed as
1100 # arguments. This lets the date, etc, be omitted and default to
1109 # See if this argument looks like a month name.
1115 $month = $month + 1;
1122 # See if this is a day of the month.
1124 if ($a =~ /^\d+$/ && $a >= 1 && $a <= 32) {
1129 # See if the next argument looks like a time.
1131 if ($a =~ /^(\d+):(\d+)/) {
1134 if ($a =~ /^(\d+):(\d+):(\d+)/) {
1140 # See if this is a year.
1142 if ($a =~ /^\d\d\d\d$/ && $a >= 1900) {
1148 $time = &timelocal (@tl);
1155 my($oneday)=24*60*60;
1157 @now=localtime($starttime+$delta);
1158 if($delta > $oneday) {
1159 $result=sprintf("%d+",$delta/$oneday);
1163 $result.=sprintf("%d:%02d:%02d",$now[2],$now[1],$now[0]);
1169 my($oneday)=24*60*60;
1171 if($busy > $oneday) {
1172 $days=int($busy/$oneday);
1173 $result=sprintf("%d+",$busy/$oneday);
1174 $busy-=$days*$oneday;
1178 $hours=int($busy/60/60);
1179 $busy-=$hours*60*60;
1180 $minutes=int($busy/60);
1183 $result.=sprintf("%d:%02d:%02d",$hours,$minutes,$seconds);
1188 print "amstatus [--config] config [--file amdump_file]\n";
1189 print " [--summary] [--dumping] [--waitdumping] [--waittaper]\n";
1190 print " [--dumpingtape] [--writingtape] [--finished] [--failed]\n";
1191 print " [--estimate] [--gestimate] [--stats] [--date]\n";