Thursday, September 2, 2010

WLST script to monitor JMS messages and heap

Inspired by this document:
http://download.oracle.com/docs/cd/E13222_01/wls/docs100/config_scripting/monitoring.html


For more info on JMS metrics, see here:
http://download.oracle.com/docs/cd/E11035_01/wls100/javadocs_mhome/weblogic/management/runtime/JMSDestinationRuntimeMBean.html


#########################################################################
#
# This script will monitor a queue over time
# Author : Pierluigi Vernetto
#
#########################################################################
 
from java.util import Date
 
ucf='PVWebLogicConfig.properties'
ukf='PVWebLogicKey.properties'
serverurl='t3://osb.acme.net:8311'


 
def JmsStat():

 connect(userConfigFile=ucf, userKeyFile=ukf,url=serverurl)
 serverRuntime()
 servername = 'dev3OsbLABMs1'
 while 1:
  cd('/JMSRuntime/' + servername + '.jms/JMSServers/myJmsServer_1/Destinations/MQGEOSystemModule!myJmsServer_1@MQGEOQueue')
  messagesCurrentCount= cmo.getMessagesCurrentCount()
  messagesTotal= cmo.getMessagesReceivedCount()
  cd('/JVMRuntime/'+servername)
  heapfree = cmo.getHeapSizeCurrent()
  date = Date() # now
  print '%14s   %5d %6d %12d' %  (date, messagesCurrentCount, messagesTotal, heapfree)
  java.lang.Thread.sleep(10000)

 
 
if __name__== "main":
        redirect('jmsmonitor.log', 'false')
        JmsStat()




No comments: