#! /usr/local/bin/perl # Set our timezone $ENV{TZ} = "CST6CDT"; $meccadir = "/edata1/mecca/"; $infodir = $meccadir."info/"; %states = ("c" => "In cleanup", "w" => "Waiting On-deck", "i" => "Staging Input Files", "o" => "Staging Output Files", "r" => "On-deck (Input Staged)", "s" => "Submitted (in queue)", "a" => "Analysis Phase", "d" => "Finished", "x" => "Cancelled", "h" => "On Hold" ); %state_times = ("c" => "CLEAN-STIME", "w" => "STARTUP-STIME", "i" => "ISR-TIME", "o" => "CLEAN-STIME", "r" => "ISD-TIME", "s" => "SUB-TIME" , "a" => "ANAL-STIME", "d" => "DONE-TIME", "x" => "CANCEL-TIME", "h" => "HOLD-TIME" ); %logic = (1 => "Yes",0 => "No"); %stage_logic = (1 => "Yes",0 => "No",2 => "Input Only",3 => "Output Only"); @times = ( ["SUB-TIME" ,"Submitted"], ["STARTUP-STIME","Went On-deck"], ["ISR-TIME" ,"Requested Input Disk"], ["IMR-TIME" ,"Requested Input Tape"], ["IMD-TIME" ,"Input Tape Mounted"], ["ISD-TIME" ,"Finished Input Staging"], ["STARTUP-ETIME","Finished On-deck"], ["ANAL-STIME" ,"Began Analysis"], ["OSR-TIME" ,"Requested Output Disk"], ["ANAL-ETIME" ,"Finished Analysis"], ["ISF-TIME" ,"Deallocated Input Disk"], ["CLEAN-STIME" ,"Began Rundown"], ["OMR-TIME" ,"Requested Output Tape"], ["OMD-TIME" ,"Output Tape Mounted"], ["OSF-TIME" ,"Deallocated Output Disk"], ["OSD-TIME" ,"Finished Output Staging"], ["DONE-TIME" ,"Finished Job"], ["CANCEL-TIME" ,"Cancelled"], ["HOLD-TIME" ,"Placed on Hold"] ); @dtimes = ( ["STARTUP-STIME","ANAL-STIME", "Time spent On-deck"], ["IMR-TIME", "IMD-TIME" ,"Time for Input Mount"], ["ISR-TIME", "ISD-TIME" ,"Time spent Staging Input"], ["ANAL-STIME" ,"ANAL-ETIME" ,"Time spent Analyzing"], ["CLEAN-STIME" ,"DONE-TIME" ,"Time spent in Rundown"], ["OMR-TIME", "OMD-TIME" ,"Time for Output Mount"], ["CLEAN-STIME" ,"OSD-TIME" ,"Time spent Staging Output"], ); # HTML definitions $color = "bgcolor=949cce"; $elem_color = "bgcolor=949cce"; $head_color = "bgcolor=ff6060"; $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 $system = $form_key{system}; $job = $form_key{job}; # Open info file, store all lines, put into %info $info_file = $infodir.$system."_".$job.".info"; open INFO,$info_file; @infolines = ; close INFO; %info = (); %info_field = (); foreach $line (@infolines) { $line =~ s/\s+//; ($key,$value) = split /:/,$line; $info{$key} = $value; $info_field{$key} = 1; } $pwd = $info{PWD}; $platform = $info{PLATFORM}; $system = $info{SYSTEM}; $job_num = $info{JOB}; $run = $info{ASKRUN}; $askrun = $info{ASKRUN}; $didrun = $info{DIDRUN}; $foundrun = $info{FOUNDRUN}; $state = $info{STATE}; $staging = $info{STAGE}; $frtape = $info{FRTAPE}; $fdtape = $info{FDTAPE}; $tapenum = $info{TAPENUM}; $host = $info{HOST}; $isr_time = $info{"ISR-TIME"}; $isdisk = $info{"ISDISK"}; $isd_time = $info{"ISD-TIME"}; $is_status = $info{"IS-STATUS"}; $isf_time = $info{"ISF-TIME"}; $istrys = $info{"ISTRYS"}; $isnfiles = $info{"ISNFILES"}; $itaped = $info{"ITAPED"}; $ilabel = $info{"ILABEL"}; $osr_time = $info{"OSR-TIME"}; $osdisk = $info{"OSDISK"}; $os_status = $info{"OS-STATUS"}; $osf_time = $info{"OSF-TIME"}; $osd_time = $info{"OSD-TIME"}; $ostrys = $info{"OSTRYS"}; $osnfiles = $info{"OSNFILES"}; $otaped = $info{"OTAPED"}; $iw_events = $info{"IW-EVENTS"}; $is_events = $info{"IS-EVENTS"}; $ia_events = $info{"IA-EVENTS"}; $os_events = $info{"OS-EVENTS"}; $oa_events = $info{"OA-EVENTS"}; if (!$staging) {$staging = 0} # Document preamble $next_job = $job+1; $prev_job = $job-1; print "Job Info for $system $job_num\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
"; print ""; print "
Prev. Job
Job Info for $system $job_num"; print "\n"; print "
Next Job
\n"; print "\n"; print "\n"; print "

\n"; ### Make nice tables print "

