version 1.1.1.1, 2004/06/17 15:58:42
|
version 1.6, 2007/03/21 14:21:01
|
Line 16 $|=1;
|
Line 16 $|=1;
|
# |
# |
|
|
# program version |
# program version |
my $version = "0.3 (24.9.2003)"; |
my $version = "0.4.3 (21.3.2007 ROC)"; |
|
|
# read command line parameters |
# read command line parameters |
my $args = parseargs; |
my $args = parseargs; |
Line 29 my $namespace = "";
|
Line 29 my $namespace = "";
|
|
|
# archive name (archive-path element, usually == $docdir) |
# archive name (archive-path element, usually == $docdir) |
my $archname; |
my $archname; |
# archive storage date |
|
my $archdate; |
|
|
|
|
|
####################################################### |
####################################################### |
Line 126 sub read_resource_meta {
|
Line 124 sub read_resource_meta {
|
my $name = sstrip($fn->findvalue('child::name')); |
my $name = sstrip($fn->findvalue('child::name')); |
my $path = sstrip($fn->findvalue('child::path')); |
my $path = sstrip($fn->findvalue('child::path')); |
logger("DEBUG", "DIR: ($path)$name"); |
logger("DEBUG", "DIR: ($path)$name"); |
my $f = ($path) ? "$path/$name" : "$name"; |
my $f = "$name"; |
|
if (($path)&&($path ne '.')) { |
|
$f = "$path/$name"; |
|
} |
$files{$f} = [$name]; |
$files{$f} = [$name]; |
} |
} |
|
|
Line 189 sub fs_read_files {
|
Line 190 sub fs_read_files {
|
|
|
|
|
# |
# |
# $%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: |
# 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 |
# 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 { |
sub run_query { |
my %files; |
my ($dirquery, $files) = @_; |
print LOG "START checkarchive $version ", scalar localtime, "\n"; |
print LOG "START checkarchive $version ", scalar localtime, "\n"; |
my $archcmd = $archprog; |
my $archcmd = $archprog; |
$archcmd .= " query archive -subdir=yes"; |
$archcmd .= " query archive -subdir=yes"; |
$archcmd .= " -description='$archname'"; |
$archcmd .= " -description='$archname'"; |
$archcmd .= " '$docdir/'"; |
$archcmd .= " '$dirquery'"; |
|
|
|
logger('INFO', "querying TSM server for $dirquery, please wait..."); |
my $archcnt = 0; |
my $archcnt = 0; |
print LOG "CMD: $archcmd\n"; |
print LOG "CMD: $archcmd\n"; |
if (open ARCH, "$archcmd 2>&1 |") { |
if (open ARCH, "$archcmd 2>&1 |") { |
Line 230 sub run_query {
|
Line 232 sub run_query {
|
$date = ymd_date($date); |
$date = ymd_date($date); |
logger("DEBUG", " QUERY: file '$file'"); |
logger("DEBUG", " QUERY: file '$file'"); |
$archcnt++; |
$archcnt++; |
if ($files{$file}) { |
if ($$files{$file}) { |
logger("WARNING", "file $file seems to be archived multiple times: $time $date"); |
logger("DEBUG", "file $file seems to be archived multiple times: $time $date"); |
$warncnt++; |
#$warncnt++; |
|
} |
|
if (length $file <= length $docdir) { |
|
logger("DEBUG", "not below document dir: $file"); |
|
next; |
} |
} |
$files{$file} = [$size, "$date $time"]; |
$$files{$file} = [$size, "$date $time"]; |
} |
} |
} |
} |
logger("INFO", "$archcnt archives of " . (scalar keys %files) . " files."); |
|
} else { |
} else { |
logger("ABORT", "unable to start archive command '$archcmd'!!"); |
logger("ABORT", "unable to start archive command '$archcmd'!!"); |
exit 1; |
exit 1; |
} |
} |
|
|
return \%files; |
return $archcnt; |
} |
} |
|
|
|
|
Line 319 sub compare_files {
|
Line 324 sub compare_files {
|
logger("ERROR", "archived $ft ($atime) is older than file on disk ($ftime)!"); |
logger("ERROR", "archived $ft ($atime) is older than file on disk ($ftime)!"); |
$errcnt++; |
$errcnt++; |
} else { |
} else { |
logger("ERROR", "archived file $ft still on disk"); |
logger("WARNING", "archived file $ft still on disk"); |
$errcnt++; |
$warncnt++; |
} |
} |
} else { |
} else { |
logger("ERROR", "file '$ft' on disk missing from archive!"); |
logger("ERROR", "file on disk '$ft' is not in archive!"); |
$errcnt++; |
$errcnt++; |
} |
} |
} |
} |
Line 339 logger("INFO", "archivecheck $version");
|
Line 344 logger("INFO", "archivecheck $version");
|
|
|
# make shure the right user is running this program |
# make shure the right user is running this program |
my $user = getlogin; |
my $user = getlogin; |
if (($user ne "archive")&&($user ne "root")) { |
if (not (($user eq "archive")||($user eq "root"))) { |
logger("ABORT", "you must be archive or root user to run this program!"); |
logger("ABORT", "you must be archive or root user to run this program!"); |
exit 1; |
exit 1; |
} |
} |
Line 359 if (-f "$docdir/.archived") {
|
Line 364 if (-f "$docdir/.archived") {
|
} |
} |
|
|
# check archive |
# 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) { |
if ($num_arch_files == 0) { |
logger("ABORT", "no archive of this directory!!"); |
logger("ABORT", "no archive of this directory!!"); |
exit 1; |
exit 1; |
Line 369 if ($num_arch_files == 0) {
|
Line 385 if ($num_arch_files == 0) {
|
logger("INFO", "$num_arch_files files archived"); |
logger("INFO", "$num_arch_files files archived"); |
|
|
# check list of archived files |
# check list of archived files |
check_files($files_to_archive, $archived_files); |
check_files($files_to_archive, \%archived_files); |
|
|
# read files from filesystem |
# read files from filesystem |
my %fsfiles; |
my %fsfiles; |
Line 378 my $num_fs_files = fs_read_files($docdir
|
Line 394 my $num_fs_files = fs_read_files($docdir
|
|
|
logger("INFO", "$num_fs_files files still on disk!"); |
logger("INFO", "$num_fs_files files still on disk!"); |
if ($num_fs_files > 0) { |
if ($num_fs_files > 0) { |
compare_files(\%fsfiles, $archived_files); |
compare_files(\%fsfiles, \%archived_files); |
} |
} |
|
|
logger("INFO", "$warncnt warnings"); |
logger("INFO", "$warncnt warnings"); |
logger("INFO", "$errcnt errors"); |
logger("INFO", "$errcnt errors"); |
if ($errcnt == 0) { |
if ($errcnt == 0) { |
logger("DONE", "" . (scalar keys %$archived_files) . " archived files checked"); |
logger("DONE", "" . (scalar keys %archived_files) . " archived files OK"); |
|
exit 0; |
} else { |
} else { |
logger("ABORT", "there were $errcnt errors!!"); |
logger("ABORT", "there were $errcnt errors!!"); |
exit 1; |
exit 1; |