Display Oracle Forms 12c Sessions with WLST

Posted by Dirk Nachbar on Friday, August 25, 2017 with No comments
Sometimes you want to get a quick overview of the current connected Forms Sessions in your Oracle Forms 12c environment and the Fusion Middleware Control (http://<servername>:7001/em) is sometimes really slow reacting.

Under the My Oracle Support (MOS) Note 1580517.1 you can find a small handy Python Script, which should display you all informations about your current Forms Sessions against a specific Managed Server hosting your Forms Application. But with Oracle Forms 12c this is not longer working out of box.

Under Oracle Forms 12c the DMS nouns are not converted to MBeans by default and the MOS Script is based on an access to "oracle.dms:type=FormsRuntimeInfo".

So at first you need to enable the DMS Nouns MBeans on your Managed Server hosting your Oracle Forms Application. For this simply connect with WLST to your Admin Server of your WebLogic Server and perform following steps:

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

# Replace Username, Password, Server plus Port with your settings
wls:/offline> connect('weblogic','welcome1','localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server "FRTESTAdminServer" that belongs to domain "FRTEST".

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.

wls:/FRTEST/serverConfig/> updateDMSEventRoute(destinationid="mbeanCreationDestination", enable="true", server="<Servere Name>")
# For example
wls:/FRTEST/serverConfig/> updateDMSEventRoute(destinationid="mbeanCreationDestination", enable="true", server="WLS_FORMS;")
wls:/FRTEST/serverConfig/> exit()

After that restart your Managed Server and from now on you have the DMS nouns converted to MBeans which can be accessed via WLST.

In addition, I found from an unknown author a nice modification of the provided script from the MOS Note 1580517.1, which can be found here http://yong321.freeshell.org/oranotes/FormsServerSessionMonitor.txt (in case you are the author or you know the author, please drop me a comment here, merci)

This script, is quite nice, but I modified it on top, so that you get for each execution of the script a logfile with timestamp in the logfile name and I added a more secure way for the connect data to your Managed Server.

What you will need now are 2 file:
  • domain.properties: which contains your connection details to your Managed Server and the location of the logfile
  • mon_frm_sessions.py: Python Script which retrieves the current running Forms Sessions including Client IP, DB Username, DB Session ID, Forms Session PID, Forms Section Name (from formsweb.cfg)
Create the property file named domain.properties and set the permission to 600 (chmod 600 domain.properties):

# Replace with your hostname and Port of Managed Server
# Replace with your Password
# Replace with your Username
# Replace with your preferred Logfile Location
# Please note, the trailing slash at the end is needed !

As next create the mon_frm_sessions.py

import sys
import re
import os
from datetime import datetime
from java.io import File
from java.io import FileOutputStream
from java.io import FileInputStream

# Load Connection Properties
propInputStream = FileInputStream("domain.properties")
configProps = Properties()

# Construct the Logfile with Timestamp
LogFileName = logFileLocation +'mon_frm_sessions-%s.log'%datetime.now().strftime('%Y_%m_%d_%H_%M_%S')

redirect('/dev/null', 'false')
# Perform connection to Managed Server hosting Forms App
cd ('oracle.dms')
children = ls()
childList = children.split("\n");
f = open(LogFileName, 'a')
f.write("\n" + datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "\n")
# Printout for stdout
print "Config\tDBName\tDBSessID\tClientIP\tPID\tUser"
for child in childList:
  childInfo = child.split(' ');
  length = len(childInfo);
  if (len(childInfo) > 2 and re.match('oracle.dms:type=FormsRuntimeInfo,name=/frmDMS/\d',childInfo[3])):
     attrs = ls();
     attrList = attrs.split("\n");
     for attr in attrList:
       if (attr.find("config_value") != -1 or attr.find("dbname_value") != -1 or attr.find("dbsessid_value") != -1 or attr.find("ip_value") != -1 or attr.find("pid_value") != -1 or attr.find("user_value") != -1):
            vl = attr.split()[2]+'\t'
          except IndexError:
            vl = '\t'
     cd ('..')
print " "
print "Logfile are generated: " + LogFileName

And now you can execute the above Python Script with WLST

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

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Config  DBName  DBSessID        ClientIP        PID     User
test    DB122   1145      10313   scott
demo    DB122   1234      21330   scott

Logfile are generated: /u00/app/oracle/logs/mon_frm_sessions-2017_08_25_15_40_54.log

Enjoy displaying your current Forms Sessions without connecting to the Fusion Middleware Control :-)