Dim WshShell, fso, AccessInfoFile, oExec, oRun, oCosmiHome, oAdmin, oMngsvut, oCjsleep
Dim oMngHost, oAAHost, 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
oAAHost = "172.16.12.30" '--- Adminagent Server
oUser = "admin" ' --- Management Server's userid
oPass = "admin" ' --- Management Server's password
' ==== Open ====
Function Open( )
Resource.LogInformation "======== Entering Open. ========"
Open = True
End Function
' ==== Online ====
Function Online( )
Resource.LogInformation "======== Entering Online. ========"
'--- adminagent.access.info file ---
Set fso = CreateObject("Scripting.FileSystemObject")
Set AccessInfoFile = fso.CreateTextFile(oCosmiHome & "¥manager¥tmp¥adminagent.access.info", True)
AccessInfoFile.WriteLine(oMngHost & ":28080," & oAAHost & ":20295")
AccessInfoFile.Close
'--- 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=" & oExec.ExitCode
Resource.LogInformation oRun
Resource.LogInformation oExec.StdOut.ReadAll
Online = False
Exit Function
End If
'--- mngsvrutil ---
oRun = oMngsvut & " -m " & oMngHost & ":28080 -u "&oUser&" -p "&oPass&" -s -l 360 start allServers"
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=" & oExec.ExitCode
Resource.LogInformation oExec.StdErr.ReadAll
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 " & oAAHost & " -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&" -s -l 360 stop allServers"
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 stopping failed. ### rtn=" & oExec.ExitCode
Resource.LogInformation oExec.StdErr.ReadAll
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=" & oExec.ExitCode
Resource.LogInformation oExec.StdErr.ReadAll
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 |