<%@ LANGUAGE="VBScript" %> <% time_start=Now() dim s_wait dim wait_time dim start_time dim end_time dim s_start dim s_end dim s_old Dim st_pedcalc dim ed_pedcalc ' actions(0,i) action ' actions(1,i) description ' actions(2,i) group ' ' Dim actions(2,20) ' 'action_results(0,i)integer number of times the action took place( imp in sinking and pass) 'action_results(1,i) datevalue action time ' Dim action_results(2,20) ' ' ' groups ' action_groups(0,i) name ' action_groups(1,i) display result ' Dim action_groups(1,20),color(6) color(0)="O" color(1)="P" color(2)="C" color(3)="U" color(4)="N" color(5)="W" color(6)="C'" Function actiongroup(action_name) igroup=-1 For i=0 To ngroups-1 If action_groups(0,i)=action_name Then igroup=i Exit For End If Next actiongroup=igroup end Function ' ' the database is programmed to send a fixed number of ' records for each run. We will select a set of runs of a given run type ' For each run type there is a well defined sequence of actions that need to be ' taken. To save network and computing bandwidth we will get a detailed list of ' actions and then assume that the individual run data comes in the same sequence. ' ' The actions will be stored in an array ' ' If Request("run_type")<>"" Then run_type=CStr(Request("run_type")) Else run_type="ALLBEAM" End If ' ' Get first and last run number ' If Request("run_min")<>"" Then run_min=CInt(Request("run_min")) Else run_min=6175 End If If Request("run_max")<>"" Then run_max=CInt(Request("run_max")) Else run_max=6176 End If ' ' Open Database ' Set Connection = Server.CreateObject("ADODB.Connection") Connection.Mode = adModeRead Connection.Open phdb_rd ' ' This SQL statement gives an ordered list of actions related to run of type run_type ' SQLStmt = " select ta.action,la.action_group,la.description from phoffline.track_actions ta,phoffline.log_actions la " SQLStmt = SQLStmt & " where la.action=ta.action and la.action_type=2 and ta.run_type='" & run_type & "' " SQLStmt = SQLStmt & " order by la.action_order " ' response.write(SQLStmt) Set RS = Connection.Execute(SQLStmt) nactions=0 ngroups=0 old_group="" Do While Not RS.EOF group=CStr(RS("action_group")) actions(0,nactions)=CStr(RS("action")) actions(1,nactions)=CStr(RS("description")) actions(2,nactions)=group nactions=nactions+1 If group<>old_group Then action_groups(0,ngroups)=group ngroups=ngroups+1 old_group=group End If RS.MoveNext Loop Set RS=nothing ' ' For i=0 to ngroups-1 ' Response.write(i & " " & action_groups(0,i) & " " & action_groups(1,i) & "
") ' Next ' ' Get last run and sequence ' SQLStmt = " select max(run) last_run,max(sequence) last_sequence ,to_char(sysdate,'MM/DD/YYYY HH24:MI:SS') timedate from phoffline.runseqs " SQLStmt = SQLStmt & " where run=(select max(run) from phoffline.runseqs) " Set RS = Connection.Execute(SQLStmt) last_run=CStr(RS("last_run")) last_sequence=CStr(RS("last_sequence")) timedate=formatdatetime(RS("timedate"),0) ' i_new_sequence=actiongroup("NEW_SEQUENCE") i_pedcalc=actiongroup("PEDCALC") i_sinking=actiongroup("SINKING") i_pass0=actiongroup("PASS0") i_dv=actiongroup("DV") ' ' And this statement lists the run number and the number of times a given ' action was performed. 0 means that the action was never done. ' SQLStmt = " select max(ta1.run) run,max(ta1.sequence) sequence,count(rl.action) naction,to_char(max(rl.log_date),'MM/DD/YYYY HH24:MI:SS') ddate from " SQLStmt = SQLStmt & " (select rn.run,rn.sequence,ruu.run_type,ta.action,le.log_date from phoffline.log_entries le,phoffline.log_actions la, " SQLStmt = SQLStmt & " phoffline.runseq_numbers rn, phoffline.runs ruu, phoffline.runseqs ru,phoffline.track_actions ta " SQLStmt = SQLStmt & " where ta.action=le.action and la.action=ta.action and rn.logid=le.logid and rn.run=ru.run and rn.run=ruu.run and ru.sequence=rn.sequence " SQLStmt = SQLStmt & " and ruu.run_type='" & run_type & "' " SQLStmt = SQLStmt & " and ta.run_type=ruu.run_type and la.action_type=2 " SQLStmt = SQLStmt & " and ruu.run between " & CStr(run_min) & " and " & CStr(run_max) & ") rl, " SQLStmt = SQLStmt & " (select r.run,r.sequence,l.action,l.action_order,rr.run_type " SQLStmt = SQLStmt & " from phoffline.track_actions t,phoffline.runseqs r,phoffline.runs rr,phoffline.log_actions l " SQLStmt = SQLStmt & " where rr.run_type='" & run_type & "' " SQLStmt = SQLStmt & " and l.action=t.action and t.run_type=rr.run_type and r.run=rr.run and l.action_type=2 " SQLStmt = SQLStmt & " and r.run between " & CStr(run_min) & " and " & CStr(run_max) & ") ta1 " SQLStmt = SQLStmt & " where ta1.action=rl.action(+) and ta1.run=rl.run(+) and ta1.sequence=rl.sequence(+)" SQLStmt = SQLStmt & " group by ta1.run,ta1.sequence,ta1.action " SQLStmt = SQLStmt & " order by ta1.run desc,ta1.sequence,max(ta1.action_order) " ' response.write(SQLStmt) Set RS = Connection.Execute(SQLStmt) %> Sequence Production Status