\n"; # Current Status Table print "\n"; print "\n"; # Staging info Table # End Master Table print "
"; print " \n"; print "\n"; print "\n"; print "\n"; if ($pwd) { @path_parts = split /\//,$pwd; $area = pop @path_parts; $queue = pop @path_parts; print "\n"; } print "\n"; print "\n"; $time_state = time() - $info{$state_times{$state}}; if ($time_state < 0) { $hours = 0; $minutes = 0; $seconds = 0; } else { $hours = int (($time_state)/3600.0); $minutes = int (($time_state-3600*$hours)/60.0); $seconds = int ($time_state-3600*$hours - 60*$minutes); } if ($hours < 72 && $state ne "x" && $state ne "d") { $time_string = sprintf "%3d:%2.2d:%2.2d",($hours,$minutes,$seconds); print "\n"; } # Run information table print "\n"; if ($frtape && $fdtape) { print " \n"; print " \n"; } else { print " \n"; } if ($ilabel) {TableElement("Internal Label",$ilabel)} if ($itaped) {print "\n"} if ($otaped) {print "\n"} if ($askrun) { print " \n"; } if ($didrun) { print " \n"; } if ($foundrun) { @found_lines = grep /FOUNDRUN/,@infolines; foreach $line (@found_lines) { $line =~ s/\n//; ($junk,$frun) = split /:/,$line; push @allruns,$frun; } print " \n"; } if ($staging) { $sisr_time = MeccaTime($isr_time); $sosr_time = MeccaTime($osr_time); $sisd_time = MeccaTime($isd_time); $sosd_time = MeccaTime($osd_time); $sisf_time = MeccaTime($isf_time); $sosf_time = MeccaTime($osf_time); print "\n"; if ($isr_time) {TableElement("Input Disk Requested",$sisr_time)} if ($isdisk) {TableElement("Input Staging Disk","$isdisk on $host")} if ($isd_time) {TableElement("Input Staging Completed",$sisd_time)} if ($isf_time) {TableElement("Input Disk Deallocated",$sisf_time)} if ($istrys) {TableElement("# of Input attempts",$istrys)} if ($isnfiles) {TableElement("# of files input",$isnfiles)} TableElement("Input Staging Successful","$logic{$is_status}  "); if ($osr_time) {TableElement("Output Disk Requested",$sosr_time)} if ($osdisk) {TableElement("Output Staging Disk","$osdisk on $host")} if ($osd_time) {TableElement("Output Staging Completed",$sosd_time)} if ($osf_time) {TableElement("Output Disk Deallocated",$sosf_time)} if ($ostrys) {TableElement("# of Output stage attempts",$ostrys)} if ($osnfiles) {TableElement("# of files output",$osnfiles)} TableElement("Output Staging Successful","$logic{$os_status}  "); } print "
Current Job Status
Production System$system
Job Number$job_num
Batch Area$queue\/$area
Staging Requested$stage_logic{$staging}
Job Progress$states{$state}
Time in State$time_string
Run/Tape Info
Input Tape $fdtape
Output Tape$frtape
Tape Number$tapenum
Input Tape Drive$itaped
Output Tape Drive$otaped
Requested Run$askrun
Analyzed or Staged Run$didrun
Runs found on tape@allruns
Staging Info
\n"; print "
\n"; # Times Table print " \n"; if ($iw_events || $is_events || $ia_events || $oa_events || $os_events) { print "\n"; } if ($iw_events) {TableElement("Input Events (Whyme)", $iw_events)} if ($is_events) {TableElement("Input Events (Staged)", $is_events)} if ($ia_events) {TableElement("Input Events (Analyzed)", $ia_events)} if ($oa_events) {TableElement("Output Events (Analyzed)", $oa_events)} if ($os_events) {TableElement("Output Events (Staged)", $os_events)} print "\n"; for $i (0..$#times) { $description = $times[$i][1]; $ntime = $info{$times[$i][0]}; if ($ntime) { $time_string = MeccaTime($ntime); TableElement($description,$time_string); } } for $i (0..$#dtimes) { $description = $dtimes[$i][2]; $ntime1 = $info{$dtimes[$i][0]}; $ntime2 = $info{$dtimes[$i][1]}; if ($ntime2 < $ntime1) { $hours = 0; $minutes = 0; $seconds = 0; } else { $hours = int (($ntime2 - $ntime1)/3600.0); $minutes = int ((($ntime2 - $ntime1-3600*$hours)/60.0)); $seconds = int ($ntime2 - $ntime1-3600*$hours - 60*$minutes); } if ($ntime1 && $ntime2) { $time_string = sprintf "%3d:%2.2d:%2.2d",($hours,$minutes,$seconds); TableElement($description,$time_string); } } print "
Event Counts
Action Times
\n"; print "
\n"; print "

\n"; # Print out full file print "


"; print "
Raw Info File
"; print "

\n"; print "

 \n";
foreach $line (@infolines) {
  print "$line \n";
}
print "
\n"; sub MeccaTime ($) { $numerical_time = $_[0]; $time_string = localtime($numerical_time); ($wday,$month,$day,$time,$year) = split /\s+/,$time_string; $time_string = "$time $day-$month-$year"; return $time_string; } sub TableElement ($$) { $label = $_[0]; $value = $_[1]; print "$label$value\n"; return; }