%@LANGUAGE="VBSCRIPT"%>
<%
'=====================================================
'| |
'| ADMIN Build Status Information |
'| |
'=====================================================
%>
<%
Option explicit
' Good idea to set when using redirect
Response.Expires = 0 ' always load the page, dont store
%>
<%
'------------ ACCESS CONTROL ------------------
%>
<%
'------------ Variable Definition -------------
Dim rsQry
Dim query_string
Dim styleAlt1
Dim styleAlt2
Dim styleNow
Dim param_refreshPeriod
Dim param_refreshEnabled
Dim bIndefinitelyPaused
'------------ Constants Declaration -----------
Const Min_Refresh_Time = 10
'------------ Variable Init -------------------
styleAlt1="class='body_rowg1'"
styleAlt2="class='body_rowg2'"
styleNow = styleAlt1
'----------------------------------------------
%>
<%
'--------------------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------------------------------------------------------------
' Toggle row style between the two alternative styles
Sub ToggleStyleNow
If styleNow = styleAlt1 Then
styleNow = styleAlt2
Else
styleNow = styleAlt1
End If
End Sub
'--------------------------------------------------------------------------------------------------------------------------
' Convert run level into a meaningful string
Function Get_Run_Level( nLevel, indefinitePause, astate)
If indefinitePause Then
Get_Run_Level = "Stopped"
ElseIf astate = 1 Then ' if build daemon paused
Get_Run_Level = "Paused"
ElseIf astate = 2 Then ' if build daemon disabled
Get_Run_Level = "Disabled"
ElseIf astate = 0 Then ' if build daemon enabled
If nLevel = 1 Then
Get_Run_Level = "Cannot Continue"
ElseIf nLevel = 2 Then
Get_Run_Level = "Paused"
ElseIf nLevel = 3 Then
Get_Run_Level = "Building"
ElseIf nLevel = 4 Then
Get_Run_Level = "Idle"
ElseIf nLevel = 5 Then
Get_Run_Level = "Waiting"
ElseIf nLevel = 6 Then
Get_Run_Level = "Publishing"
Else
Get_Run_Level = "Unknown!"
End If
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Is a build occurring for this dataset/row ?
Function Is_Actively_Building( nPkgId )
Is_Actively_Building = False
If (NOT IsNull(nPkgId)) AND (nPkgId <> "") Then
Is_Actively_Building = True
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Return True if the paramter values represent a possibly hung daemon
Function Daemon_Delta_Threshold_Exceeded( nDelta )
Daemon_Delta_Threshold_Exceeded = False
If (nDelta > 600) Then
Daemon_Delta_Threshold_Exceeded = True
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Return True if the paramter values represent a paused daemon
Function Is_Paused( nLevel, indefinitePause )
If indefinitePause Then
Is_Paused = True
Else
If nLevel = 2 Then
Is_Paused = True
Else
Is_Paused = False
End If
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Return True if the paramter values represent a disabled or paused daemon
Function Is_Disabled( astate)
If astate = 1 Then ' if build daemon paused
Is_Disabled = True
ElseIf astate = 2 Then ' if build daemon disabled
Is_Disabled = True
Else
Is_Disabled = False
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Convert daemon mode into a meaningful string
Function Get_Daemon_Mode( nMode )
If nMode = "M" Then
Get_Daemon_Mode = "Master"
ElseIf nMode = "S" Then
Get_Daemon_Mode = "Slave"
Else
Get_Daemon_Mode = "?"
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Return HTML for a seperator line between rows in the table
Function HTML_Row_Divider( projectChanged, projectChecked, releaseChanged, last_row_displayed )
Dim s
s = ""
If projectChanged Then
s = s + "
"
s = s + "
"
s = s + "
"
s = s + "
"
s = s + "
"
s = s + "
"
Else
if projectChecked = "checked" AND last_row_displayed = True Then
s = s + "
"
If releaseChanged Then
s = s + "
"
s = s + "
"
Else
s = s + "
"
s = s + "
"
End If
s = s + "
"
End If
End If
HTML_Row_Divider = s
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Use this function to determine the state of a specified project checkbox
Function Is_Project_Checked( nProjId )
Dim hiddenProjects_arr
Dim hiddenProjects
Dim str
hiddenProjects = Request("HideProj")
Is_Project_Checked = "checked"
hiddenProjects_arr = Split(hiddenProjects, ",")
For Each str in hiddenProjects_arr
If str = nProjId Then
Is_Project_Checked = ""
Exit For
End If
Next
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Use this function to set/clear the filter on/off radio button checked state
' Format of Filter Param : Filter=ON,[problemDaemonSets}[,ActiveBuilds] | OFF
Function Display_Filtered(id)
Dim filter
Display_Filtered = ""
filter = Request("Filter")
If NOT IsNull(filter) AND filter <> "" Then
If InStr(filter, id) > 0 Then
Display_Filtered = "checked"
End If
Else
If id = "OFF" Then
Display_Filtered = "checked"
End If
End If
End Function
Function Display_Filter_Is_On()
If Display_Filtered("ON") = "checked" Then
Display_Filter_Is_On = True
Else
Display_Filter_Is_On = False
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Use this function to set/clear a filter option check box with the given ID
Function Filter_Checked(id)
Dim filter
Filter_Checked = ""
filter = Request("Filter")
If NOT IsNull(filter) AND filter <> "" Then
If InStr(filter, id) > 0 Then
Filter_Checked = "checked"
End If
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Test to see if a particular filter option is on
Function Filter_Is_On(id)
If Display_Filter_Is_On() Then
If Filter_Checked(id) = "checked" Then
Filter_Is_On = True
Else
Filter_Is_On = False
End If
Else
Filter_Is_On = False
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
' Get name of package given its ID. Return empty string if not able to do so.
Function Get_Pkg_Name( nPkgId )
Dim rsQry2
Dim query_string2
Get_Pkg_Name = ""
If (NOT IsNull(nPkgId)) AND (nPkgId <> "") Then
query_string2 = "SELECT pkg.PKG_NAME " &_
" FROM PACKAGES pkg" &_
" WHERE pkg.PKG_ID = " & nPkgId
Set rsQry2 = OraDatabase.DbCreateDynaset( query_string2, ORADYN_DEFAULT )
If rsQry2.RecordCount > 0 Then
Get_Pkg_Name = rsQry2("pkg_name")
End If
rsQry2.Close()
Set rsQry2 = nothing
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
Function Indefinitely_Paused()
Dim rsQry2
Dim query_string2
Indefinitely_Paused = False
query_string2 = " select * from run_level_schedule rls where rls.indefinite_pause = 'P'"
Set rsQry2 = OraDatabase.DbCreateDynaset( query_string2, ORADYN_DEFAULT )
If rsQry2.RecordCount > 0 Then
Indefinitely_Paused = True
End If
End Function
'--------------------------------------------------------------------------------------------------------------------------
Function PrettyDelta( delta, daemonState,pkgId )
Dim style
style = ""
If (delta > 600) AND (IsNull(pkgId) OR pkgId = "") Then
style = "style=color:Red"
If (delta > 86400 ) Then
Dim bdate, dd,mm,yy
bdate = DateAdd("s", - delta,Now())
dd = Day(bdate)
mm = MonthName(Month(bdate),1)
yy = Year( bdate)
delta = dd & "-" & mm & "-" & yy
If ( daemonState >= 2 ) Then
style = ""
End If
ElseIf ( delta > 60*60 ) Then
'Dim bdate, hh, mins, ss
bdate = DateAdd("s", - delta,Now())
delta = TimeValue( bdate)
'delta = hh & ":" & mins & ":" & ss
End If
End If
If style <> "" Then
delta = "" & delta & ""
End If
PrettyDelta = delta
End Function
'--------------------------------------------------------------------------------------------------------------------------
%>
<%
'------------ RUN BEFORE PAGE RENDER ----------
' Default values for Auto Refresh checkbox and edit input box
param_refreshEnabled = False
param_refreshPeriod = "0"
' Read the Refresh parameter which is of the form Refresh=,ON|OFF
Dim param_refresh
param_refresh = Request("Refresh")
If param_refresh <> "" Then
Dim pr_arr
pr_arr = Split(param_refresh,",")
param_refreshPeriod = pr_arr(0)
' Range check and end-stop the refresh period if necessary
If CInt(param_refreshPeriod) < Min_Refresh_Time Then
param_refreshPeriod = CStr(Min_Refresh_Time)
End If
' determine checkbox state
If UBound(pr_arr) >= 1 Then
If InStr(UCase(pr_arr(1)), "ON") > 0 Then
param_refreshEnabled = True
Else
param_refreshEnabled = False
End If
End If
End If
' Get indefinite pause status
bIndefinitelyPaused = Indefinitely_Paused()
'----------------------------------------------
%>
Release Manager
<%If param_refreshEnabled AND param_RefreshPeriod <> 0 Then%>
>
<%End If%>
BUILD DAEMON STATUS INFORMATION
<%If bIndefinitelyPaused Then%>
WARNING: Indefinite Pause, Build Daemons are all stopped - please contact an administrator
<%End If%>
Project
Release
Release Mode
Daemon Mode
Daemon Host
Daemon State
Building Package
Last Change Delta (secs)
<%
query_string = "SELECT rc.RCON_ID, " &_
" rc.RTAG_ID, " &_
" bm.DISPLAY_NAME, " &_
" rc.DAEMON_MODE, "&_
" rt.RTAG_NAME, " &_
" rt.OFFICIAL, " &_
" p.PROJ_ID, " &_
" p.PROJ_NAME, " &_
" rl.CURRENT_PKG_ID_BEING_BUILT, "&_
" rl.CURRENT_RUN_LEVEL, "&_
" rl.PAUSE, " &_
" TRUNC (86400*(SYSDATE - rl.KEEP_ALIVE)) as delta" &_
" FROM RELEASE_CONFIG rc, RELEASE_TAGS rt, PROJECTS p, RUN_LEVEL rl, BUILD_MACHINE_CONFIG bm " &_
" WHERE rt.RTAG_ID = rc.RTAG_ID " &_
" AND rc.DAEMON_HOSTNAME is not null" &_
" AND rt.PROJ_ID = p.PROJ_ID " &_
" AND rt.OFFICIAL != 'A' " &_
" AND rt.OFFICIAL != 'Y' " &_
" AND rl.RCON_ID = rc.RCON_ID" &_
" AND rc.DAEMON_HOSTNAME = bm.MACHINE_HOSTNAME(+)" &_
" ORDER BY p.PROJ_NAME, rt.RTAG_NAME, rc.DAEMON_MODE, bm.DISPLAY_NAME"
Set rsQry = OraDatabase.DbCreateDynaset( query_string, ORADYN_DEFAULT )
' String variables
Dim strProject_checked ' Can be "" or "checked". Determines appearance of project enable checkbox
' Boolean variables
Dim bProject_changed ' signals a row change due to a different project
Dim bRelease_changed ' signals a row change due to a different release
Dim bRow_displayed ' signals whether a row should be displayed or not
Dim bRelease_link_displayed ' indicates whether the release name has been rendered yet
Dim bDisplay_whole_set ' forces the whole daemon set for a release to be displayed
Dim bDisplayFilterIsOn ' Indicates if Filtering is on or off
Dim bShowProblemDaemonSets ' Indicates if problem daemons must be shown during filtering
Dim bShowDisabledDaemons ' Indicates if a disabled daemon must be shown during filtering
Dim bShowActiveBuilds ' Indicates if active builds must be shown during filtering
' Integer variables
Dim pkgId
Dim lastProjID ' Used to detect project changes from one row to the next
Dim lastRtagId ' Used to detect release changes from one row to the next
Dim daemonState
' Initialise variables
strProject_checked = ""
bProject_changed = True
bRelease_changed = True
bRow_displayed = True
bRelease_link_displayed = False
bDisplay_whole_set = False
bDisplayFilterIsOn = Display_Filter_Is_On()
bShowProblemDaemonSets = Filter_Is_On("problemDaemonSets")
bShowActiveBuilds = Filter_Is_On("activeBuilds")
bShowDisabledDaemons = Filter_Is_On("disabledDaemons")
lastProjID = 0
lastRtagId = 0
Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
pkgId = rsQry("current_pkg_id_being_built")
' determine if user has checked the project checkbox
strProject_checked = Is_Project_Checked(rsQry("proj_id"))
' Has the project changed since the last row. If so, signal it via bProject_changed variable, and
' reset the bRelease_link_displayed variable to force the display of the release column value on the
' render of the next unfiltered row
bProject_changed = False
If lastProjID <> rsQry("proj_id") Then
lastProjID = rsQry("proj_id")
bProject_changed = True
bRelease_link_displayed = False
bDisplay_whole_set = False
End If
' Has the release changed since the last row of displayed data. If so, signal it via the bRelease_changed variable,
' and reset the bRelease_link_displayed variable to force the display of the release column value on the
' render of the next unfiltered row.
bRelease_changed = False
If lastRtagId <> rsQry("rtag_id") Then
lastRtagId = rsQry("rtag_id")
bRelease_changed = True
bRelease_link_displayed = False
bDisplay_whole_set = False
End If
daemonState = rsQry("pause")
If IsNull(daemonState) Then
daemonState = 0
End If
' generate the table row divider - this uses the bRow_displayed value from the previous iteration in order
' to prevent dividers being drawn between rows that were not actually rendered due to any filtering that
' may be in effect.
%>
<%=HTML_Row_Divider( bProject_changed, strProject_checked, bRelease_changed, bRow_displayed )%>
<%
' If this is a Master Daemon, look ahead at all the slaves and evaluate if any daemons in the set appear to
' be having a problem. If any are and the user has turned the "Show Problem Daemon Sets" filter on then
' set the bDisplay_whole_set variable to True else set it to False
If rsQry("daemon_mode") = "M" Then
' Initial default value is to not show the entire daemon set
bDisplay_whole_set = False
' If the filter is turned on and master daemon is NOT actively building a package and it is NOT paused...
If bDisplayFilterIsOn _
AND bShowProblemDaemonSets _
AND (NOT Is_Actively_Building(rsQry("current_pkg_id_being_built"))) _
AND (NOT Is_Paused(rsQry("current_run_level"), bIndefinitelyPaused) ) _
AND (NOT Is_Disabled(daemonState) ) _
Then
' Display the whole set if the master daemons delta exceeds the threshold
bDisplay_whole_set = Daemon_Delta_Threshold_Exceeded(rsQry("delta"))
' If nothing appears wrong with the Master Daemon, look ahead at all the slaves in the set
If NOT bDisplay_whole_set Then
Dim thisRtagId
Dim rtag_id_set_count
Dim i
thisRtagId = rsQry("rtag_id")
rtag_id_set_count = 1
rsQry.MoveNext
Do While (NOT rsQry.BOF) AND (NOT rsQry.EOF) AND rsQry("rtag_id") = thisRtagId
rtag_id_set_count = rtag_id_set_count + 1
' If this slave daemon is NOT actively building a package and it is NOT paused and its Delta exceeds the threshold...
If (NOT Is_Actively_Building(rsQry("current_pkg_id_being_built"))) _
AND (NOT Is_Paused(rsQry("current_run_level"), bIndefinitelyPaused)) _
AND (NOT Is_Disabled(daemonState) ) _
AND Daemon_Delta_Threshold_Exceeded(rsQry("delta")) Then
bDisplay_whole_set = True
End If
rsQry.MoveNext
Loop
For i = 1 to rtag_id_set_count
rsQry.MovePrevious
Next
End If
End If
End If
' Now figure out if this row of data is to be displayed or not
bRow_displayed = ( NOT bDisplayFilterIsOn ) _
OR ( bDisplay_whole_set ) _
OR ( bShowDisabledDaemons AND Is_Disabled(daemonState) ) _
OR ( bShowActiveBuilds AND Is_Actively_Building(pkgId) )
' If the release has changed and we are going to display this row, toggle the row style to give
' it a slightly different look to the previous displayed row which was for a different release
If bRelease_changed AND bRow_displayed Then
Call ToggleStyleNow
End If
' Now we are ready to render the HTML content for the row, but we may still circumvent rendering if the user
' has unchecked the project checkbox
%>