メトリックへのWLSTコマンドの使用
WLSTを使用すると、システムに関するメトリックを収集できます。
WLSTコマンドを使用してメトリックを取得できます。
これで、DMSカスタムWLSTコマンドを対話的に使用できるようになりました。たとえば、先頭にOracle_BIが付くすべてのメトリック表を表示するには、次のコマンドを入力します。
wls:/bifoundation_domain/serverConfig> displayMetricTables('Oracle_BI*')
このコマンドでは、Oracle BIのメトリックごとにデータの長大なリストが生成されます。そのため、Oracle_BI_Generalなどの特定のメトリック表に焦点を絞ったほうが役立ちます。次のコマンドでは、次に示すサンプルのような出力が表示されます。
wls:/bifoundation_domain/serverConfig> displayMetricTables('Oracle_BI_General')
----------------- Oracle_BI_General ----------------- Active_Execute_Requests.value: 0 Active_Fetch_Requests.value: 0 Active_File_Handles.value: 1 Active_Initblock_Executions.value: 0 Active_Logins.value: 0 Active_Prepare_Requests.value: 0 Avg._Failed_Logins_Elapsed_Time.value: 0 Avg._Initblock_Executions_Elapsed_Time.value: 0 Avg._Succeeded_Logins_Elapsed_Time.value: 0 Avg._query_elapsed_time.value: 0 Busy_File_Handles.value: 0 File_Handle_Waiters.value: 0 Free_File_Handles.value: 502 Host: oracle-bc5ac6af Max._Initblock_Execution_Elapsed_Time.value: 0 Max_File_Handles.value: 503 Name: Oracle BI General New_Execute_Requests.value: 19 New_Fetch_Requests.value: 32 New_Initblock_Executions.value: 0 New_Logins.value: 7 New_Prepare_Requests.value: 19 New_Requests.value: 187 OBPERF_***.value: 7 Oracle_BI_Applications: Oracle BI Server Parent: /Oracle BI Server Process: Oracle BI Server:4004:/instance1/coreapplication_obis1 Queries/sec.value: 0 ServerName: /instance1/coreapplication_obis1 Succeeded_Initblock_Execution_Ratio_as_%.value: 0 Succeeded_Logins_Ratio_as_%.value: 7 Total_sessions.value: 0
WLSTのスクリプト作成機能を使用してDMSコマンドをPythonスクリプトに組み込み、必要なメトリック値をファイルに格納できます。次にこのようなスクリプトの例を示します。
# Script to dump timestamp (in milliseconds) for a single Oracle BI metric
# to a file
#
from java.util import Date
from java.text import SimpleDateFormat
#
# Modify to connect to your server
connect('biadmin','welcome1','t3://localhost:9500')
#
# This is the number of times to sample the metric
sample_length = 100
#
# This is where you define what metric table and metric to dump to file
metric_table = "Oracle_BI_General"
metric_of_interest = "Avg._query_elapsed_time.value"
#
# Some metrics have non-text characters in the name. Provide a reference here
# so it dumps to file without error in file name
output_file_metric_ref = "Avg_Qry_Elapse"
#
# This section defines the output file name with unique time
start_time = str(SimpleDateFormat("dd-MMM-yyyy_HH-mm-ss").format(Date()))
output_filename = start_time + "_" + output_file_metric_ref + "_dump.txt"
#
# Open the file and write summary of metric to be dumped
file = open(output_filename,'w')
print >>file, "Start Metric Dump of: " + str(metric_table) + " : " + str(metric_of_interest) + " at " + str(SimpleDateFormat("dd-MMM-yyyy HH-mm-ss").format(Date()))
#
#
# The following section forms a loop according to the sample length defined
# earlier. The 'displayMetricTables()' command returns the metric table in the
# form of a JMX composite data array. The code following this command access
# the metric data from this array. In this case, a particular metric of
# interest is tested for and only the value of that metric is output to file.
#
counter = 0
while counter <= sample_length:
results = displayMetricTables(metric_table)
for table in results:
name = table.get('Table')
rows = table.get('Rows')
rowCollection = rows.values()
iter = rowCollection.iterator()
while iter.hasNext():
row = iter.next()
rowType = row.getCompositeType()
keys = rowType.keySet()
keyIter = keys.iterator()
while keyIter.hasNext():
columnName = keyIter.next()
value = row.get(columnName)
if columnName == metric_of_interest:
print >>file, str(SimpleDateFormat("dd-MMM-yyyy HH-mm-ss-SSS").format(Date())) + "," + str(value)
counter = counter + 1
file.close()
disconnect()
「Oracle_BI_Thread_Pool」などの一部のOracle BIメトリック表は、実際には2つのディメンションで構成される表です。「Oracle_BI_Thread_Pool」表では、「Server」や「Usage_Tracking」などの様々な「名前」のメトリック値の問合せを実行できます。この場合、必要なメトリック値をファイルにエクスポートするには、前のスクリプト例のループで使用しているロジックを、2つのディメンションを扱うように変更する必要があります。次のスクリプト例では、このような場合の処理方法の1つを示しています。
# Script to dump timestamp (in milliseconds) and a
#single Oracle BI metric to a file for metrics with multiple sections
#
from java.util import Date
from java.text import SimpleDateFormat
#
# Modify to connect to your server
connect('biadmin','welcome1','t3://localhost:9500')
#
# This is the number of times to sample the metric
sample_length = 100
#
# This is where you define what metric table, category, and metric to
# dump to file
metric_table = "Oracle_BI_Thread_Pool"
category_of_interest = "Server"
metric_of_interest = "Avg._Request/sec.value"
#
# Some metrics have non-text characters - provide a reference here
# so it dumps to file without error
output_file_metric_ref = "Avg_Req_Sec"
#
# This section defines the output file name with unique time
start_time = str(SimpleDateFormat("dd-MMM-yyyy_HH-mm-ss").format(Date()))
output_filename = start_time + "_" + output_file_metric_ref + "_dump.txt"
#
# Open the file and write summary of metric to be dumped
file = open(output_filename,'w')
print >>file, "Start Metric Dump of: " + str(metric_table) + " : " + str(metric_of_interest) + " for Category: " + str(category_of_interest) + " at " + str(SimpleDateFormat("dd-MMM-yyyy HH-mm-ss").format(Date()))
#
#
counter = 0
while counter <= sample_length:
results = displayMetricTables(metric_table)
for table in results:
name = table.get('Table')
rows = table.get('Rows')
rowCollection = rows.values()
iter = rowCollection.iterator()
while iter.hasNext():
row = iter.next()
if row.containsValue(category_of_interest):
rowType = row.getCompositeType()
keys = rowType.keySet()
keyIter = keys.iterator()
while keyIter.hasNext():
columnName = keyIter.next()
value = row.get(columnName)
if columnName == metric_of_interest:
print >>file, str(SimpleDateFormat("dd-MMM-yyyy HH-mm-ss-SSS").format(Date())) + "," + str(value)
counter = counter + 1
file.close()
disconnect()