Search This Blog

Oracle Fusion Middleware Administration Course

Oracle Fusion Middleware Administration Course
OFMW Admin Course

Saturday, November 14, 2009

JMS Monitoring using WLST

Let me walk through the script, The script is referring to a secure way of user credential usage in the WLST that is given here .

storeUserConfig() command in WLST can generates 2 file suserKeyFile, userConfigFile. These we can use multiple times in the script so I declared it on the top, Global scope variables, which can be used by any method in the script.
Coming to downside of the script, where you can find the main program logic. We need to understand from the main program onwards that is the good programmer reading habit :).

In the main module we don't want to see unnecessary data while running the script just want to see , so redirect useless data. first connect to the admin server in the domain.

Initialization of the URL dictionary for multiple server instances domain. The JmsStat module will tell you the actual status of each JMSRumtime Mbeans.

Here I got two hurdles the all script output is not from same MBean. I need to display the JMS statics from JMSRuntime MBean and need to navigate to the instance's specific JMS.

The list (ls) content need to store in variable and need to cding (cd)
myJmsls=ls(returnMap='true')

This makes turning point for the following script we surf for this found Satya Gattu Answer in ObjectMix.

Here (myJmsls) variable holds the value into list datastructure. Just by pointing index the value will be returned.

################################################################# 
# This script will  get the jms attributes
# Author : Prasanna Yalam
# Updated by: Pavan Devarakonda
################################################################# 

from java.util import Date

ucf='ursec'
ukf='urkey'
admurl='t3://url'
urldict={}

def conn():
try:
 connect(userConfigFile=ucf, userKeyFile=ukf, url=admurl)
except ConnectionException,e:
 print 'Unable to find admin server...'
 exit()
def initalize():
 serverlist= ['app010','app011',...]
 for svr in serverlist:
 cd("/Servers/"+svr)
 urldict[svr]='t3://'+get('ListenAddress')+':'+str(get('ListenPort'))

def JmsStat():
 d = Date() # now
 print  d 

 print 'Instance         ConCur ConHi ConTot High  MsgCur MsgPnd'
 print 'Name             Count  Count Count  Count Count  Count'
 print '===========**=======**==================================' 
 Ks = urldict.keys()
 Ks.sort()

 for key in Ks:
  try:
   connect(userConfigFile=ucf, userKeyFile=ukf,url=urldict[key])
   serverRuntime()
   cd('JMSRuntime/'+key+'.jms/JMSServers')
   curCnt= get('ConnectionsCurrentCount')
   cHiCnt=get('ConnectionsHighCount')
   cTotCnt=get('ConnectionsTotalCount')

   myJmsls=ls(returnMap='true')
   x=myJmsls[0]
   cd(x)

   hiCnt= get('MessagesHighCount')
   currCnt= get('MessagesCurrentCount')
   pendCnt= get('MessagesPendingCount')
   print '%14s   %4d   %4d  %4d  %4d  %4d  %4d' %  (key, curCnt, cHiCnt, cTotCnt,  hiCnt, currCnt, pendCnt) 
  except:
   print 'Exception...in server:', key
   pass
 quit()

def quit():
 d = Date() # now
 print  d
 print 'Hit any key to Re-RUN this script ...'
 Ans = raw_input("Are you sure Quit from WLST... (y/n)")
 if (Ans == 'y'):
  disconnect()
  stopRedirect() 
  exit()
else:
 JmsStat()

if __name__== "main":
 redirect('./logs/jmsCnt.log', 'false')
 conn()
 initalize()
 JmsStat()

5 comments:

  1. Hi Pavan, i'm a novice python/jython/wlst scripting.
    i'm trying to implement this sample on my trial environment, but launching the script (with my environment data) i got these errors trying tu run the script by the BEA script runWLST.sh monitorJMS.py and runWLST.sh mJms.py

    error #1
    =================
    Problem invoking WLST - Traceback (innermost last):
    (no code object) at line 0
    File "/app/bea/user_projects/domains/trialDomain/scripts/WLST_Configs/monitorJMS.py", line 5
    print "Instance ConCur ConHi ConTot High MsgCur MsgPnd"
    ^
    SyntaxError: invalid syntax
    ==================

    error #2
    ==================
    Problem invoking WLST - Traceback (innermost last):
    (no code object) at line 0
    File "/app/bea/user_projects/domains/trialDomain/scripts/WLST_Configs/mJms.py", line 8
    try:
    ^
    SyntaxError: invalid syntax
    ====================


    it seems that something wrong 'bout some library missing, dont you?

    i simplified your script doing one step of your looping script through the mbean tree, writing line by line at wlst prompt, once connected to domain and i retrieved correctly the jms resource on one server.

    can you help me understanding what's wrong?

    from scratch, which kind of command can i load so your script (JMS MONITORING.py) can be load correctly ?

    ReplyDelete
  2. May be it is indentation issue.
    every try: block, if block, for loop block required one tab in each line in the block.

    Expected changes in this script are user credentials, admin url, and JMS targeted servers list(line 22).

    The script will first fetches server wise URLs and connects to each server instance to know the JMS que status as mentioned in the script JMS parameters.

    you can try to navigate at wlst prompt so that you can clear understand that script.

    After Refreshing the blog you might get some clear idea about how the script works, I had updated it.

    ReplyDelete
  3. Hi Pavan,
    i must thank you for your immediate response to my request, what i can say: GREAT!
    Your suggestions was very precious.
    I didn't know that the indentetion in python/jython was a "must" (i'm just learnig about python/jython)
    Anyway, i just modified your script to monitoring multiple JMS server and multiplied destination and multiplied, inserting 4 level of nested for loop to loop in every JMS server and queues.
    Now, my next step will be to integrate a wlst/jython script in an JSP page.
    I will stay tuned on your blog and i hope to share something of my BEA WLS Administration experience with you.
    Bye

    ReplyDelete
  4. I want to capture the payload details coming into OSB, and store the payload into a custom table. Is it doable using WLST script. I am experimenting & exploring WLST scripting.

    ReplyDelete
  5. Till read to your post I don't know the phenomena of jms monitoring using wls and I try this in my Weblogic Training practicals.Thank You.

    ReplyDelete

Please write your comment here

Popular Posts

Oracle WebLogic Administration Course

Oracle WebLogic Administration Course
WebLogic Training

Followers