Sequence Production Status: Runs of type <%=run_type%> from <%=run_min%> to <%=run_max%>

Go to request Page

<% ' ' We are now ready to loop through the runs. The number of runs is not known ' at this moment but we are sure that once the run is there it will have nactions-1 columns ' 'declare counters for each run ' ' sinkd=0 sinktbd=0 sinkwa=0 sinkpr=0 sinkcr=0 passd=0 passtbd=0 passwa=0 passpr=0 passcr=0 dvd=0 dvtbd=0 run_old=-10000 Do While Not RS.EOF run=CStr(RS("run")) sequence=CStr(RS("sequence")) ' ' check if we found a new run. If yes then close table and open new one ' it probably makes no sense to repeat legend every time, the new tables will ' be without headers ' If run<>run_old Then If run_old<>-10000 Then 'print the results from the counter response.write((dvd+dvtbd) & " sequences in this run
") response.write(sinkd &" files have been sunk to HPSS
") response.write(sinktbd &" files are still waiting for pedcalc to finish to be sunk to HPSS
") response.write(sinkwa &" files are waiting to be sunk
") response.write(sinkpr &" files are being sunk
") response.write(sinkcr &" sinking jobs have crashed
") response.write(passd &" PASS0 jobs have been done
") response.write(passtbd &" PASS0 jobs have not been done yet
") response.write(passwa &" PASS0 jobs are submitted
") response.write(passpr &" PASS0 jobs in progress
") response.write(passcr &" PASS0 jobs have crashed
") response.write(dvd & " DVPLOT jobs have been done
") response.write(dvtbd & " DVPLOT jobs have not been done
") response.write("

") 'reset counters sinkd=0 sinktbd=0 sinkwa=0 sinkpr=0 sinkcr=0 passd=0 passtbd=0 passwa=0 passpr=0 passcr=0 dvd=0 dvtbd=0 response.write("

Run "& run & "
" & vbCrLf) Else response.write("

