changeset 9:9c61f624d802

fixed dsmc to work with different mount points (try a few...)
author casties
date Tue, 30 Nov 2004 13:39:51 +0100
parents 65895eec9e30
children 4417be0e2f07
files archivecheck.pl
diffstat 1 files changed, 32 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/archivecheck.pl	Tue Sep 28 14:20:26 2004 +0200
+++ b/archivecheck.pl	Tue Nov 30 13:39:51 2004 +0100
@@ -16,7 +16,7 @@
 #
 
 # program version
-my $version = "0.3 (24.9.2003)";
+my $version = "0.4 (30.11.2004)";
 
 # read command line parameters
 my $args = parseargs;
@@ -189,20 +189,20 @@
 
 
 #
-# $%files = run_query
+# $archcnt = run_query($dirquery, \%files)
 #
-# runs the archiver program on $docdir and returns a list of archived files
+# runs the archiver program on $dirquery and adds to the hash of archived files
 #
 # Sample output:
 #         20,345  B  08/06/03   17:17:02    /mpiwg/archive/data/proyectohumboldt/webb_histo_fr_01_1839/index.meta Never /mpiwg/archive/data/proyectohumboldt/webb_histo_fr_01_1839
 #
 sub run_query {
-    my %files;
+    my ($dirquery, $files) = @_;
     print LOG "START checkarchive $version ", scalar localtime, "\n";
     my $archcmd = $archprog;
     $archcmd .= " query archive -subdir=yes";
     $archcmd .= " -description='$archname'";
-    $archcmd .= " '$docdir/'";
+    $archcmd .= " '$dirquery'";
 
     my $archcnt = 0;
     print LOG "CMD: $archcmd\n";
@@ -230,20 +230,23 @@
 		$date = ymd_date($date);
 		logger("DEBUG", "  QUERY: file '$file'");
 		$archcnt++;
-		if ($files{$file}) {
-		    logger("WARNING", "file $file seems to be archived multiple times: $time $date");
-		    $warncnt++;
-		} 
-		$files{$file} = [$size, "$date $time"];
+		if ($$files{$file}) {
+		    logger("DEBUG", "file $file seems to be archived multiple times: $time $date");
+		    #$warncnt++;
+		}
+		if (length $file <= length $docdir) {
+		    logger("DEBUG", "not below document dir: $file");
+		    next;
+		}
+		$$files{$file} = [$size, "$date $time"];
 	    }
 	}
-	logger("INFO", "$archcnt archives of " . (scalar keys %files) . " files.");
     } else {
 	logger("ABORT", "unable to start archive command '$archcmd'!!");
 	exit 1;
     }
 
-    return \%files;
+    return $archcnt;
 }
 
 
@@ -323,7 +326,7 @@
 		$errcnt++;
 	    }
 	} else {
-	    logger("ERROR", "file '$ft' on disk missing from archive!");
+	    logger("ERROR", "file on disk '$ft' is not in archive!");
 	    $errcnt++;
 	}
     }
@@ -359,9 +362,20 @@
 }
 
 # check archive
-my $archived_files = run_query;
+my %archived_files = ();
+my $archcnt = 0;
+if ($docdir =~ /\/mpiwg\/archive\/data\/(.*)/) {
+    # TSM needs two different paths because of historical mount points :-(
+    my $docdir1 = "/mpiwg/archive/data/";
+    $archcnt += run_query($docdir1, \%archived_files);
+    my $docdir2 = "/mpiwg/archive/";
+    $archcnt += run_query($docdir2, \%archived_files);
+} else {
+    $archcnt += run_query("$docdir/", \%archived_files);
+}
+logger("INFO", "$archcnt archives of " . (scalar keys %archived_files) . " files.");
 
-my $num_arch_files = (scalar keys %$archived_files);
+my $num_arch_files = (scalar keys %archived_files);
 if ($num_arch_files == 0) {
     logger("ABORT", "no archive of this directory!!");
     exit 1;
@@ -369,7 +383,7 @@
 logger("INFO", "$num_arch_files files archived");
 
 # check list of archived files
-check_files($files_to_archive, $archived_files);
+check_files($files_to_archive, \%archived_files);
 
 # read files from filesystem
 my %fsfiles;
@@ -378,13 +392,13 @@
 
 logger("INFO", "$num_fs_files files still on disk!");
 if ($num_fs_files > 0) {
-    compare_files(\%fsfiles, $archived_files);
+    compare_files(\%fsfiles, \%archived_files);
 }
 
 logger("INFO", "$warncnt warnings");
 logger("INFO", "$errcnt errors");
 if ($errcnt == 0) {
-    logger("DONE", "" . (scalar keys %$archived_files) . " archived files checked");
+    logger("DONE", "" . (scalar keys %archived_files) . " archived files OK");
 } else {
     logger("ABORT", "there were $errcnt errors!!");
     exit 1;