#! /usr/local/bin/perl # Set our timezone use Time::Local; require ("/mecca/factoids/focus_systems.pm"); $ENV{TZ} = "CST6CDT"; $meccadir = "/edata1/mecca/"; $skim1dir = "/skim1/"; $factoidir = $meccadir."factoids/"; $whymedb = $factoidir."whyme_log.db"; $factoidsdb = $factoidir."factoids.db"; $submitdb = $factoidir."submissions.db"; $damagedb = $factoidir."damage.db"; $skim1db = $skim1dir."wrprt/skim1.db"; $whyweb = "http://www-focus.fnal.gov/cgi-bin/home/www/eltiempo/whyme_all.pl\?ReqRun="; $meccaweb = "http://www-focus.fnal.gov/cgi-bin/home/www/mecca/MeccaRange.pl"; $query_string = $ENV{QUERY_STRING}; @pairs = split (/&/, $query_string); foreach $pair ( @pairs ) { ($key, $value ) = split ( /=/, $pair ); $form_key{$key} = $value; } print "Content-type: text/html \n"; print "\n"; #End of HTTP header, now start the page $begrun = $form_key{begrun}; if (grep /\D/,$begrun) { print "Run numbers must be digits. \n"; die; } $endrun = $form_key{endrun}; if (grep /\D/,$endrun) { print "Run numbers must be digits. \n"; die; } if ($endrun>14999 || $begrun<5000 || $endrun<$begrun) { print "Invalid run number range. \n"; die; } if ($endrun-$begrun > 200 ) { print "Run range is too long. Use intervals of 200 runs or less.\n"; die; } # Open WhyMe database and save all relevant lines open WHYME,$whymedb; foreach $line () { ($run,$tape) = split /:/,$line; if ($run >= $begrun && $run <= $endrun) { unless($whyme_tape{$tape}) { @whyme_lines[$run] = $line; } } elsif($run > $endrun) { last; } if($run >= $begrun - 10) { $whyme_tape{$tape} = 1; } } close WHYME; # Open submission database and save all relevant lines open SUBMIT,$submitdb; foreach $line () { chop $line; $line =~ s/\s//g; ($subtape,$subtime,$subsystem,$subjob) = split /:/,$line; if(time-$subtime < 259200) { $subtape =~ tr/a-z/A-Z/; $subrun = "Unknown"; for($run=$begrun; $run < $endrun+1; $run++) { if($whyme_lines[$run]) { ($whyrun,$whytape) = split /:/,$whyme_lines[$run]; if ($subtape eq $whytape) { $subrun = $whyrun; last; } } } $run = $subrun; if ($run >= $begrun && $run <= $endrun) { $submit_line = join ':',$subrun,$subtape,$subtime,$subsystem,$subjob; @submit_lines[$run] = $submit_line; } } } close SUBMIT; # Open factoids database and save all relevant lines open FACTOIDS,$factoidsdb; foreach $line () { $line =~ s/\n//; ($run,$pint) = split /:/,$line; if ($run >= $begrun && $run <= $endrun) { if($pint ne "a" and !$pass) { @factoids_lines[$run] = $line; $pass = $pint; $pass = unpack("C", $pass) - 96; } if($pass) { $pass -= 1; next; } @factoids_lines[$run] = $line; } } close FACTOIDS; # Open the damaged tapes database and save relevant lines. # Open Skim1 database, figure out Skim1 status for each run open SKIM1,$skim1db; foreach $line () { $line =~ s/\n//; ($skrun,$junk,$junk,$junk,$junk,$junk,$junk,$junk,$junk,$junk,$stat1,$stat2) = split /:/,$line; $skrun = int $skrun; # print "$skrun \n"; if ($skrun >= $begrun && $skrun <= $endrun) { $skim1_stat{$skrun} = ($stat1 || $stat2); } } close SKIM1; # Begin the Web page print "Mecca info for Runs $begrun to $endrun \n"; print ""; print "

\n"; print " \n"; print "

Runs in Range $begrun to $endrun

\n"; print "

\n"; print "
\n"; print "Pass1 Status Key
\n"; print "N = Not yet submitted to any queue.
\n"; print "S = Currently in the queue.
\n"; print "D = Completed without any errors.
\n"; print "P = Completed with one or more non-fatal errors.
\n"; print "E = Terminated with one or more fatal errors.
\n"; print "R = Must be resubmitted.
\n"; print "
    \n"; print " \n"; print "Skim1 Status Key
