lintian doesn't like orphan packages with uploaders...
[debian/amanda] / server-src / amstatus.pl
index 2c32d1b34c3ce9d1fc33a5843e8ac8914b5583dc..2dc19f9e5fcebd268b65260c33995aa3d144f065 100644 (file)
@@ -1,4 +1,4 @@
-#!@PERL@ -Tw
+#!@PERL@
 #
 
 # Run perl.
@@ -6,9 +6,13 @@ eval '(exit $?0)' && eval 'exec @PERL@ -S $0 ${1+"$@"}'
         & eval 'exec @PERL@ -S $0 $argv:q'
                if 0;
 
-require "newgetopt.pl";
+use warnings;
+use lib '@amperldir@';
 use Time::Local;
 use Text::ParseWords;
+use Amanda::Util;
+use Amanda::Process;
+use Getopt::Long;
 
 delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'PATH'};
 $ENV{'PATH'} = "/bin:/usr/bin:/usr/sbin:/sbin";       # force known path
@@ -20,38 +24,61 @@ $exec_prefix="@exec_prefix@";
 $exec_prefix=$exec_prefix;     # ditto
 $sbindir="@sbindir@";
 
+my $Amanda_process = Amanda::Process->new(0);
+$Amanda_process->load_ps_table();
+
 #$STATUS_STRANGE =  2;
 $STATUS_FAILED  =  4;
 $STATUS_MISSING =  8;
 $STATUS_TAPE    = 16;
 $exit_status    =  0;
 
-$USE_VERSION_SUFFIXES='@USE_VERSION_SUFFIXES@';
-$suf = '';
-if ( $USE_VERSION_SUFFIXES =~ /^yes$/i ) {
-        $suf='-@VERSION@';
-}
+my $opt_summary;
+my $opt_stats;
+my $opt_dumping;
+my $opt_waitdumping;
+my $opt_waittaper;
+my $opt_dumpingtape;
+my $opt_writingtape;
+my $opt_finished;
+my $opt_failed;
+my $opt_estimate;
+my $opt_gestimate;
+my $opt_date;
+my $opt_config;
+my $opt_file;
+my $opt_locale_independent_date_format;
 
