An Odyssey of discovery

Thursday, February 28, 2008

Weblogic Monitoring Scripts

Often times when it comes to monitoring usage and uptime of PeopleSoft Weblogic Web Server, the approach seems very basic and straight forward for most PSADMINs - "grep for java". When you are involved in multiple stress/load testing initiatives, it pretty much becomes obvious that "grepping for java" is not enough to ascertain real-time status of your web server domain. In a stress/loading testing situation, your java heap is constantly drained of memory which is directly equivalent to the number load on your web server. After several failed attempts to get a true picture of my web server domain, I had to dig deeper for a viable solution and found out about Weblogic Scripting Tool called WLST. Though not a PeopleSoft certified tool, WLST has long been used by BEA Weblogic Developers since the release of Weblogic 8.1.

WLST - What is it ?

The WebLogic Scripting Tool is a BEA tool for scripting the configuration of BEA WebLogic domains. WLST is available as a developer release for WebLogic 8.1 on the BEA dev2dev web site. BEA includes WLST as part of WebLogic Server 9.x. WLST uses a powerful scripting language called Jython (a mix of Python and Java programming languages). WLST is available in two flavors:
• WSLT Online: can be used to query and modify a running WebLogic Server domain.
• WLST Offline: can be used to build WebLogic domains without requiring a running WebLogic Server domain.

How it Works

Weblogic Server includes a large number of MBeans (Managed Beans) which provides information about the runtime state of its resources. To access runtime information, you need to invoke WLST and connect to the running administrative server. The Weblogic Scripting Tool (WLST) is a command line scripting interface for Weblogic Server. The WLST scripting environment is based on Java scripting interpreter called Jython. Commands can be interpreted interactively from a command prompt or in batches supplied in a file (script).

Steps For Using WLST in PeopleSoft Weblogic Server

1. Download jython.jar and wlst.jar from www.jython.org/download.html
2. Add the following jar files to the Weblogic CLASSPATH environment variable – weblogic.jar, jython.jar, wlst.jar
3. Name script with .py extension. This is really important otherwise, you get an error when you run the script.
4. To invoke WLST; at the command prompt enter the following command – java weblogic.WLST

Below is an example of a script I wrote to monitor JVM usage, web server status and sessions. The script is pretty basic but you can incorporate logic if you want a more robust monitoring.

####################################################################
# This script monitors web server status, JVM usage, and Active Session Count
# Usage - java weblogic.WLST $SCRIPTNAME
# Note - Make sure the following is set on your $CLASSPATH before running
# script - wlst.jar,jython.jar,weblogic.jar
#
# Author - Troy Akitoye
# Date - Today
######################################################################

# Redirect stdout to a logfile #

redirect('/apps/ps/webserv/peoplesoft/Monitoring.log')

# User details to connect to the weblogic admin server #

username = 'system'
password = 'password'
url = 't3://mdsua0rq:7001'
connect(username,password,url)
runtime()
cd("/ServerRuntimes/""/PIA")
ServerName = cmo.getAdminServerHost()
ListenAddress = cmo.getSSLListenAddress()
ServerState = cmo.getState()
cd("/ServerRuntimes/""/PIA/""/JVMRuntime/""/PIA")
totaljvm = cmo.getHeapSizeCurrent()
freejvm = cmo.getHeapFreeCurrent()
usedjvm = int(totaljvm) - int(freejvm)
cd("/ServerRuntimes/""/PIA/""/ApplicationRuntimes/""/PIA_peoplesoft/""/ComponentRuntimes/""/PIA_PIA_peoplesoft_PORTAL")sessioncounts = cmo.getOpenSessionsCurrentCount()

print '***************************************************'
print "......Now Checking Weblogic Web Server on" , ServerNameprint "Listening on" , ListenAddress print "Server Status :" , ServerState
print "Total JVM =" , int(totaljvm)
print "Free JVM =" , int(freejvm)
print "Used JVM =" , int(usedjvm)
print "Total Active Session(s) =" , int(sessioncounts)
print '****************************************************'

exit()
stopRedirect()

Below is output file (Monitoring.log)

Re-directing output to /apps/ps/webserv/peoplesoft/Monitoring.log

Connecting to weblogic server instance running at t3://mdsuaorq:7001 as username system ...

Successfully connected to Admin Server 'PIA' that belongs to domain 'peoplesoft'.

***************************************

Server Status =RUNNING
Total JVM =259522560
Free JVM =133010624
Total Active Sessions =1
***************************************

Exiting WLS scripting shell



3 comments:

Steven said...

Hi, good tutorial. Can you tell me where i can download wlst.jar from? I went to jython.org/download.html but did not find either of the jar files there.

Thanks.

Harish Chandra said...

I tried to log the stdout in file. But I did not see the "print" message in log file. I can see the message that is print by the WLST default.

Can you please let me know "How to log the own message... I mean print..

lauren said...

i knew that WLST is WebLogic Scripting Tool is a BEA tool for scripting the configuration of BEA WebLogic domains but i was not knowing how it works thanks for sharing such an informative blog
digital certificate

About Me

This blog will cover my day to day experience working as PeopleSoft Admin/DBA consultant. I will discuss pertinent technical issues, tips and architecture of PeopleSoft Infrastructure. It will also cover various PeopleTool sets, Enterprise Application modules, upgrades and industry best practice as it relates to the configuration and administration of PeopleSoft instance.

Blog Archive