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()

Popular Posts

Oracle WebLogic Administration Course

Oracle WebLogic Administration Course
WebLogic Training

Followers