Imported Upstream version 3.3.3
[debian/amanda] / perl / Amanda / Report.pm
index 48bd05a72eb6470ec90b4f032f9b2105dea53b51..8490c94e1730363e8159a2d8b67de01833bc04e9 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (c) 2010 Zmanda, Inc.  All Rights Reserved.
+# Copyright (c) 2010-2012 Zmanda, Inc.  All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 as published
-# by the Free Software Foundation.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -510,10 +511,22 @@ sub read_line
 
     if ( $type == $L_CONT ) {
        ${$self->{nbline_ref}}++;
-       push @{$self->{contline}}, $str if ${$self->{nbline_ref}} <= 100;
+       if ($str =~ /^\|/) {
+           $self->{nb_strange}++;
+           push @{$self->{contline}}, $str if $self->{nb_strange} + $self->{nb_error} <= 100;
+       } elsif ($str =~ /^\?/) {
+           $self->{nb_error}++;
+           push @{$self->{contline}}, $str if $self->{nb_error} <= 100;
+       } else {
+           $self->{nb_normal}++;
+           push @{$self->{contline}}, $str if ${$self->{nbline_ref}} <= 100;
+       }
        return;
     }
     $self->{contline} = undef;
+    $self->{nb_normal} = 0;
+    $self->{nb_strange} = 0;
+    $self->{nb_error} = 0;
 
     if ( $prog == $P_PLANNER ) {
         return $self->_handle_planner_line( $type, $str );
@@ -790,6 +803,7 @@ sub _handle_dumper_line
         my @info = Amanda::Util::split_quoted_strings($str);
         my ( $hostname, $disk, $level ) = @info[ 0 .. 2 ];
         my ( $sec, $kb, $kps, $orig_kb ) = @info[ 4, 6, 8, 10 ];
+       $kb = int($kb/1024) if $info[4] eq 'bytes';
         $orig_kb =~ s{\]$}{};
 
         my $dle    = $disklist->{$hostname}->{$disk};
@@ -805,6 +819,9 @@ sub _handle_dumper_line
        $self->{contline} = $dumper->{stranges} ||= [];
        $dumper->{nb_stranges} = 0;
        $self->{nbline_ref} = \$dumper->{nb_stranges};
+       $self->{nb_normal} = 0;
+       $self->{nb_strange} = 0;
+       $self->{nb_error} = 0;
 
         return $self->{flags}{exit_status} |= STATUS_STRANGE
 
@@ -817,6 +834,7 @@ sub _handle_dumper_line
         my @info = Amanda::Util::split_quoted_strings($str);
         my ( $hostname, $disk, $timestamp, $level ) = @info[ 0 .. 3 ];
         my ( $sec, $kb, $kps, $orig_kb ) = @info[ 5, 7, 9, 11 ];
+       $kb = int($kb/1024) if $info[6] eq 'bytes';
         $orig_kb =~ s{\]$}{};
 
         my $dle    = $disklist->{$hostname}->{$disk};
@@ -864,6 +882,7 @@ sub _handle_chunker_line
         my @info = Amanda::Util::split_quoted_strings($str);
         my ( $hostname, $disk, $timestamp, $level ) = @info[ 0 .. 3 ];
         my ( $sec, $kb, $kps ) = @info[ 5, 7, 9 ];
+       $kb = int($kb/1024) if $info[6] eq 'bytes';
         $kps =~ s{\]$}{};
 
         my $dle     = $disklist->{$hostname}->{$disk};
@@ -930,6 +949,7 @@ sub _handle_taper_line
         my ( $currpart, $predparts ) = ( $1, $2 );
 
         my ($level, $sec, $kb, $kps, $orig_kb) = @info[ 6, 8, 10, 12, 14 ];
+       $kb = int($kb/1024) if $info[9] eq 'bytes';
         $kps =~ s{\]$}{};
         $orig_kb =~ s{\]$}{} if defined($orig_kb);
 
@@ -967,6 +987,7 @@ sub _handle_taper_line
         my @info = Amanda::Util::split_quoted_strings($str);
         my ( $hostname, $disk, $timestamp, $part_ct, $level ) = @info[ 0 .. 4 ];
         my ( $sec, $kb, $kps, $orig_kb ) = @info[ 6, 8, 10, 12 ];
+       $kb = int($kb/1024) if $info[7] eq 'bytes';
        my $error;
        if ($type == $L_PARTIAL) {
            if ($kps =~ /\]$/) {
@@ -1148,6 +1169,9 @@ sub _handle_fail_line
         $self->{contline} = $program_d->{errors} ||= [];
        $program_d->{nb_errors} = 0;
        $self->{nbline_ref} = \$program_d->{nb_errors};
+       $self->{nb_normal} = 0;
+       $self->{nb_strange} = 0;
+       $self->{nb_error} = 0;
     }
 }
 
@@ -1304,13 +1328,16 @@ sub check_missing_fail_strange
 
     foreach my $dle_entry (@dles) {
         my $alldumps = $self->get_dle_info(@$dle_entry, 'dumps');
+       my $driver = $self->get_dle_info(@$dle_entry, 'driver');
        my $planner = $self->get_dle_info(@$dle_entry, 'planner');
 
        if ($planner && $planner->{'status'} eq 'fail') {
            $self->{flags}{dump_failed} = 1;
        } elsif ($planner && $planner->{'status'} eq 'skipped') {
            # We don't want these to be counted as missing below
-       } elsif (!defined $alldumps->{$self->{'run_timestamp'}}) {
+       } elsif (!defined $alldumps->{$self->{'run_timestamp'}} and
+                !$driver and
+                !$planner) {
            $self->{flags}{results_missing} = 1;
            $self->{flags}{exit_status} |= STATUS_MISSING;
        } else {