Dim WshShell, fso, AccessInfoFile, oExec, oRun, oCosmiHome, oAdmin, oMngsvut, oCjsleep
Dim oMngHost, oUser, oPass
Set WshShell = CreateObject("WScript.Shell")
oCosmiHome = WshShell.ExpandEnvironmentStrings("%COSMINEXUS_HOME%")
oAdminac = """" & oCosmiHome & "¥manager¥bin¥adminagentctl"""
oMngsvut = """" & oCosmiHome & "¥manager¥bin¥mngsvrutil"""
oCjsleep = """" & oCosmiHome & "¥CC¥server¥bin¥cjsleep"""
oMngHost = "172.16.12.39" '--- Management Server
oUser = "admin" ' --- Management Server's userid
oPass = "admin" ' --- Management Server's password
'==== Open ====
Function Open( )
Resource.LogInformation "======== Entering Open. ========"
' --- J2EE Server Name ---
If Resource.PropertyExists("ServerName") = False Then
Resource.LogInformation "### Private property ServerName is not set. ###"
End If
' --- Inprocess OTS Status Path ---
If Resource.PropertyExists("StatusPath") = False Then
Resource.LogInformation "### Private property StatusPath is not set. ###"
End If
' --- Cluster IP Address ---
If Resource.PropertyExists("IPAddress") = False Then
Resource.LogInformation "### Private property IPAddress is not set. ###"
End If
' --- Cluster Host Name ---
If Resource.PropertyExists("HostName") = False Then
Resource.LogInformation "### Private property HostName is not set. ###"
End If
Open = True
End Function
'==== Online ====
Function Online( )
Resource.LogInformation "======== Entering Online. ========"
'--- private properties ---
If Resource.PropertyExists("ServerName") = False Or _
Resource.PropertyExists("StatusPath") = False Or _
Resource.PropertyExists("IPAddress") = False Or _
Resource.PropertyExists("HostName") = False Then
Resource.LogInformation "### Private property is not set. ###"
Online = False
Exit Function
End If
'--- adminagentctl ---
Set oExec = WshShell.Exec(oAdminac & " start")
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Administration Agent cannot start. ### rtn=" & oResult
Resource.LogInformation oExec.StdErr.ReadAll
Online = False
Exit Function
End If
'--- mngsvrutil ---
oRun = oMngsvut & " -m "& oMngHost &":28080 -u " & oUser & " -p " & oPass & _
" -t " & Resource.IPAddress & " -k host -s start server"
Set oExec = WshShell.Exec(oRun)
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Logical Servers start failed. ### rtn=" & oResult
Resource.LogInformation oExec.StdErr.ReadAll
Online = False
Exit Function
End If
Online = True
End Function
'==== LooksAlive ====
Function LooksAlive( )
Resource.LogInformation "======== Entering LooksAlive. ========"
'--- tasklist ---
Set oExec = WshShell.Exec("tasklist /NH /FI ""IMAGENAME eq adminagent.exe""")
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If InStr(1, oExec.StdOut.ReadAll, "adminagent.exe", 1) <> 0 Then
LooksAlive = True
Else
LooksAlive = False
End If
End Function
'==== IsAlive ====
Function IsAlive( )
Resource.LogInformation "======== Entering IsAlive. ========"
'--- mngsvrutil ---
oRun = oMngsvut & " -m " & oMngHost & ":28080 -u " & oUser & " -p " & oPass & _
" -t " & Resource.IPAddress & " -k host check adminAgent"
Set oExec = WshShell.Exec(oRun)
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Administration Agent command failed. ### rtn=" & oExec.ExitCode
Resource.LogInformation oExec.StdErr.ReadAll
IsAlive = False
Else
IsAlive = True
End If
End Function
'==== Offline ====
Function Offline( )
Resource.LogInformation "======== Entering Offline. ========"
'--- mngsvrutil ---
oRun = oMngsvut & " -m " & oMngHost & ":28080 -u " & oUser & " -p " & oPass & _
" -t " & Resource.IPAddress & " -k host -s stop server"
Set oExec = WshShell.Exec(oRun)
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Logical Server stopping failed. ### rtn=" & oResult
Resource.LogInformation oExec.StdErr.ReadAll
Offline = False
Exit Function
End If
'--- adminagentctl ---
Set oExec = WshShell.Exec(oAdminac & " stop")
Do While oExec.Status = 0
WshShell.Run oCjsleep & " 1", 0, True
Loop
If oExec.ExitCode <> 0 Then
Resource.LogInformation "### Administration Agent stopping failed. ### rtn=" & oResult
Resource.LogInformation oExec.StdErr.ReadAll
Offline = False
Exit Function
End If
Offline = True
End Function
'==== Close ====
Function Close( )
Resource.LogInformation "======== Entering Close. ========"
Close = True
End Function
'==== Terminate ====
Function Terminate( )
Resource.LogInformation "======== Entering Terminate. ========"
Terminate = True
End Function |