Capture Metrics Using the Dynamic Monitoring Service

In addition to the Metrics Browser in Fusion Middleware Control, you can view metrics using the Dynamic Monitoring Service (DMS) and WLST commands.

This section describes how to use these methods.

Use the Dynamic Monitoring Service for Metrics

You can use the Dynamic Monitoring Service (DMS) to view metrics.

Access the service using the following URL:

http://<host>:<AdminServer port>/dms

Using the Metrics Tables list in the left pane, select Non-J2EE Metrics to view the list of metrics for Oracle Analytics Server. This is the same list that you see in the Metrics Browser of Fusion Middleware Control.

You can use the Dynamic Monitoring Service to quickly obtain a snapshot of metrics. You can use the URL for a given metric as the source for a web query in a Microsoft Excel spreadsheet that you combine with a macro that automatically copies values to an archive sheet and refreshes the query on a loop for a given period.

Suppose that you want to use the Dynamic Monitoring Service to see the details of the metric table called Oracle_BI_General. When you click the Oracle_BI_General link in the Metrics Tables list, the table is displayed on the right side. This metric table consists of several monitored values, such as Active_Execute_Requests and Total_Sessions. You can use the information from the tables that are displayed in this Metrics Browser as part of WLST commands.

For information on accessing DMS metrics using WLST commands, see Use WLST Commands for Metrics..

Use WLST Commands for Metrics

Using WLST, you can collect metrics about the system.

You can use WLST commands to capture metrics.

  1. Navigate to the ORACLE_HOME/oracle_common/common/bin directory.
  2. Run the WLST utility.
  3. Connect to the system using the connect command, as shown in the following example:

    connect('user','password','t3://<host><port>)

  4. View the following prompt:

    wls:/bi/serverConfig>

You can now interactively use the DMS custom WLST commands. For example, to list all the metric tables that start with "Oracle_BI", enter the following command:

wls:/bifoundation_domain/serverConfig> displayMetricTables('Oracle_BI*')

This command generates a long list of data for each of the Oracle BI metric tables. So it is more useful to focus on a given metric table, such as "Oracle_BI_General". The following command displays output such as that shown in this sample.

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

Using the scripting capability of WLST, you can embed DMS commands into a Python script to store the required metric values in a file. The following is an example of such a script.

# 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','password','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()

Certain Oracle BI metric tables, such as "Oracle_BI_Thread_Pool", are in effect two-dimensional. With the "Oracle_BI_Thread_Pool" table, you can query the metric values for various "Names", such as "Server" or "Usage_Tracking". To export the required metric value to a file in this case, you must modify the logic that was used in looping in the previous example script to handle the two dimensions. The following example script provides one way to handle this case.

# 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','password','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()