Cosminexus アプリケーションサーバ V8 機能解説 運用/監視/連携編
運用管理エージェントを監視,起動,および停止するためのスクリプトファイルをVBScriptで記述します。現用系のアプリケーションサーバと予備系のアプリケーションサーバで同一の汎用スクリプトファイルを使用し,同一のパスに配置してください。
アプリケーションサーバを1:1に配置して系を切り替える場合の汎用スクリプトファイルの例(GenericScript.vbs)を次に示します。なお,汎用スクリプトファイルに定義する関数と変数については,「(2) 汎用スクリプトファイルの関数」,および「(3) 汎用スクリプトファイルの変数」を参照してください。
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
|
汎用スクリプトファイルには,関数を定義する必要があります。各関数の戻り値は,正常終了時にはTrueを,異常終了時にはFalseを返します。汎用スクリプトファイルの関数を次の表に示します。
表19-2 汎用スクリプトファイルの関数(アプリケーションサーバの1:1系切り替えの場合)
| 関数名 | 内容 |
|---|---|
| Open | この汎用スクリプトファイルが開かれるときに実行される関数です。Resource.LogInformationメソッドでクラスタログにログを出力します。 |
| Online | 汎用スクリプトリソースのオンライン時に実行される関数です。この関数でアクセス情報ファイルを作成し,運用管理エージェント,論理サーバを起動します。 アクセス情報ファイルのフォーマットを次に示します。 <Mng_ip>:<Mng_port>,<AA_ip>:<AA_port>
|
| LooksAlive | リソースの稼働状況を簡単に把握するための関数です。この関数では,tasklistコマンドで運用管理エージェントのプロセスの有無を確認します。 |
| IsAlive | リソースの稼働状況を厳密に把握するための関数です。この関数では,mngsvrutilのcheckコマンドで運用管理エージェントが正常に動作しているかを確認します。 |
| Offline | 汎用スクリプトリソースのオフライン時に実行される関数です。この関数で論理サーバと運用管理エージェントを停止します。 |
| Close | この汎用スクリプトファイルが閉じるときに実行される関数です。 |
| Terminate | 汎用スクリプトリソースの強制終了時に実行される関数です。 |
汎用スクリプトファイルでは,必要に応じて次の表に示す変数の値を変更してください。
表19-3 汎用スクリプトファイルの変数(アプリケーションサーバの1:1系切り替えの場合)
| 変数名 | 内容 |
|---|---|
| oMngHost | Management Serverが稼働しているホスト |
| oAAHost | 運用管理エージェントが稼働しているホスト(クラスタIPアドレス) |
| oUser | Management ServerにログインするためのログインID |
| oPass | Management Serverにログインするためのパスワード |
All Rights Reserved. Copyright (C) 2008, 2011, Hitachi, Ltd.