SOA 12.2.1.2.0: Schedule your Integration Workload Statistics (IWS) Report by Command Line

Posted by Dirk Nachbar on Thursday, February 09, 2017
From Oracle SOA Suite 12.2.1 on, Oracle added a nice feature - The Integration Workload Statistics, which you can compare to an Oracle Database AWR report for your SOA Suite.

Kevin King from AVIO Consulting has released for this a really good blog post about the IWS http://www.avioconsulting.com/blog/no-more-hidden-soa-performance-problems

As I am more coming from the Administration site, I prefer to have script-based solutions.

Here I will show you how to scheduled an automated way for the generation of your Integration Workload Statistics including mailing of the report for UNIX platforms:

On your server which is hosting your SOA suite simply perform following steps as SOA Suite Software owner:


cd $HOME
mkdir -p iws_report/logs
cd iws_report

Create in the new folder $HOME/iws_report a script called create_soa_iws_report.ksh with following content:

#!/bin/ksh
#
# Author: Dirk Nachbar
#
# Purpose: Script to create an IWS Report for a given SOA Domain
#          and Managed Server
#
#---------------------------------------------------------------------


#---------------------------------------------------------------------
# CONSTANTS
#---------------------------------------------------------------------
MyName="$(basename $0)"
# Align the value for your Middleware Home directory
MW_HOME=/u00/app/oracle/product/fmw-soa-12.2.1.2.0
WorkDir=`pwd`


#---------------------------------------------------------------------
Usage()
#
# PURPOSE: Verwendung
#---------------------------------------------------------------------
{

  echo "ERR: create_soa_iws_report.ksh called with wrong parameters"
  cat <<_EOI

SYNOPSIS
       create_soa_iws_report.ksh  -d <Domain_Name> -s <ManagedServer> 
               -t <Number of Hours to look back>
               
DESCRIPTION
       
Creation of IWS Report for a given SOA Domain and Managed Server

_EOI


    exit 1
}

#---------------------------------------------------------------------
CheckParams()
#
# PURPOSE: Checks the input Parmeters 
#---------------------------------------------------------------------
{
    if [ "${TheDomain}" = "" ] ; then
        echo "ERR: Missing parameter(s), the flags -d must be used."
        Usage
    fi

    if [ "${TheManagedServer}" = "" ] ; then
        echo "ERR: Missing parameter(s), the flags -s must be used."
        Usage
    fi

    if [ "${TheHoursBack}" = "" ] ; then
        echo "ERR: Missing parameter(s), the flags -t must be used."
        Usage
    fi

}


#---------------------------------------------------------------------
CreateIWSReport()
#
# PURPOSE: Creates an IWS Report for the given ManagedServer
#
#---------------------------------------------------------------------
{

echo "STARTING: Creating IWS Report for ${TheDomain} / ${TheManagedServer} over the last ${TheHoursBack} hours"
HighDate="$(date '+%Y-%m-%dT%H:%M:%S+0200')"

LowDate=$(eval "date '+%Y-%m-%dT%H:%M:%S+0200' -d '${TheHoursBack} hours ago'")

LogFileDate="$(date '+%Y-%m-%d_%H:%M:%S')"

export TheLogFile=${WorkDir}/logs/iws_report_${TheDomain}_${TheManagedServer}_${LogFileDate}.html


${MW_HOME}/oracle_common/common/bin/wlst.sh ${WorkDir}/soa_iws_report.py ${TheManagedServer} ${LowDate} ${HighDate}

echo "DONE: Creating IWS Report for ${TheDomain} / ${TheManagedServer} over the last ${TheHoursBack} hours"
echo "INFO: IWS Report = ${TheLogFile}"


}

#---------------------------------------------------------------------
MailIWSReport()
#
# PURPOSE: Mail the prior create IWS Report 
#
#---------------------------------------------------------------------
{

# Getting the Email Recipients
ConfigFile=${TheManagedServer}.properties

TheMailRecipients="$(cat ${WorkDir}/${ConfigFile} | grep -i "^mailrecipients=" | head -n 1 | cut -d= -f2-)"
TheEmailSubject="IWS for ${TheDomain} - ${TheManagedServer}"

echo "STARTING: Mail the IWS Report ${TheLogFile}"

echo "IWS Report" | mailx -s "${TheEmailSubject}" -a ${TheLogFile} ${TheMailRecipients}

echo "DONE: Mail the IWS Report ${TheLogFile}"

}


#---------------------------------------------------------------------
# MAIN
#---------------------------------------------------------------------

TheDomain=""
TheManagedServer=""
TheHoursBack=""

while getopts d:s:t:h: CurOpt; do
    case ${CurOpt} in
        d) TheDomain="${OPTARG}"        ;;
        s) TheManagedServer="${OPTARG}" ;;
        t) TheHoursBack="${OPTARG}"     ;;
        h) Usage           exit 1       ;;
        ?) Usage           exit 1       ;;
    esac