Run ") Response.write( run & "
" & vbCrLf) End If run_old=run ' new run becomes old run from now on Else ' ' same run ' end If ' ' write info for one sequence now. We know how many entries are for this sequence ' a priori so we can rely on For loop in advancing the records. ' ' For i=0 To nactions-1 action_results(0,i)=CInt(RS("naction")) if not isnull(RS("ddate"))then action_results(1,i)=formatdatetime(RS("ddate"),0) else action_results(1,i)="1/1/85" ' very old date such that the difference is huge end if RS.MoveNext Next ' ' Find location of this group ' igroup=i_new_sequence If igroup>-1 Then s_start=false s_end=false s_old=false For i=0 to nactions-1 If actions(2,i)="NEW_SEQUENCE" Then If actions(0,i)="START_SEQ" Then If CInt(action_results(0,i))>0 Then s_start=true End If Elseif actions(0,i)="END_SEQ" Then If CInt(action_results(0,i))>0 Then s_end=true End If Elseif actions(0,i)="NEW_RUN_SEQUENCE" Then If CInt(action_results(0,i))>0 Then s_old=true End If End If End If Next If (s_start and s_end) Or (s_old) Then action_groups(1,igroup)=color(0)'green ,ok Elseif (s_start and (Not s_end)) Then If (run=last_run And sequence=last_sequence) Then action_groups(1,igroup)=color(1)'yellow, still running Else action_groups(1,igroup)=color(2)'red, crash End If Else action_groups(1,igroup)=color(3) 'blue, unknown End If End If ' 'PEDCALC analysis ' igroup=i_pedcalc If igroup>-1 Then st_pedcalc=false ed_pedcalc=false For i=0 to nactions-1 If actions(2,i)="PEDCALC" then If actions(0,i)="START_PEDCALC" then If Cint(action_results(0,i))>0 then st_pedcalc=true end if Elseif actions(0,i)="END_PEDCALC" then If Cint(action_results(0,i))>0 then ed_pedcalc=true End if End if End if Next If (st_pedcalc and ed_pedcalc) then action_groups(1,igroup)=color(0)'ok Elseif (st_pedcalc and (not ed_pedcalc)) then action_groups(1,igroup)=color(2)' in progress else action_groups(1,igroup)=color(4)'not done End if end if ' 'Sink analysis ' igroup=i_sinking If igroup>-1 Then For i=0 to nactions-1 If actions(2,i)="SINKING" then If actions(0,i)="SINK_WAIT_SEQ" then s_wait=cint(action_results(0,i)) wait_time=action_results(1,i) Elseif actions(0,i)="SINK_START_SEQ" then s_start=cint(action_results(0,i)) start_time=action_results(1,i) Elseif actions(0,i)="SINK_END_SEQ" then s_end=cint(action_results(0,i)) end_time=action_results(1,i) end if end if Next if (s_start<=0 and s_end<=0) then if s_wait<=0 then sinktbd=sinktbd+1' not done elseif s_wait>0 then if datediff("s",wait_time,timedate)>21600 then sinkcr=sinkcr+1'crash else 'waiting sinkwa=sinkwa+1 end if end if elseif(s_start>0 and s_end<=0) then if s_wait<=0 then if datediff("s",start_time,timedate)>21600 then sinkcr=sinkcr+1'crash else sinkpr=sinkpr+1 'in progress end if elseif s_wait>0 then if datediff("s",wait_time,start_time)>0 then if datediff("s",start_time,timedate)>21600 then sinkcr=sinkcr+1 'crash else sinkpr=sinkpr+1 'in progress end if else if datediff("s",wait_time,timedate)>21600 then sinkcr=sinkcr+1 'crash else sinkwa=sinkwa+1 'waiting end if end if end if elseif(s_start>0 and s_end>0) then if s_wait<=0 then if datediff("s",start_time,end_time)>0 then sinkd=sinkd+1'ok else if datediff("s",start_time,timedate)>21600 then sinkcr=sinkcr+1 'crash else sinkpr=sinkpr+1 'in progress end if end if elseif s_wait>0 then if datediff("s",wait_time,start_time)>0 then if datediff("s",start_time,end_time)>0 then sinkd=sinkd+1 'ok else if datediff("s",start_time,timedate)>21600 then sinkcr=sinkcr+1 'crash else sinkpr=sinkpr+1 'in progress end if end if else if datediff("s",wait_time,timedate)>21600 then sinkcr=sinkcr+1 action_groups(1,igroup)=color(6) 'crash else sinkwa=sinkwa +1 action_groups(1,igroup)=color(5) 'waiting end if end if end if Elseif (s_start<=0 and s_end>0) then if s_wait<=0 then sinkd=sinkd+1 'ok elseif s_wait>0 then if datediff("s",wait_time,end_time)>0 then sinkd=sinkd+1 'ok else if datediff("s",wait_time,timedate)>21600 then sinkcr=sinkcr+1 'crash else sinkwa=sinkwa +1 'waiting end if end if end if end if end if ' 'Pass analysis ' igroup=i_pass0 If igroup>-1 Then s_wait=false s_start=false s_end=false' For i=0 to nactions-1 If actions(2,i)="PASS0" then If actions(0,i)="P0_SUBMIT_SEQ" then s_wait=cint(action_results(0,i)) wait_time=action_results(1,i) Elseif actions(0,i)="P0_START_SEQ" then s_start=cint(action_results(0,i)) start_time=action_results(1,i) Elseif actions(0,i)="P0_END_SEQ" then s_end=cint(action_results(0,i)) end_time=action_results(1,i) end if end if Next if (s_start<=0 and s_end<=0) then if s_wait<=0 then passtbd=passtbd +1 ' not done elseif s_wait>0 then if datediff("s",wait_time,timedate)>21600 then passcr=passcr+1 'crash else passwa=passwa+1 'waiting end if end if elseif(s_start>0 and s_end<=0) then if s_wait<=0 then if datediff("s",start_time,timedate)>21600 then passcr=passcr+1 'crash else passpr=passpr+1 'in progress end if elseif s_wait>0 then if datediff("s",wait_time,start_time)>0 then if datediff("s",start_time,timedate)>21600 then passcr=passcr+1 'crash else passpr=passpr+1 'in progress end if else if datediff("s",wait_time,timedate)>21600 then passcr=passcr+1 'crash else passwa=passwa+1 'waiting end if end if end if elseif(s_start>0 and s_end>0) then if s_wait<=0 then if datediff("s",start_time,end_time)>0 then passd=passd+1 'ok else if datediff("s",start_time,timedate)>21600 then passcr=passcr+1 'crash else passpr=passpr+1 'in progress end if end if elseif s_wait>0 then if datediff("s",wait_time,start_time)>0 then if datediff("s",start_time,end_time)>0 then passd=passd+1 'ok else if datediff("s",start_time,timedate)>21600 then passcr=passcr+1 'crash else passpr=passpr+1 'in progress end if end if else if datediff("s",wait_time,timedate)>21600 then passcr=passcr+1 'crash else passwa=passwa+1 'waiting end if end if end if end if end if ' ' DV analysis ' find if has been processed by DV, this is run only if run type is ALLBEAM ' loop through the action_groups array to see if DV present ' igroup=i_dv If igroup>-1 Then s_start=false For i=0 to nactions-1 If actions(2,i)="DV" Then If actions(0,i)="DV_PLOT_SEQ" Then If CInt(action_results(0,i))>0 Then s_start=true End If End If End If Next ' ' make the final decision ' If s_start Then dvd=dvd+1'green ,ok Else dvtbd=dvtbd+1'grey, not done End If End if Loop response.write((dvd+dvtbd) & " sequences in this run
") response.write(sinkd &" files have been sunk to HPSS
") response.write(sinktbd &" files are still waiting for pedcalc to finish to be sunk to HPSS
") response.write(sinkwa &" files are waiting to be sunk
") response.write(sinkpr &" files are being sunk
") response.write(sinkcr &" sinking jobs have crashed
") response.write(passd &" PASS0 jobs have been done
") response.write(passtbd &" PASS0 jobs have not been done yet
") response.write(passwa &" PASS0 jobs are submitted
") response.write(passpr &" PASS0 jobs in progress
") response.write(passcr &" PASS0 jobs have crashed
") response.write(dvd & " DVPLOT jobs have been done
") response.write(dvtbd & " DVPLOT jobs have not been done
") response.write("

") %>
<% ' ' CLose database connection ' Set RS=nothing Connection.Close Set Connection=nothing time_stop=Now() time_tot=Round(24*60*60*(time_stop-time_start),1) Response.write("" & time_tot & "") %>