\n"; print "U = Not yet skimmed.
\n"; print "K = Skimmed.
\n"; print "
\n"; print "help\n"; print "
\n"; print "
\n"; print ""; print "\n"; print ""; print "\n"; for($run=$begrun; $run < $endrun+1; $run++) { if ($skim1_stat{$run}) { $code = "K" } else { $code = "U" } $hilink = $run + 10; $lolink = $run - 10; $skim1link = ""; print ""; print "\n"; } elsif (!$factoids_lines[$run]) { ($subrun,$subtape,$subtime,$subsystem,$subjob) = split /:/,$submit_lines[$run]; ($sec,$min,$hour,$mday,$mon,$year) = localtime($subtime); $month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon]; if ($min < 10) {$min = "0".$min} if ($sec < 10) {$sec = "0".$sec} print ""; print ""; print ""; print ""; print "\n"; } } } print "
Run #"; print "Iter."; print "Vers."; print "Tape #"; print "Events"; print "Job #"; print "Status
Pass1
Skim1"; print "
More Information
ProcessedWritten$code"; if($whyme_lines[$run]) { ($whyrun,$whytape,$beam,$whyevents,$spill,$mastergate) = split /:/,$whyme_lines[$run]; if (!$factoids_lines[$run] && !$submit_lines[$run]) { print "
$run"; print "

"; print "
$whytape"; print "$whyevents
"; print "
N $skim1link"; $run =~ s/^0//; print "$mastergate
$run"; print "

"; print "
$subtape"; print "$whyevents"; print "", "$farm_letter{$subsystem} $subjob"; print "S$skim1link"; print "$mday-$month $hour:$min"; print "\n"; } else { ($subrun,$subtape,$subtime,$subsystem) = split /:/,$submit_lines[$run]; ($factoidsrun,$iteration,$tape,$events,$complete,$logok,$oddok, $start_time,$end_time,$cputime,$version,$platform,$junk1,$junk2, $evtswt,$system,$job) = split /:/,$factoids_lines[$run]; if(!$version) { $version = "N/A"; } if(!$tape) { $tape = "N/A"; } ($eyear,$emonth,$eday,$ehour,$eminute,$esecond) = split /-/,$end_time; ($syear,$smonth,$sday,$shour,$sminute,$ssecond) = split /-/,$start_time; if ($emonth > 0) {--$emonth} if ($smonth > 0) {--$smonth} if ($eyear > 1900) {$eyear = $eyear - 1900} if ($syear > 1900) {$syear = $syear - 1900} if ($end_time ne "-----") { $nend_time = timelocal($esecond,$eminute,$ehour,$eday,$emonth,$eyear); } else { $nend_time = 0 } if ($start_time ne "-----") { $nstart_time = timelocal($ssecond,$sminute,$shour,$sday,$smonth,$syear); } else { $nstart_time = 0 } if ($system && $job) { $job_link = ""; $job_link .= "$farm_letter{$system} $job"; } else { $job_link = "N/A"; } $runtime = "N/A"; if ($nstart_time && $nend_time) { $runtime = sprintf "%5.2f",($nend_time - $nstart_time) / 3600.0; } $itlink = "$iteration"; $tape =~ tr/a-z/A-Z/; $tapelink = "$tape"; if ($complete == 1) { $complink = "D" } elsif($complete == 2 || $complete == 3) { $complink = "P" } elsif($complete == 4 || $complete == 5) { $complink = "R" } else { $complink = "E" } if ($subtime > $nend_time and time-$subtime < 172800) { $complink .= "S"; ($subrun,$subtape,$subtime,$subsystem,$subjob) = split /:/,$submit_lines[$run]; ($sec,$min,$hour,$mday,$mon,$year) = localtime($subtime); $month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$mon]; if ($min < 10) {$min = "0".$min} if ($sec < 10) {$sec = "0".$sec} $job_link = ""; $job_link .= "$farm_letter{$subsystem} $subjob"; print "
$run"; print "$itlink \+1
"; print "
$tapelink"; print "$whyevents"; print "$job_link"; print "$complink$skim1link"; print "$mday-$month $hour:$min"; print "\n"; next; } if ($oddok) { $subdirectory = substr $factoidsrun,0,2; $oddaccess = "/cgi-bin/home/www/topher/odp_get_any.pl?quick=$subdirectory/$factoidsrun$iteration.odd"; $oddlink = "$run$iteration.odd"; } else { $oddlink = "N/A"; } if ($logok) { $sloglink = "$run$iteration.log"; } else { $sloglink = "N/A"; } if(!$evtswt) { $evtswt = "0"; } if(!$events) { $events = "0"; } print "
$run"; print "$itlink"; print "$version $platform"; print "$tapelink"; print "$events$evtswt"; # print "$runtime"; print "$job_link"; print "$complink$skim1link"; print "$oddlink"; print "$sloglink

\n"; print "Status Key
\n"; print "N = Not yet submitted to any queue.
\n"; print "S = Submitted and currently in the queue.
\n"; print "D = Submitted and completed without any errors.
\n"; print "P = Submitted and completed with one or more non-fatal errors.
\n"; print "E = Submitted and terminated with one or more fatal errors.
\n"; print "

", "Mecca Access Page

";