comparison archivecheck.pl @ 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 30497c6a3eca
children b19df18aa19a
comparison
equal deleted inserted replaced
8:65895eec9e30 9:9c61f624d802
14 ####################################################### 14 #######################################################
15 # internal parameters 15 # internal parameters
16 # 16 #
17 17
18 # program version 18 # program version
19 my $version = "0.3 (24.9.2003)"; 19 my $version = "0.4 (30.11.2004)";
20 20
21 # read command line parameters 21 # read command line parameters
22 my $args = parseargs; 22 my $args = parseargs;
23 23
24 # debug level 24 # debug level
187 return $cnt; 187 return $cnt;
188 } 188 }
189 189
190 190
191 # 191 #
192 # $%files = run_query 192 # $archcnt = run_query($dirquery, \%files)
193 # 193 #
194 # runs the archiver program on $docdir and returns a list of archived files 194 # runs the archiver program on $dirquery and adds to the hash of archived files
195 # 195 #
196 # Sample output: 196 # Sample output:
197 # 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 197 # 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
198 # 198 #
199 sub run_query { 199 sub run_query {
200 my %files; 200 my ($dirquery, $files) = @_;
201 print LOG "START checkarchive $version ", scalar localtime, "\n"; 201 print LOG "START checkarchive $version ", scalar localtime, "\n";
202 my $archcmd = $archprog; 202 my $archcmd = $archprog;
203 $archcmd .= " query archive -subdir=yes"; 203 $archcmd .= " query archive -subdir=yes";
204 $archcmd .= " -description='$archname'"; 204 $archcmd .= " -description='$archname'";
205 $archcmd .= " '$docdir/'"; 205 $archcmd .= " '$dirquery'";
206 206
207 my $archcnt = 0; 207 my $archcnt = 0;
208 print LOG "CMD: $archcmd\n"; 208 print LOG "CMD: $archcmd\n";
209 if (open ARCH, "$archcmd 2>&1 |") { 209 if (open ARCH, "$archcmd 2>&1 |") {
210 while (<ARCH>) { 210 while (<ARCH>) {
228 my $label = $7; 228 my $label = $7;
229 $size =~ s/,//g; 229 $size =~ s/,//g;
230 $date = ymd_date($date); 230 $date = ymd_date($date);
231 logger("DEBUG", " QUERY: file '$file'"); 231 logger("DEBUG", " QUERY: file '$file'");
232 $archcnt++; 232 $archcnt++;
233 if ($files{$file}) { 233 if ($$files{$file}) {
234 logger("WARNING", "file $file seems to be archived multiple times: $time $date"); 234 logger("DEBUG", "file $file seems to be archived multiple times: $time $date");
235 $warncnt++; 235 #$warncnt++;
236 } 236 }
237 $files{$file} = [$size, "$date $time"]; 237 if (length $file <= length $docdir) {
238 logger("DEBUG", "not below document dir: $file");
239 next;
240 }
241 $$files{$file} = [$size, "$date $time"];
238 } 242 }
239 } 243 }
240 logger("INFO", "$archcnt archives of " . (scalar keys %files) . " files.");
241 } else { 244 } else {
242 logger("ABORT", "unable to start archive command '$archcmd'!!"); 245 logger("ABORT", "unable to start archive command '$archcmd'!!");
243 exit 1; 246 exit 1;
244 } 247 }
245 248
246 return \%files; 249 return $archcnt;
247 } 250 }
248 251
249 252
250 # 253 #
251 # check_files(\%files_to_archive, \%archived_files) 254 # check_files(\%files_to_archive, \%archived_files)
321 } else { 324 } else {
322 logger("ERROR", "archived file $ft still on disk"); 325 logger("ERROR", "archived file $ft still on disk");
323 $errcnt++; 326 $errcnt++;
324 } 327 }
325 } else { 328 } else {
326 logger("ERROR", "file '$ft' on disk missing from archive!"); 329 logger("ERROR", "file on disk '$ft' is not in archive!");
327 $errcnt++; 330 $errcnt++;
328 } 331 }
329 } 332 }
330 } 333 }
331 334
357 logger("WARNING", "no .archived file!"); 360 logger("WARNING", "no .archived file!");
358 $warncnt++; 361 $warncnt++;
359 } 362 }
360 363
361 # check archive 364 # check archive
362 my $archived_files = run_query; 365 my %archived_files = ();
363 366 my $archcnt = 0;
364 my $num_arch_files = (scalar keys %$archived_files); 367 if ($docdir =~ /\/mpiwg\/archive\/data\/(.*)/) {
368 # TSM needs two different paths because of historical mount points :-(
369 my $docdir1 = "/mpiwg/archive/data/";
370 $archcnt += run_query($docdir1, \%archived_files);
371 my $docdir2 = "/mpiwg/archive/";
372 $archcnt += run_query($docdir2, \%archived_files);
373 } else {
374 $archcnt += run_query("$docdir/", \%archived_files);
375 }
376 logger("INFO", "$archcnt archives of " . (scalar keys %archived_files) . " files.");
377
378 my $num_arch_files = (scalar keys %archived_files);
365 if ($num_arch_files == 0) { 379 if ($num_arch_files == 0) {
366 logger("ABORT", "no archive of this directory!!"); 380 logger("ABORT", "no archive of this directory!!");
367 exit 1; 381 exit 1;
368 } 382 }
369 logger("INFO", "$num_arch_files files archived"); 383 logger("INFO", "$num_arch_files files archived");
370 384
371 # check list of archived files 385 # check list of archived files
372 check_files($files_to_archive, $archived_files); 386 check_files($files_to_archive, \%archived_files);
373 387
374 # read files from filesystem 388 # read files from filesystem
375 my %fsfiles; 389 my %fsfiles;
376 my %fsdirs; 390 my %fsdirs;
377 my $num_fs_files = fs_read_files($docdir, "", \%fsfiles, \%fsdirs); 391 my $num_fs_files = fs_read_files($docdir, "", \%fsfiles, \%fsdirs);
378 392
379 logger("INFO", "$num_fs_files files still on disk!"); 393 logger("INFO", "$num_fs_files files still on disk!");
380 if ($num_fs_files > 0) { 394 if ($num_fs_files > 0) {
381 compare_files(\%fsfiles, $archived_files); 395 compare_files(\%fsfiles, \%archived_files);
382 } 396 }
383 397
384 logger("INFO", "$warncnt warnings"); 398 logger("INFO", "$warncnt warnings");
385 logger("INFO", "$errcnt errors"); 399 logger("INFO", "$errcnt errors");
386 if ($errcnt == 0) { 400 if ($errcnt == 0) {
387 logger("DONE", "" . (scalar keys %$archived_files) . " archived files checked"); 401 logger("DONE", "" . (scalar keys %archived_files) . " archived files OK");
388 } else { 402 } else {
389 logger("ABORT", "there were $errcnt errors!!"); 403 logger("ABORT", "there were $errcnt errors!!");
390 exit 1; 404 exit 1;
391 } 405 }