-$result = &NGetOpt (   "summary",
-                       "stats|statistics",
-                       "dumping|d",
-                       "waitdumping|wdumping",
-                       "waittaper|wtaper",
-                       "dumpingtape|dtape",
-                       "writingtape|wtape",
-                       "finished",
-                       "failed|error",
-                       "estimate",
-                       "gestimate|gettingestimate",
-                       "date",
-                       "config|c:s",
-                       "file:s",
-                       "locale-independent-date-format",
-                       );
-if($result !=1 ) {
-       &usage();
+sub usage() {
+       print "amstatus [--file amdump_file]\n";
+       print "         [--summary] [--dumping] [--waitdumping] [--waittaper]\n";
+       print "         [--dumpingtape] [--writingtape] [--finished] [--failed]\n";
+       print "         [--estimate] [--gestimate] [--stats] [--date]\n";
+       print "         [--locale-independent-date-format]\n";
+       print "         [--config] <config>\n";
+       exit 0;
 }
 
+Getopt::Long::Configure(qw{ bundling });
+GetOptions(
+    'summary'                        => \$opt_summary,
+    'stats|statistics'               => \$opt_stats,
+    'dumping|d'                      => \$opt_dumping,
+    'waitdumping|wdumping'           => \$opt_waitdumping,
+    'waittaper|wtaper'               => \$opt_waittaper,
+    'dumpingtape|dtape'              => \$opt_dumpingtape,
+    'writingtape|wtape'              => \$opt_writingtape,
+    'finished'                       => \$opt_finished,
+    'failed|error'                   => \$opt_failed,
+    'estimate'                       => \$opt_estimate,
+    'gestimate|gettingestimate'      => \$opt_gestimate,
+    'date'                           => \$opt_date,
+    'config|c:s'                     => \$opt_config,
+    'file:s'                         => \$opt_file,
+    'locale-independent-date-format' => \$opt_locale_independent_date_format,
+    ) or usage();
+
+
 if( defined $opt_config ) {
        $conf = $opt_config;
 }
@@ -73,11 +100,11 @@ if ($conf =~ /^([\w.-]+)$/) {          # $1 is untainted
 }
 
 if ( ! -e "$confdir/$conf" ) {
-    print "Configuration directory '" . $confdir/$conf . "' doesn't exist\n";
+    print "Configuration directory '$confdir/$conf' doesn't exist\n";
     exit 1;
 }
 if ( ! -d "$confdir/$conf" ) {
-    print "Configuration directory '" . $confdir/$conf . "' is not a directory\n";
+    print "Configuration directory '$confdir/$conf' is not a directory\n";
     exit 1;
  }
 
@@ -86,7 +113,7 @@ $pwd = `pwd`;
 chomp $pwd;
 chdir "$confdir/$conf";
 
-$logdir=`$sbindir/amgetconf$suf logdir`;
+$logdir=`$sbindir/amgetconf logdir`;
 exit 1 if $? != 0;
 chomp $logdir;
 $errfile="$logdir/amdump";
@@ -117,7 +144,7 @@ if($nb_options == 0 ) {
        $opt_estimate    = 1;
 }
 
-$unit=`$sbindir/amgetconf$suf displayunit`;
+$unit=`$sbindir/amgetconf displayunit`;
 chomp($unit);
 $unit =~ tr/A-Z/a-z/;
 $unitdivisor=1;
@@ -139,6 +166,7 @@ else {
 }
 
 
+my $dead_run = 0;
 if( defined $opt_file) {
        if( $opt_file =~ m,^/, ) {
                $errfile = $opt_file;
@@ -156,19 +184,22 @@ else {
                } else {
                        $errfile="$logdir/amdump.1";
                }
+               $dead_run = 1;
        }
 }
 
 open(AMDUMP,"<$errfile") || die("$errfile: $!");
 print "Using $errfile\n";
 
+my %taper_status_file;
+
 $start_degraded_mode = 0;
 
 $label = "";                                   # -w fodder
 $origsize = 0;                                 # -w fodder
 $idle_dumpers = 0;
 $status_driver = "";
-$status_taper = 0;
+$status_taper = "Searching for a new tape";
 $estimate_done = 0;
 $holding_space = 0;
 $start_time = 0;
@@ -228,8 +259,8 @@ while($lineX = <AMDUMP>) {
                        $dump_started{$hostpart}=-1;
                        $level{$hostpart}=$line[5];
                        $error{$hostpart}="planner: " . $line[6];
-       } elsif($line[1] eq "time") {
-               if($line[3] eq "got") {
+       } elsif($line[1] eq "time") {
+               if($line[3] eq "got") {
                                if($line[4] eq "result") {
                                        $host = $line[7];
                                        $partition = $line[9];
@@ -312,10 +343,10 @@ while($lineX = <AMDUMP>) {
                        $esize=$line[14];       #compressed size
                        $esize=32 if $esize<32;
                        $esize{$hostpart}=$esize / $unitdivisor;
-                       if(!defined($line[22])) {
+                       if(!defined($line[25])) {
                                $degr_level{$hostpart}=-1;
                        } else {
-                               $degr_level{$hostpart}=$line[18];
+                               $degr_level{$hostpart}=$line[17];
                                $esize=$line[25];       #compressed size
                                $esize=32 if $esize<32;
                                $degr_size{$hostpart}=$esize / $unitdivisor;
@@ -329,10 +360,17 @@ while($lineX = <AMDUMP>) {
                $holding_file = $line[5];
                $hostpart=&make_hostpart($host,$partition,$datestamp);
                $flush{$hostpart}=0;
+               $dump_finished{$hostpart}=0;
                $holding_file{$hostpart}=$holding_file;
                $level{$hostpart}=$level;
        } elsif($line[0] eq "driver") {
-               if($line[1] eq "start" && $line[2] eq "time") {
+               if($line[1] eq "pid") {
+                       $pid = $line[2];
+                       if (! $Amanda_process->process_alive($pid, "driver")) {
+                               $dead_run = 1;
+                       }
+               }
+               elsif($line[1] eq "start" && $line[2] eq "time") {
                        $start_time=$line[3];
                        $current_time=$line[3];
                        $dumpers_active[0]=0;
@@ -359,6 +397,7 @@ while($lineX = <AMDUMP>) {
                                        $partition = $line[11];
                                        $hostpart=&make_hostpart($host,$partition,$gdatestamp);
                                        $serial=$line[7];
+                                       $dumper_to_serial{$line[5]} = $serial;
                                        $dump_started{$hostpart}=1;
                                        $dump_time{$hostpart}=$current_time;
                                        $dump_finished{$hostpart}=0;
@@ -372,6 +411,7 @@ while($lineX = <AMDUMP>) {
                                        }
                                        $running_dumper{$dumper} = $hostpart;
                                        $error{$hostpart}="";
+                                       $taper_error{$hostpart}="";
                                        $size{$hostpart} = 0;
                                        $dumpers_active++;
                                        if(! defined($dumpers_active[$dumpers_active])) {
@@ -388,11 +428,13 @@ while($lineX = <AMDUMP>) {
                                        $partition=$line[11];
                                        $hostpart=&make_hostpart($host,$partition,$gdatestamp);
                                        $serial=$line[7];
+                                       $chunker_to_serial{$line[5]} = $serial;
                                        $serial{$serial}=$hostpart;
                                        $holding_file{$hostpart}=$line[8];
                                        #$chunk_started{$hostpart}=1;
                                        $chunk_time{$hostpart}=$current_time;
                                        #$chunk_finished{$hostpart}=0;
+                                       $size{$hostpart} = 0;
                                }
                                elsif($line[6] eq "CONTINUE") {
                                        #7:handle 8:filename 9:chunksize 10:use
@@ -406,20 +448,33 @@ while($lineX = <AMDUMP>) {
                        }
                        elsif($line[5] =~ /taper/) {
                                if($line[6] eq "START-TAPER") {
-                                       #7:timestamp
-                                       $gdatestamp=$line[7];
+                                       #7:name 8:timestamp
+                                       $gdatestamp=$line[8];
                                        if(!defined $datestamp{$gdatestamp}) {
                                                $datestamp{$gdatestamp} = 1;
                                                push @datestamp, $gdatestamp;
                                        }
+                                       $status_taper = "Searching for a new tape";
+                               }
+                               elsif($line[6] eq "NEW-TAPE") {
+                                       #7:name 8:handle
+                                       $status_taper = "Searching for a new tape";
+                               }
+                               elsif($line[6] eq "NO-NEW-TAPE") {
+                                       #7:name 8:handle 9:errmsg
+                                       $serial=$line[8];
+                                       $error=$line[9];
+                                       $status_taper = $error;
                                }
                                elsif($line[6] eq "FILE-WRITE") {
-                                       #7:handle 8:filename 9:host 10:disk 11:level 12:datestamp 13:splitsize
-                                       $serial=$line[7];
-                                       $host=$line[9];
-                                       $partition=$line[10];
-                                       $level=$line[11];
-                                       $ldatestamp=$line[12];
+                                       #7:name 8:handle 9:filename 10:host 11:disk 12:level 13:datestamp 14:splitsize
+                                       $name=$line[7];
+                                       $serial=$line[8];
+                                       $host=$line[10];
+                                       $partition=$line[11];
+                                       $level=$line[12];
+                                       $ldatestamp=$line[13];
+                                       $status_taper = "Writing $host:$partition";
                                        if(!defined $datestamp{$ldatestamp}) {
                                                $datestamp{$ldatestamp} = 1;
                                                push @datestamp, $ldatestamp;
@@ -432,21 +487,42 @@ while($lineX = <AMDUMP>) {
                                        $taper_started{$hostpart}=1;
                                        $taper_finished{$hostpart}=0;
                                        $taper_time{$hostpart}=$current_time;
-                                       $ntchunk_size = 0;
+                                       $taper_error{$hostpart}="";
+                                       $taper_name{$hostpart} = $name;
+                                       $worker_to_serial{$name} = $serial;
+                                   $tapedsize{$hostpart} = 0;
                                }
                                elsif($line[6] eq "PORT-WRITE") {
-                                       #7:handle 8:host 9:disk 10:level 11:datestamp 12:splitsize 13:diskbuffer 14:fallback_splitsize
-                                       $serial=$line[7];
-                                       $host=$line[8];
-                                       $partition=$line[9];
-                                       $level=$line[10];
-                                       $ldatestamp=$line[11];
+                                       #7:name 8:handle 9:host 10:disk 11:level 12:datestamp 13:splitsize 14:diskbuffer 15:fallback_splitsize
+                                       $name=$line[7];
+                                       $serial=$line[8];
+                                       $host=$line[9];
+                                       $partition=$line[10];
+                                       $level=$line[11];
+                                       $ldatestamp=$line[12];
+                                       $status_taper = "Writing $host:$partition";
                                        $hostpart=&make_hostpart($host,$partition,$ldatestamp);
                                        $serial{$serial}=$hostpart;
                                        $taper_started{$hostpart}=1;
                                        $taper_finished{$hostpart}=0;
                                        $taper_time{$hostpart}=$current_time;
-                                       $ntchunk_size = 0;
+                                       $taper_error{$hostpart}="";
+                                       $taper_name{$hostpart} = $name;
+                                       $worker_to_serial{$name} = $serial;
+                                   $tapedsize{$hostpart} = 0;
+                                       $size{$hostpart} = 0;
+                               }
+                               elsif($line[6] eq "TAKE-SCRIBE-FROM") {
+                                       #7:name1 #8:handle #9:name2
+                                       $name1=$line[7];
+                                       $serial=$line[8];
+                                       $name2=$line[9];
+                                       $hostpart=$serial{$serial};
+                                       $taper_nb{$name1} = $taper_nb{$name2};
+                                       $taper_nb{$name2} = 0;
+                                       if (defined $hostpart) {
+                                               $error{$hostpart} = $olderror{$hostpart};
+                                       }
                                }
                        }
                }
@@ -454,17 +530,28 @@ while($lineX = <AMDUMP>) {
                        #print "result: " , $line[5] . " " . $line[6] . " " . $line[7] . "\n" if defined $line[5] && defined $line[6] && defined $line[7];
                        $current_time = $line[3];
                        if($line[5] =~ /dumper\d+/) {
+                               if($line[6] eq "(eof)") {
+                                       $line[6] = "FAILED";
+                                       $line[7] = $dumper_to_serial{$line[5]};
+                                       $line[8] = "dumper CRASH";
+                               }
                                if($line[6] eq "FAILED" || $line[6] eq "TRY-AGAIN") {
                                        #7:handle 8:message
                                        $serial = $line[7];
                                        $error = $line[8];
                                        $hostpart=$serial{$serial};
-                             $dump_finished{$hostpart}=-1;
+                                       if ($taper_started{$hostpart} == 1) {
+                                               $dump_finished{$hostpart}=-1;
+                                       } else {
+                                               $dump_finished{$hostpart}=-3;
+                                       }
                                        $busy_time{$line[5]}+=($current_time-$dump_time{$hostpart});
-                             $running_dumper{$line[5]} = "0";
-                             $dump_time{$hostpart}=$current_time;
-                             $error{$hostpart}="dumper: $error";
-                             $dumpers_active--;
+                                       $running_dumper{$line[5]} = "0";
+                                       $dump_time{$hostpart}=$current_time;
+                                       if (!$taper_error{$hostpart}) {
+                                               $error{$hostpart}="dumper: $error";
+                                       }
+                                       $dumpers_active--;
 
                                }
                                elsif($line[6] eq "DONE") {
@@ -486,7 +573,11 @@ while($lineX = <AMDUMP>) {
                                        $serial=$line[7];
                                        $hostpart=$serial{$serial};
                                        $dump_started{$hostpart}=0;
-                                       $dump_finished{$hostpart}=0;
+                                       if ($taper_started{$hostpart} == 1) {
+                                               $dump_finished{$hostpart}=-1;
+                                       } else {
+                                               $dump_finished{$hostpart}=-3;
+                                       }
                                        $busy_time{$line[5]}+=($current_time-$dump_time{$hostpart});
                                        $running_dumper{$line[5]} = "0";
                                        $dump_time{$hostpart}=$current_time;
@@ -495,22 +586,31 @@ while($lineX = <AMDUMP>) {
                                }
                        }
                        elsif($line[5] =~ /chunker\d+/) {
+                               if($line[6] eq "(eof)") {
+                                       $line[6] = "FAILED";
+                                       $line[7] = $chunker_to_serial{$line[5]};
+                                       $line[8] = "chunker CRASH";
+                               }
                                if($line[6] eq "DONE" || $line[6] eq "PARTIAL") {
                                        #7:handle 8:size
                                        $serial=$line[7];
                                        $outputsize=$line[8] / $unitdivisor;
                                        $hostpart=$serial{$serial};
                                        $size{$hostpart}=$outputsize;
-                                       $dump_finished{$hostpart}=1;
+                                       if ($line[6] eq "DONE") {
+                                               $dump_finished{$hostpart}=1;
+                                       } else {
+                                               $dump_finished{$hostpart}=-3;
+                                       }
                                        $busy_time{$line[5]}+=($current_time-$chunk_time{$hostpart});
                                        $running_dumper{$line[5]} = "0";
                                        $chunk_time{$hostpart}=$current_time;
-                                       $error{$hostpart}="";
                                        if ($line[6] eq "PARTIAL") {
                                                $partial{$hostpart} = 1;
                                        }
                                        else {
                                                $partial{$hostpart} = 0;
+                                               $error{$hostpart}="";
                                        }
                                }
                                elsif($line[6] eq "FAILED") {
@@ -531,36 +631,56 @@ while($lineX = <AMDUMP>) {
                                }
                        }
                        elsif($line[5] eq "taper") {
-                               if($line[6] eq "DONE" || $line[6] eq "PARTIAL") {
-                                       #7:handle 8:label 9:filenum 10:errstr
+                               if($line[6] eq "(eof)") {
+                                       # all worker fail
+                                       foreach $worker (keys %worker_to_serial) {
+                                               $serial = $worker_to_serial{$worker};
+                                               $hostpart=$serial{$serial};
+                                               if(defined $hostpart) {
+                                                       $error= "taper CRASH";
+                                                       $taper_finished{$hostpart} = -2;
+                                                       $status_taper = $error;
+                                                       $busy_time{"taper"}+=($current_time-$taper_time{$hostpart});
+                                                       $taper_time{$hostpart}=$current_time;
+                                                       $error{$hostpart}="$error";
+                                                       undef $worker_to_serial{$worker};
+                                               }
+                                               undef $taper_status_file{$hostpart};
+                                       }
+                               }
+                               elsif($line[6] eq "DONE" || $line[6] eq "PARTIAL") {
+                                       #DONE:    7:handle 8:label 9:filenum 10:errstr
+                                       #PARTIAL: 7:handle 8:INPUT-* 9:TAPE-* 10:errstr 11:INPUT-MSG 12:TAPE-MSG
                                        $serial=$line[7];
-                                       $label=$line[8];
+
+                                       $status_taper = "Idle";
                                        $hostpart=$serial{$serial};
-                                       $line[10] =~ /sec (\S+) kb (\d+) kps/;
-                                       $size=$2 / $unitdivisor;
+                                       $line[10] =~ /sec (\S+) (kb|bytes) (\d+) kps/;
+                                       if ($2 eq 'kb') {
+                                               $size=$3 / $unitdivisor;
+                                       } else {
+                                               $size=$3 / ( $unitdivisor * 1024);
+                                       }
                                        $taper_finished{$hostpart}=1;
                                        $busy_time{"taper"}+=($current_time-$taper_time{$hostpart});
                                        $taper_time{$hostpart}=$current_time;
                                        if(!defined $size{$hostpart}) {
                                                $size{$hostpart}=$size;
                                        }
-                                       $ntpartition{$nb_tape}++;
-                                       $ntsize{$nb_tape} += $size{$hostpart} - $ntchunk_size;
-                                       if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
-                                               $ntesize{$nb_tape} += $esize{$hostpart} - $ntchunk_size;
-                                       }
-                                       else {
-                                               $ntesize{$nb_tape} += $size{$hostpart} - $ntchunk_size;
-                                       }
+                                       $ntape = $taper_nb{$taper_name{$hostpart}};
+                                       $ntpartition{$ntape}++ if defined $ntape;
                                        if ($line[6] eq "PARTIAL") {
                                                $partial{$hostpart} = 1;
+                                               if ($line[9] eq "TAPE-ERROR") {
+                                                       $error{$hostpart} = "taper: $line[12]";
+                                                       $taper_error{$hostpart} = "taper: $line[12]";
+                                               }
                                        }
                                        else {
                                                $partial{$hostpart} = 0;
                                        }
-                                       if ($ntchunk_size > 0) {
-                                               $ntchunk{$nb_tape}++;
-                                       }
+                                       undef $taper_status_file{$hostpart};
+                                       undef $worker_to_serial{$taper_name{$hostpart}};
                                }
                                elsif($line[6] eq "PARTDONE") {
                                        #7:handle 8:label 9:filenum 10:ksize 11:errstr
@@ -570,56 +690,77 @@ while($lineX = <AMDUMP>) {
                                        #$size=$1 / $unitdivisor;
                                        $size=$line[10] / $unitdivisor;
                                        $tapedsize{$hostpart} += $size;
-                                       $ntchunk{$nb_tape}++;
-                                       $ntsize{$nb_tape} += $size;
-                                       $ntesize{$nb_tape} += $size;
-                                       $ntchunk_size += $size;
+                                       $ntape = $taper_nb{$taper_name{$hostpart}};
+                                       $ntchunk{$ntape}++;
+                                       $ntsize{$ntape} += $size;
+                                       $ntesize{$ntape} += $size;
                                }
                                elsif($line[6] eq "REQUEST-NEW-TAPE") {
                                        #7:serial
                                        $serial=$line[7];
+                                       $old_status_taper = $status_taper;
+                                       $status_taper = "Asking for a new tape";
                                        $hostpart=$serial{$serial};
-                                       if (defined $hostpart) {
+                                       if (defined $hostpart and
+                                               !defined($olderror{$hostpart})) {
+                                               $olderror{$hostpart} = $error{$hostpart};
                                                $error{$hostpart} = "waiting for a new tape";
                                        }
                                }
                                elsif($line[6] eq "NEW-TAPE") {
                                        #7:serial #8:label
                                        $serial=$line[7];
+                                       $status_taper = $old_status_taper;
                                        $hostpart=$serial{$serial};
+                                       $nb_tape++;
+                                       $taper_nb{$taper_name{$hostpart}} = $nb_tape;
+                                       $label = $line[8];
+                                       $ntlabel{$nb_tape} = $label;
+                                       $ntpartition{$nb_tape} = 0;
+                                       $ntsize{$nb_tape} = 0;
+                                       $ntesize{$nb_tape} = 0;
                                        if (defined $hostpart) {
-                                               $error{$hostpart} = "";
+                                               $error{$hostpart} = $olderror{$hostpart};
                                        }
                                }
-                               elsif($line[6] eq "TRY-AGAIN" || $line[6] eq "TAPE-ERROR") {
-                                       #7:handle 8:errstr
-                                       $serial=$line[7];
+                               elsif($line[6] eq "TAPER-OK") {
+                                       #7:name #8:label
+                                       $status_taper = "Idle";
+                               }
+                               elsif($line[6] eq "TAPE-ERROR") {
+                                       #7:name 8:errstr
                                        $error=$line[8];
-                                       $hostpart=$serial{$serial};
-                                       if(defined $hostpart) {
-                                               $taper_finished{$hostpart}= $line[6] eq 'TAPE-ERROR' ? -2 : -1;
-                                               $busy_time{"taper"}+=($current_time-$taper_time{$hostpart});
-                                               $taper_time{$hostpart}=$current_time;
-                                               $error{$hostpart}="taper: $error";
-                                       }
+                                       $status_taper = $error;
+                                       $exit_status |= $STATUS_TAPE;
+                                       undef $taper_status_file{$hostpart};
                                }
                                elsif($line[6] eq "FAILED") {
                                        #7:handle 8:INPUT- 9:TAPE- 10:input_message 11:tape_message
-                                  $serial=$line[7];
+                                       $serial=$line[7];
                                        $hostpart=$serial{$serial};
                                        if(defined $hostpart) {
                                                if($line[9] eq "TAPE-ERROR") {
                                                        $error=$line[11];
                                                        $taper_finished{$hostpart} = -2;
-                                               }
-                                               else {
-                                                       $error=$line[10];
+                                                       $status_taper = $error;
+                                               } elsif($line[9] eq "TAPE-CONFIG") {
+                                                       $tape_config{$hostpart} = $error;
+                                                       $error=$line[11];
+                                                       $tape_config{$hostpart} = $error;
+                                                       $taper_finished{$hostpart} = -2;
+                                                       $status_taper = $error;
+                                               } else { # INPUT-ERROR
+                                                       $error = $line[10];
+                                                       $error = $error{$hostpart} if defined $error{$hostpart};
                                                        $taper_finished{$hostpart} = -1;
+                                                       $status_taper = "Idle";
                                                }
                                                $busy_time{"taper"}+=($current_time-$taper_time{$hostpart});
                                                $taper_time{$hostpart}=$current_time;
                                                $error{$hostpart}="$error";
                                        }
+                                       undef $taper_status_file{$hostpart};
+                                       undef $worker_to_serial{$taper_name{$hostpart}};
                                }
                        }
                }
@@ -647,7 +788,6 @@ while($lineX = <AMDUMP>) {
                elsif($line[1] eq "state" && $line[2] eq "time") {
                        #3:time 4:"free" 5:"kps" 6:free 7:"space" 8:space 9:"taper" 10:taper 11:"idle-dumpers" 12:idle-dumpers 13:"qlen" 14:"tapeq" 15:tapeq 16:"runq" 17:runq 18:"roomq" 19:roomq 20:"wakeup" 21:wakeup 22:"driver-idle" 23:driver-idle
                        $current_time=$line[3];
-                       $status_taper=$line[10];
                        $idle_dumpers=$line[12];
 
                        $free{"kps"} = $line[6];
@@ -665,13 +805,13 @@ while($lineX = <AMDUMP>) {
                                }
                                $state_time_prev=$current_time;
                                $dumpers_active_prev=$dumpers_active;
-                               $status_driver=$line[16];
+                               $status_driver=$line[23];
                                if(! defined($dumpers_held[$dumpers_active]{$status_driver})) {
                                        $dumpers_held[$dumpers_active]{$status_driver}=0;
                                }
                        }
                }
-          elsif($line[1] eq "FINISHED") {
+               elsif($line[1] eq "FINISHED") {
                        $driver_finished = 1;
                }
        }
@@ -687,28 +827,26 @@ while($lineX = <AMDUMP>) {
                }
        }
        elsif($line[0] eq "taper") {
-               if($line[1] eq "slot") {
-                       #2:slot 3:"wrote" 4:"label" 5:corrupted...
-                       $nb_tape++;
-                       $lineX =~ /wrote label `(\S*)'/;
-                       $label = $1;
-                       $ntlabel{$nb_tape} = $label;
-                       $ntpartition{$nb_tape} = 0;
-                       $ntsize{$nb_tape} = 0;
-                       $ntesize{$nb_tape} = 0;
+               if($line[1] eq "wrote") {
+                       #1:"wrote" 2:"label" 3:label
+                       #$nb_tape++;
+                       #$label = $line[3];
+                       #$ntlabel{$nb_tape} = $label;
+                       #$ntpartition{$nb_tape} = 0;
+                       #$ntsize{$nb_tape} = 0;
+                       #$ntesize{$nb_tape} = 0;
                }
-               elsif($line[1] eq "wrote") {
-                       #1:"wrote" 2:"label" 3:corrupted
-                       $nb_tape++;
-                       $lineX =~ /wrote label `(\S*)'/;
-                       $label = $1;
-                       $ntlabel{$nb_tape} = $label;
-                       $ntpartition{$nb_tape} = 0;
-                       $ntsize{$nb_tape} = 0;
-                       $ntesize{$nb_tape} = 0;
+               elsif($line[1] eq "status" && $line[2] eq "file") {
+                       #1:"status" #2:"file:" #3:hostname #4:diskname #5:filename
+                       #$host = $line[3];
+                       #$partition = $line[4];
+                       #Which datestamp to use?
+                       #$hostpart=&make_hostpart($host,$partition,$datestamp);
+                       #assume $hostpart is already set.
+                       $taper_status_file{$hostpart} = $line[5];
                }
        }
-   elsif($line[0] eq "splitting" &&
+       elsif($line[0] eq "splitting" &&
                         $line[1] eq "chunk" &&
                         $line[2] eq "that" &&
                         $line[3] eq "started" &&
@@ -717,9 +855,8 @@ while($lineX = <AMDUMP>) {
                $line[7] =~ /(\d*)kb/;
                $size = $1;
                $ntchunk{$nb_tape}++;
-          $ntsize{$nb_tape} += $size / $unitdivisor;
+               $ntsize{$nb_tape} += $size / $unitdivisor;
                $ntesize{$nb_tape} += $size / $unitdivisor;
-               $ntchunk_size += $size / $unitdivisor;
        }
        else {
                #print "Ignoring: $lineX\n";
@@ -791,6 +928,7 @@ foreach $host (sort @hosts) {
 
 foreach $host (sort @hosts) {
        foreach $partition (sort @$host) {
+          $qpartition = Amanda::Util::quote_string($partition);
           foreach $datestamp (sort @datestamp) {
                        $hostpart=&make_hostpart($host,$partition,$datestamp);
                        next if(!defined $estimate{$hostpart} && !defined $flush{$hostpart});
@@ -803,20 +941,31 @@ foreach $host (sort @hosts) {
                        if($estimate_done != 1 && !defined $flush{$hostpart}) {
                                if(defined $estimate{$hostpart}) {
                                        if($estimate{$hostpart} != 1) {
-                                               if( defined $opt_gestimate) {
+                                               if( defined $opt_gestimate ||
+                                                        defined $opt_failed && $dead_run != 0) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s", "$host:$partition";
-                                                       print "              getting estimate\n";
+                                                       printf "%-${maxnamelength}s", "$host:$qpartition";
+                                                       print "             ";
+                                                       if ($dead_run) {
+                                                               print " failed: killed while";
+                                                               $exit_status |= $STATUS_FAILED;
+                                                       }
+                                                       print " getting estimate\n";
                                                }
                                        }
                                        else {
                                                if(defined $opt_estimate ||
-                                                       (defined $opt_gestimate && $partialestimate{$hostpart} == 1)) {
+                                                       (defined $opt_gestimate && $partialestimate{$hostpart} == 1) ||
+                                                       (defined $opt_failed && $dead_run != 0 && $partialestimate{$hostpart} == 1)) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s", "$host:$partition";
+                                                       printf "%-${maxnamelength}s", "$host:$qpartition";
                                                        printf "%2d ",  $level{$hostpart};
                                                        printf "%9d$unit", $esize{$hostpart};
                                                        if($partialestimate{$hostpart} == 1) {
+                                                               if ($dead_run) {
+                                                                       print " failed: killed while";
+                                                                       $exit_status |= $STATUS_FAILED;
+                                                               }
                                                                print " partial";
                                                        }
                                                        print " estimate done\n";
@@ -835,7 +984,7 @@ foreach $host (sort @hosts) {
                                        elsif (!defined $dump_started{$hostpart} || $dump_started{$hostpart} == 0) {
                                                if( defined $opt_failed) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "           no estimate\n";
                                                }
                                                $exit_status |= $STATUS_FAILED;
@@ -850,22 +999,12 @@ foreach $host (sort @hosts) {
                                }
                                if(defined $taper_started{$hostpart} &&
                                                $taper_started{$hostpart}==1) {
-                                       if(defined $dump_started{$hostpart}) {
-                                               $dpartition++;
-                                               if(defined($size{$hostpart})) {
-                                                       $dsize += $size{$hostpart};
-                                               }
-                                               else {
-                                                       $dsize += $esize{$hostpart};
-                                               }
-                                               $desize += $esize{$hostpart};
-                                       }
                                        if(defined $dump_started{$hostpart} &&
-                                               $dump_started{$hostpart} == 1 &&
+                                               $dump_started{$hostpart} == 1 &&
                                                        $dump_finished{$hostpart} == -1) {
                                                if(defined $opt_failed) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $esize{$hostpart};
                                                        print " dump to tape failed: " . $error{$hostpart};
                                                        print "\n";
@@ -874,14 +1013,36 @@ foreach $host (sort @hosts) {
                                                $fpartition++;
                                                $fsize+=$esize{$hostpart};
                                        } elsif(defined $dump_started{$hostpart} &&
-                                               $dump_started{$hostpart} == 1 &&
+                                               $dump_started{$hostpart} == 1 &&
                                                        $dump_finished{$hostpart} == 0 &&
                                                        $taper_started{$hostpart} == 1) {
-                                               if( defined $opt_dumpingtape ) {
+                                               if( defined $opt_dumpingtape ||
+                                                        defined $opt_failed && $dead_run != 0) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $esize{$hostpart};
+                                                       if ($dead_run) {
+                                                               print " failed: killed while";
+                                                               $exit_status |= $STATUS_FAILED;
+                                                       }
                                                        print " dumping to tape";
+                                                       $size = $tapedsize{$hostpart};
+                                                       if ($taper_status_file{$hostpart} && -f $taper_status_file{$hostpart} &&
+                                                               open FF, "<$taper_status_file{$hostpart}") {
+                                                               $line = <FF>;
+                                                               if (defined $line) {
+                                                                       chomp $line;
+                                                                       $value = $line / ($unitdivisor * 1024);
+                                                                       if ($value) {
+                                                                               $size = $value if (!defined($size) || $value > $size);
+                                                                       }
+                                                               }
+                                                               close FF;
+                                                       }
+                                                       if(defined($size)) {
+                                                               printf " (%d$unit done (%0.2f%%))", $size, 100.0 * $size/$esize{$hostpart};
+                                                               $dtsize += $size;
+                                                       }
                                                        if( defined $starttime ) {
                                                                print " (", &showtime($taper_time{$hostpart}), ")";
                                                        }
@@ -891,24 +1052,54 @@ foreach $host (sort @hosts) {
                                                $dtesize += $esize{$hostpart};
                                        }
                                        elsif($taper_finished{$hostpart} == 0) {
-                                               if( defined $opt_writingtape ) {
+                                               if( defined $opt_writingtape ||
+                                                        defined $opt_failed && $dead_run != 0) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $size{$hostpart};
+                                                       if ($dead_run) {
+                                                               print " failed: killed while";
+                                                               $exit_status |= $STATUS_FAILED;
+                                                       }
                                                        if($in_flush == 0) {
+                                                               if (defined $dump_finished{$hostpart}) {
+                                                                       if ($dump_finished{$hostpart} == 1) {
+                                                                               print " dump done,";
+                                                                       } else {
+                                                                               $exit_status |= $STATUS_FAILED;
+                                                                               print " dump failed: ", $error{$hostpart}, ",";
+                                                                               $fpartition++;
+                                                                               $fsize+=$esize{$hostpart};
+                                                                       }
+                                                               }
                                                                print " writing to tape";
                                                        }
                                                        else {
                                                                print " flushing to tape";
                                                        }
-                                                       if(defined($tapedsize{$hostpart})) {
-                                                               printf " (%d$unit done)", $tapedsize{$hostpart};
+                                                       $size = $tapedsize{$hostpart};
+                                                       if ($taper_status_file{$hostpart} &&  -f $taper_status_file{$hostpart} &&
+                                                               open FF, "<$taper_status_file{$hostpart}") {
+                                                               $line = <FF>;
+                                                               if (defined $line) {
+                                                                       chomp $line;
+                                                                       $value = $line / ($unitdivisor * 1024);
+                                                                       if ($value) {
+                                                                               $size = $value if (!defined($size) || $value > $size);
+                                                                       }
+                                                               }
+                                                               close FF;
+                                                       }
+                                                       if(defined($size) and defined($size{$hostpart}) and $size{$hostpart} > 0) {
+                                                               printf " (%d$unit done (%0.2f%%))", $size, 100.0 * $size/$size{$hostpart};
                                                        }
                                                        if( defined $starttime ) {
                                                                print " (", &showtime($taper_time{$hostpart}), ")";
                                                        }
-                                                       print ", ", $error{$hostpart} if defined($error{$hostpart} &&
-                                                                                                                                          $error{$hostpart} ne "");
+                                                       print ", ", $error{$hostpart} if (defined($error{$hostpart}) &&
+                                                                                                                         $error{$hostpart} ne "" &&
+                                                                                                                         (!defined $dump_finished{$hostpart} ||
+                                                                                                                          $dump_finished{$hostpart} != -3));
                                                        print "\n";
                                                }
                                                $tapartition++;
@@ -919,6 +1110,15 @@ foreach $host (sort @hosts) {
                                                else {
                                                        $taesize += $size{$hostpart};
                                                }
+                                               if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1) {
+                                                       $dpartition++;
+                                                       $dsize += $size{$hostpart};
+                                                       if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
+                                                               $desize += $esize{$hostpart};
+                                                       } else {
+                                                               $desize += $size{$hostpart};
+                                                       }
+                                               }
                                        }
                                        elsif($taper_finished{$hostpart} < 0) {
 
@@ -942,16 +1142,25 @@ foreach $host (sort @hosts) {
                                                if( defined $opt_failed  ||
                                                         (defined $opt_waittaper && ($taper_finished{$hostpart} == -1))) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $xsize;
+                                                       print " dump done," if defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1;
                                                        if($in_flush == 0) {
-                                                               print " failed to tape";
+                                                               if ($tape_config{$hostpart}) {
+                                                                       print " taping delayed because of config";
+                                                               } else {
+                                                                       print " failed to tape";
+                                                               }
                                                        }
                                                        else {
-                                                               print " failed to flush";
+                                                               if ($tape_config{$hostpart}) {
+                                                                       print " flushing delayed because of config";
+                                                               } else {
+                                                                       print " failed to flush";
+                                                               }
                                                        }
                                                        print ": ",$error{$hostpart} if defined $error{$hostpart};
-                                               
+
                                                        print " (will retry)" unless $taper_finished{$hostpart} < -1;
                                                        if( defined $starttime ) {
                                                                print " (", &showtime($taper_time{$hostpart}), ")";
@@ -973,13 +1182,28 @@ foreach $host (sort @hosts) {
                                                        $wfpartition++;
                                                        $wfsize += $xsize;
                                                }
+                                               if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1) {
+                                                       $dpartition++;
+                                                       $dsize += $size{$hostpart};
+                                                       if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
+                                                               $desize += $esize{$hostpart};
+                                                       } else {
+                                                               $desize += $size{$hostpart};
+                                                       }
+                                               }
                                        }
                                        elsif($taper_finished{$hostpart} == 1) {
                                                if( defined $opt_finished ) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $size{$hostpart};
                                                        if($in_flush == 0) {
+                                                               if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == -3) {
+                                                                       $exit_status |= $STATUS_FAILED;
+                                                                       print " dump failed: ", $error{$hostpart}, ",";
+                                                                       $fpartition++;
+                                                                       $fsize+=$esize{$hostpart};
+                                                               }
                                                                print " finished";
                                                        }
                                                        else {
@@ -994,6 +1218,15 @@ foreach $host (sort @hosts) {
                                                        }
                                                        print "\n";
                                                }
+                                               if (defined $dump_finished{$hostpart} && $dump_finished{$hostpart} == 1) {
+                                                       $dpartition++;
+                                                       $dsize += $size{$hostpart};
+                                                       if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
+                                                               $desize += $esize{$hostpart};
+                                                       } else {
+                                                               $desize += $size{$hostpart};
+                                                       }
+                                               }
                                                $tpartition++;
                                                $tsize += $size{$hostpart};
                                                if(defined $esize{$hostpart} && $esize{$hostpart} > 1) {
@@ -1005,7 +1238,7 @@ foreach $host (sort @hosts) {
                                        }
                                        else {
                                                printf "%8s ", $datestamp if defined $opt_date;
-                                               printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                               printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                print " unknown state TAPER\n";
                                        }
                                }
@@ -1013,8 +1246,8 @@ foreach $host (sort @hosts) {
                                        if($dump_started{$hostpart} == -1) {
                                                if( defined $opt_failed ) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
-                                                       printf " " . $error{$hostpart} . "\n";
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
+                                                       printf "failed: " . $error{$hostpart} . "\n";
                                                }
                                                $exit_status |= $STATUS_FAILED;
 
@@ -1025,9 +1258,13 @@ foreach $host (sort @hosts) {
                                                if($estimate{$hostpart} == 1) {
                                                        if( defined $opt_waitdumping ) {
                                                                printf "%8s ", $datestamp if defined $opt_date;
-                                                               printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                               printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                                printf "%9d$unit", $esize{$hostpart};
-                                                               print " wait for dumping $error{$hostpart}\n";
+                                                               if ($dead_run) {
+                                                                       print " failed: process terminated while";
+                                                                       $exit_status |= $STATUS_FAILED;
+                                                               }
+                                                               print " waiting for dumping $error{$hostpart}\n";
                                                        }
                                                        if($driver_finished == 1) {
                                                                $exit_status |= $STATUS_MISSING;
@@ -1037,11 +1274,12 @@ foreach $host (sort @hosts) {
                                                }
                                        }
                                        elsif($dump_started{$hostpart} == 1 &&
-                                                       $dump_finished{$hostpart} == -1) {
+                                                       ($dump_finished{$hostpart} == -1 ||
+                                                   $dump_finished{$hostpart} == -3)) {
                                                if( defined $opt_failed ) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
-                                                       print " ", $error{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
+                                                       print "backup failed: ", $error{$hostpart};
                                                        if( defined $starttime ) {
                                                                print " (", &showtime($dump_time{$hostpart}), ")";
                                                        }
@@ -1052,11 +1290,16 @@ foreach $host (sort @hosts) {
                                                $fsize+=$esize{$hostpart};
                                        }
                                        elsif($dump_started{$hostpart} == 1 &&
-                                                       $dump_finished{$hostpart} != 1) {
-                                               if( defined $opt_dumping ) {
+                                                       $dump_finished{$hostpart} == 0) {
+                                               if( defined $opt_dumping ||
+                                                        defined $opt_failed && $dead_run != 0) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $esize{$hostpart};
+                                                       if ($dead_run) {
+                                                               print " failed: killed while";
+                                                               $exit_status |= $STATUS_FAILED;
+                                                       }
                                                        printf " dumping %8d$unit", $size{$hostpart};
                                                        if($size{$hostpart} != 0) {
                                                                printf " (%6.2f%%)", (100.0*$size{$hostpart})/$esize{$hostpart};
@@ -1077,13 +1320,17 @@ foreach $host (sort @hosts) {
                                                        $taper_started{$hostpart} != 1) {
                                                if( defined $opt_waittaper ) {
                                                        printf "%8s ", $datestamp if defined $opt_date;
-                                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                        printf "%9d$unit", $size{$hostpart};
                                                        print " dump done";
                                                        if( defined $starttime ) {
                                                                print " (", &showtime($dump_time{$hostpart}), ")";
                                                        }
-                                                       print ", wait for writing to tape";
+                                                       print ",";
+                                                       if ($dead_run) {
+                                                               print " process terminated while";
+                                                       }
+                                                       print " waiting for writing to tape";
                                                        if(defined $partial{$hostpart} && $partial{$hostpart} == 1) {
                                                                print ", PARTIAL";
                                                                $exit_status |= $STATUS_FAILED;
@@ -1099,15 +1346,18 @@ foreach $host (sort @hosts) {
                                        }
                                        else {
                                                printf "%8s ", $datestamp if defined $opt_date;
-                                               printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                               printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                print " unknown state DUMPER\n";
                                        }
                                }
                                elsif(defined $flush{$hostpart}) {
                                        if( defined $opt_waittaper ) {
                                                printf "%8s ", $datestamp if defined $opt_date;
-                                               printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                               printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                                printf "%9d$unit", $size{$hostpart};
+                                               if ($dead_run) {
+                                                       print " process terminated while";
+                                               }
                                                print " waiting to flush";
                                                if(defined $partial{$hostpart} && $partial{$hostpart} == 1) {
                                                        print ", PARTIAL";
@@ -1120,7 +1370,7 @@ foreach $host (sort @hosts) {
                                }
                                elsif(defined $level{$hostpart}) {
                                        printf "%8s ", $datestamp if defined $opt_date;
-                                       printf "%-${maxnamelength}s%2d ", "$host:$partition", $level{$hostpart};
+                                       printf "%-${maxnamelength}s%2d ", "$host:$qpartition", $level{$hostpart};
                                        print " unknown state\n";
                                }
                        }
@@ -1141,9 +1391,16 @@ if (defined $opt_summary) {
        printf "wait for dumping: %3d %20d$unit           (%6.2f%%)\n",
                $wpartition , $wsize,
                $estsize ? ($wsize * 1.0 / $estsize) * 100 : 0.0;
-       printf "dumping to tape : %3d %20d$unit           (%6.2f%%)\n",
-               $dtpartition, $dtesize,
-               $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
+       if(defined($dtsize)) {
+               printf "dumping to tape : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
+                       $dtpartition, $dtsize, $dtesize,
+                       $dtsize ? ($dtsize * 1.0 / $dtesize) * 100 : 0.0,
+                       $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
+       } else {
+               printf "dumping to tape : %3d %20d$unit           (%6.2f%%)\n",
+                       $dtpartition, $dtesize,
+                       $estsize ? ($dtesize * 1.0 / $estsize) * 100 : 0.0;
+       }
        printf "dumping         : %3d %9d$unit %9d$unit (%6.2f%%) (%6.2f%%)\n",
                $dupartition, $dusize, $duesize,
                $duesize ? ($dusize * 1.0 / $duesize) * 100 : 0.0,
@@ -1195,22 +1452,21 @@ if (defined $opt_summary) {
                $c3 = ($idle_dumpers == 1) ? " " : "";
                printf "%d dumper%s idle%s %s: %s\n", $idle_dumpers, $c1, $c2, $c3, $status_driver;
        }
-       if($status_taper eq "writing" && defined($qlen{"tapeq:"})) {
-               printf "taper writing, tapeq: %d\n", $qlen{"tapeq:"};
-       }
-       else {
-               printf "taper idle\n";
+
+       printf "taper status: $status_taper\n";
+       if (defined $qlen{"tapeq"}) {
+               printf "taper qlen: %d\n", $qlen{"tapeq"};
        }
-       if (defined ($free{"kps:"})) {
-               printf "network free kps: %9d\n", $free{"kps:"};
+       if (defined ($free{"kps"})) {
+               printf "network free kps: %9d\n", $free{"kps"};
        }
-       if (defined ($free{"space:"})) {
+       if (defined ($free{"space"})) {
                if ($holding_space) {
-                       $hs = ($free{"space:"} * 1.0 / $holding_space) * 100;
+                       $hs = ($free{"space"} * 1.0 / $holding_space) * 100;
                } else {
                        $hs = 0.0;
                }
-               printf "holding space   : %9d$unit (%6.2f%%)\n", ($free{"space:"}/$unitdivisor), $hs;
+               printf "holding space   : %9d$unit (%6.2f%%)\n", ($free{"space"}/$unitdivisor), $hs;
        }
 }
 
@@ -1397,12 +1653,29 @@ sub set_starttime() {
 
 
 sub showtime() {
-       my($delta)=shift;
-       my($oneday)=24*60*60;
+       my($delta) = shift;
+       my($oneday) = 24*60*60;
+
+       my @starttime = localtime($starttime);
+       my @now = localtime($starttime+$delta);
+       $now_yday = $now[7];
+
+       # leap year
+       if ($starttime[5] < $now[5]) {
+               my $days_in_year = 364;
+               my $startime1 = $starttime;
+               while ($startime1 < $starttime+$delta) {
+                       my @starttime1 = localtime($starttime);
+                       if ($starttime1[7] > $days_in_year) {
+                               $days_in_year = $starttime1[7];
+                       }
+                       $startime1 += $oneday;
+               }
+               $now_yday += $days_in_year+1;
+       }
 
-       @now=localtime($starttime+$delta);
-       if($delta > $oneday) {
-               $result=sprintf("%d+",$delta/$oneday);
+       if ($starttime[7] < $now_yday) {
+               $result=sprintf("%d+", $now_yday - $starttime[7]);
        } else {
                $result="";
        }
@@ -1430,10 +1703,3 @@ sub busytime() {
        return $result;
 }
 
-sub usage() {
-       print "amstatus [--config] config [--file amdump_file]\n";
-       print "         [--summary] [--dumping] [--waitdumping] [--waittaper]\n";
-       print "         [--dumpingtape] [--writingtape] [--finished] [--failed]\n";
-       print "         [--estimate] [--gestimate] [--stats] [--date] [--locale-independent-date-format]\n";
-       exit 0;
-}