Monitoring JMS Queues by WLST

The modules of Weblogic Domain monitor with different ways. Weblogic Scripting Tool (WLST) is good choice which based on the java version of python scripting (Jython).

Jython is a high level, dynamic, object-oriented programming language. Its compiler completely written in Java compiler. It allows to use  Python and Java libraries together.

Different resources can configure with WLST in WebLogic Server.  Also, it shows easy way to monitor many resources like Heap Percentage, WebLogic Instance Health, JMS Data sources… etc.

Let’s talk about the script which monitor Java Messaging Service queue count . You can find main program logic at below. Professional perspective is needed to understand the main program code.

JMS Queue Monitoring by WLST

JMS Queue Monitoring by WLST

I’ve added comment rows in the WLST code which will help you to understand and use it.

#Checks JMS Queues and prints the number of accumulated messages.
#Optional numeric argument can be passed in order to limit queues to a lower count limit.
#Conditionally import wlstModule only when script is executed with jython
if __name__ == '__main__': 
    from wlstModule import *#@UnusedWildImport

#Connect to the server
def connectTOJMS():    
	username = '*******'
	password = '********'
	url='**********'
	print 'connecting to JMS server ...'
	connect(username,password,url)

def getQueueLimit(default = 3):
	if len(sys.argv) == 2 and sys.argv[1].isdigit():
		return sys.argv[1]
	else:
		return default

#Get to the JMSDestinationRuntimeMBean
def monitorRunningServers():
	#connect to server    
	connectTOJMS()

	#get queues
	print 'Getting queues...'
	print ''
	print 'Excluding _TMP queues...'
	print ''	
	limit = int(getQueueLimit())
	allofQueues = getDestinationsBiggerThan(limit)
	mxPendingOnly = getDestinationsMXBiggerThan(limit)
    #sort in reverse order
    #queues.sort()
    #queues.reverse()

    #print in columns
	a = prettyPrint(allofQueues)
	b = prettySum(allofQueues)
	prettyPrintMXONLY(mxPendingOnly,a,b)

def prettyPrint(allofQueues):    
	sum=0
	j=0

	for allofQueues in allofQueues:
		allofQueues.sort()
		allofQueues.reverse()
		x=0
		print ''
		if len(allofQueues):

			for queuex in allofQueues:

				print str(queuex[0]).rjust(7),queuex[1]
				x = x + int(queuex[0])
				if "_to_aTTIP" in str(queuex[1]):
					j=j+int(queuex[0])
			print '||'
			print '||__________' + queuex[2] + 'Queues Total:	' , + x
			sum = sum+x

	print '||'
	print '||__________' + '' + 'Sum of all Queues:		' , + sum
	return j

def prettySum(allofQueues):    
	sum=0
	j=0
	for allofQueues in allofQueues:
		allofQueues.sort()
		allofQueues.reverse()
		x=0
		print ''
		if len(allofQueues):

			for queuex in allofQueues:

				print str(queuex[0]).rjust(7),queuex[1]
				x = x + int(queuex[0])
				if "_to_aTTIP" in str(queuex[1]):
					j=j+int(queuex[0])

			sum = sum+x
	return sum

def prettyPrintMXONLY(mXQueues,m,k):    
	sum=0

	for mXQueues in mXQueues:
		mXQueues.sort()
		mXQueues.reverse()
		x=0
		print ''
		if len(mXQueues):

 

 

 

 

Tags: , ,

About the Author

Ayten Sarifakioglu is a Middleware Consultant and works onsite at Turk Telekom, Ankara. She daily operates high level, mission critical OSB and SOA domains successfully.

Post a Reply

Your email address will not be published. Required fields are marked *

Top