| Oracle® Fusion Middleware Oracle WebLogic Scripting Tool 11g リリース1(10.3.3) B61621-01 |
|
![]() 前 |
![]() 次 |
WLSTでは、WebLogic Serverインスタンスが実行時の状態を記述するために生成する情報を取得できます。次の項では、WLSTを使用した実行時情報の取得方法について説明します。
管理サーバーは、WebLogicドメインに含まれる任意のサーバー上の任意のMBeanへのアクセスを提供する、ドメインの実行時階層をホストします。管理サーバーがドメインに対して実行されていない場合、WLSTでは個々の管理対象サーバーに接続して実行時データを取得できます。
WebLogicドメインの実行時情報にアクセスする主な手順は、次のとおりです。
WLSTを呼び出し、実行中の管理サーバーのインスタンスに接続します。「WLSTの呼出し」を参照してください。
domainRuntimeコマンドを入力して、ドメインの実行時MBean階層にナビゲートします。
wls:/mydomain/serverConfig>domainRuntime()
domainRuntimeコマンドによりWLSTは、ドメイン全体の実行時管理オブジェクトのルートDomainRuntimeMBeanに置かれます。
ServerRuntimesにナビゲートしてから、モニターするサーバー・インスタンスにナビゲートします。
wls:/mydomain/domainRuntime>cd('ServerRuntimes/myserver')
サーバー・インスタンスで、実行時MBeanにナビゲートし、照会を行います。
wls:/mydomain/domainRuntime/ServerRuntimes/myserver>cd('JVMRuntime/myserver')> wls:/mydomain/domainRuntime/ServerRuntimes/myserver/JVMRuntime/myserver>ls() -r-- AllProcessorsAverageLoad 0.0 -r-- Concurrent true -r-- FreeHeap 15050064 -r-- FreePhysicalMemory 900702208 -r-- GCHandlesCompaction true -r-- GcAlgorithm Dynamic GC currently running strategy: Nursery, parallel mark, parallel sweep -r-- Generational true -r-- HeapFreeCurrent 14742864 -r-- HeapFreePercent 5 -r-- HeapSizeCurrent 268435456 -r-- HeapSizeMax 268435456 -r-- Incremental false -r-- JVMDescription Oracle JRockit Java Virtual Machine -r-- JavaVMVendor BEA Systems, Inc. -r-- JavaVendor BEA Systems, Inc. -r-- JavaVersion 1.5.0 ...
次の項では、WebLogic Serverサーバー・インスタンスおよびWebLogicドメイン・リソースに関する実行時情報を取得するためのスクリプト例を示します。
例8-1のWLSTオンライン・スクリプトは、ドメインの実行時階層をナビゲートし、管理対象サーバーのステータスを5秒間隔でチェックします。このスクリプトは、サーバーの状態がRUNNINGから他のステータスに移行した場合に、サーバーを再起動します。ここでは、WLSTがWebLogicドメインの管理サーバーに接続されていることが前提となります。
このスクリプトを実行する方法については、「WLSTの呼出し」を参照してください。
例8-1 サーバー状態のモニター
# Node Manager needs to be running to run this script.
import thread
import time
def checkHealth(serverName):
while 1:
slBean = getSLCRT(serverName)
status = slBean.getState()
print 'Status of Managed Server is '+status
if status != "RUNNING":
print 'Starting server '+serverName
start(serverName, block="true")
time.sleep(5)
def getSLCRT(svrName):
domainRuntime()
slrBean = cmo.lookupServerLifecycleRuntime(svrName)
return slcBean
例8-2のWLSTオンライン・スクリプトは、WebLogicドメインに含まれるすべての実行中サーバーのHJVMHeapSizeを監視します。3分ごとにヒープ・サイズをチェックし、指定したしきい値をヒープ・サイズが上回ると、警告を出力します。ここでは、WebLogicドメインの管理サーバーのURLがt3://localhost:7001であることが前提となります。
このスクリプトを実行する方法については、「WLSTの呼出し」を参照してください。
例8-2 JVMヒープ・サイズのモニター
waitTime=300000
THRESHOLD=100000000
uname = "weblogic"
pwd = "welcome1"
url = "t3://localhost:7001"
def monitorJVMHeapSize():
connect(uname, pwd, url)
while 1:
serverNames = getRunningServerNames()
domainRuntime()
for name in serverNames:
print 'Now checking '+name.getName()
try:
cd("/ServerRuntimes/"+name.getName()+"/JVMRuntime/"+name.getName())
heapSize = cmo.getHeapSizeCurrent()
if heapSize > THRESHOLD:
# do whatever is neccessary, send alerts, send email etc
print 'WARNING: The HEAPSIZE is Greater than the Threshold'
else:
print heapSize
except WLSTException,e:
# this typically means the server is not active, just ignore
# pass
java.lang.Thread.sleep(1800000)
def getRunningServerNames():
# only returns the currently running servers in the domain
# return domainRuntimeService.getServerRuntimes()
if __name__== "main":
monitorJVMHeapSize()
if __name__== "main":
monitorJVMHeapSize()
WLSTを使用すると、サーバー・インスタンスのロギングおよびメッセージ出力を構成できます。
構成できるログ属性を判断するには、Oracle Fusion Middleware Oracle WebLogic Server MBeanリファレンスのLogMBeanおよびLogFileMBeanに関する項を参照してください。このリファレンスでは、各属性の有効な値も示されています。
例8-3のWLSTオンライン・スクリプトでは、LogFileMBeanを拡張するLogMBeanの属性を設定します。このスクリプトを実行する方法については、「WLSTの呼出し」を参照してください。
例8-3 ロギングの構成
# Connect to the server
connect("weblogic","welcome1","t3://localhost:7001")
edit()
startEdit()
# set CMO to the server log config
cd("Servers/myserver/Log/myserver")
ls ()
# change LogMBean attributes
set("FileCount", 5)
set("FileMinSize", 400)
# list the current directory to confirm the new attribute values
ls ()
# save and activate the changes
save()
activate()
# all done...
exit()
WebLogic診断フレームワーク(WebLogic Diagnostic Framework: WLDF)は、サーバーおよびアプリケーションによって生成される診断データを収集できる監視および診断フレームワークです。WLDFを構成して、データを収集し、そのデータを様々なソース(ログ・レコード、データ・イベント、および収集されたメトリック)に格納します。詳細は、『Oracle Fusion Middleware Oracle WebLogic Server診断フレームワークの構成と使い方』を参照してください。
WLSTを使用してのWebLogic診断フレームワークの構成を示すサンプル・スクリプトについては、『Oracle Fusion Middleware Oracle WebLogic Server診断フレームワークの構成と使い方』の「WebLogic Scripting Toolの例」を参照してください。
WLSTで収集された診断情報を表示するには、次のいずれかのコマンドを使用してWLDFリポジトリからデータをエクスポートします。
WLSTオフラインの場合、exportDiagnosticDataコマンドを使用します(Oracle Fusion Middleware WebLogic Scripting Toolコマンド・リファレンスのexportDiagnosticDataに関する項を参照)。
WLSTオンラインの場合、exportDiagnosticDataFromServerコマンドを使用します(Oracle Fusion Middleware WebLogic Scripting Toolコマンド・リファレンスのexportDiagnosticDataFromServerに関する項を参照)。