done
shift $((${OPTIND}-1))

if [ $# -ne 0 ]; then
    Usage
fi


CheckParams

CreateIWSReport

MailIWSReport


Create in the folder $HOME/iws_report a property file with following naming convention <your_managed_server_name>.properties and fill it with following content:

domain.name=<your_domain_name>
soa.url=<your_server_name>:<port_of_your_managed_server>
admin.userName=weblogic
admin.password=<password_of_weblogic_user>
mailrecipients=<email>


Moreover we need in the $HOME/iws_report directory a Python script named soa_iws_report.py with following content:

# ============================================================
#
# Script: soa_iws_report.py
#
# Author: Dirk Nachbar
#
# Purpose: Generates an IWS Report based on input time range
#
# ============================================================

import sys, os, getopt
from java.util import Date
from java.text import SimpleDateFormat
from java.io import File
from java.io import FileOutputStream
from java.io import FileInputStream

# Load the WLS Connection Credential and establish the connection
propInputStream = FileInputStream(sys.argv[1]+".properties")
# propInputStream = FileInputStream("domain.properties")
configProps = Properties()
configProps.load(propInputStream)
domainName=configProps.get("domain.name")
soaURL=configProps.get("soa.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")
LogFile=os.environ['TheLogFile']

connect(adminUserName,adminPassword,soaURL)

getSoaIWSReportByDateTime(sys.argv[1], 0, sys.argv[2], sys.argv[3], 'default', None, 10, 'html', LogFile)
disconnect()



After that validate that the IWS is activated, either by Enterprise Manager Fusion Middleware or with wlst:

cd $ORACLE_HOME/oracle_common/common/bin
./wlst.sh
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> connect('weblogic','<your_weblogic_password>','<your_server_name>:<port_of_your_managed_server>')

# Check the current status of the IWS
wls:/demo_domain/serverConfig/> getSoaIWSStatisticsLevel()

Successfully executed the command. SOA IWS Statistics Level is : OFF

# Check the current Snapshot Interval for IWS
wls:/demo_domain/serverConfig/> getSoaIWSSnapshotInterval()

Successfully executed the command. SOA IWS Snapshot Interval is : 10 minutes.

# List all available Statistics Levels
wls:/demo_domain/serverConfig/> getSoaIWSStatisticsLevelList()

Successfully executed the command. SOA IWS Statistics Level List : 
--------------------------------------------------------------
FINEST
NORMAL
BASIC
MINIMUM
OFF
--------------------------------------------------------------

# Set your IWS Statistics Level, e.g. NORMAL
wls:/demo_domain/serverConfig/> setSoaIWSStatisticsLevel('NORMAL')

# Validate your IWS Statistics Level
wls:/demo_domain/serverConfig/> getSoaIWSStatisticsLevel()

Successfully executed the command. SOA IWS Statistics Level is : NORMAL

wls:/demo_domain/serverConfig/> exit()


Perform some activities on your SOA Suite and after some time run the create_soa_iws_report.ksh:

cd $HOME/iws_report
./create_soa_iws_report.ksh
ERR: Missing parameter(s), the flags -d must be used.
ERR: create_soa_iws_report.ksh called with wrong parameters

SYNOPSIS
       create_soa_iws_report.ksh  -d <domain_name> -s <managedserver> 
               -t <Number of Hours to look back>
               
DESCRIPTION
       
Creation of IWS Report for a given SOA Domain and Managed Server

./create_soa_iws_report.ksh -d demo_domain -s soa_server1 -t 1

STARTING: Creating IWS Report for demo_domain / soa_server1 over the last 1 hours

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://soaserver1:7004 with userid weblogic ...
Successfully connected to managed Server "soa_server1" that belongs to domain "demo_domain".

Warning: An insecure protocol was used to connect to the server. 
To ensure on-the-wire security, the SSL port or Admin port should be used instead.


Successfully executed the command. Report generated in the file given.

Disconnected from weblogic server: soa_server1
DONE: Creating IWS Report for demo_domain / soa_server1 over the last 1 hours
INFO: IWS Report = /home/oracle/iws_report/logs/iws_report_demo_domain_soa_server1_2017-02-09_15:58:23.html
STARTING: Mail the IWS Report /home/oracle/iws_report/logs/iws_report_demo_domain_soa_server1_2017-02-09_15:58:23.html
DONE: Mail the IWS Report /home/oracle/iws_report/logs/iws_report_demo_domain_soa_server1_2017-02-09_15:58:23.html


Now you should find in your Inbox for your Mail your IWS Report and under the $HOME/iws_report/logs directory the generated HTML IWS Report.