Intro: We got a mail from Richard who wish to write a WLST script to monitor a JMS Runtime. The Queue performance details wish to collect.
WLST script to monitor JMS and store the attribute values when there is Production live available or Performance test run going on with multiple user load collect the statistcs and send that into a separate CSV file. Just to give little idea on CVS, A comma-separated values (CSV) file are also referred as a flat files, ascii files, and it is a spreadsheet convertible files. Richi want the logic to storing the statistics to a .csv file. Thought that it will be helpful for anyone who may have similar thoughts. We got the script idea from Richi that consisting the following prototype.
Writing to a CVS file has been simplified without using writer.csv, instead commas have been used and the file extension is hard coded as .csv, once you open the file you will see a prompt where in you need to select comma as the delimeter so that the values of jms statistics will be sorted accordingly, you can modify the script as per your need.
The script flow will be as mentioned below
WLST script to monitor JMS and store the attribute values when there is Production live available or Performance test run going on with multiple user load collect the statistcs and send that into a separate CSV file. Just to give little idea on CVS, A comma-separated values (CSV) file are also referred as a flat files, ascii files, and it is a spreadsheet convertible files. Richi want the logic to storing the statistics to a .csv file. Thought that it will be helpful for anyone who may have similar thoughts. We got the script idea from Richi that consisting the following prototype.
Writing to a CVS file has been simplified without using writer.csv, instead commas have been used and the file extension is hard coded as .csv, once you open the file you will see a prompt where in you need to select comma as the delimeter so that the values of jms statistics will be sorted accordingly, you can modify the script as per your need.
The script flow will be as mentioned below
- Open a file with write access.
- Get the RUNNING servers of the domain from domainRuntimeService.
- Print the headers of JMS counters.
- Get the details of JMS servers using JMSRuntime and JMSServers functions.
- Using a loop get the jms server destinations.
- Using a loop get the details of the parameters like ConsumersCurrentCount, ConsumersHighCount etc of the destinations and store those to variables.
- Print the variables.
- Close the file.
################################################## #Title: WLST script to monitor JMS runtime and saving the values to CSV file #Author: Sunil Nagavelli/Pavan Bhavani Shekar Devarakonda # ################################################### import sys
file1=open('JMS.csv','w+')
servers = domainRuntimeService.getServerRuntimes();
print>>file1, " ConsumersCurrentCount: ", ",", " ConsumersHighCount: ", ",", " DestinationType: ", ",", " BytesHighCount: ",
",", " BytesPendingCount: "
if (len(servers) > 0):
for server in servers:
jmsRuntime = server.getJMSRuntime();
jmsServers = jmsRuntime.getJMSServers();
for jmsServer in jmsServers:
destinations = jmsServer.getDestinations();
for destination in destinations:
CCC = destination.getConsumersCurrentCount()
CHC = destination.getConsumersHighCount()
DT = destination.getDestinationType()
BHC = destination.getBytesHighCount()
BPC = destination.getBytesPendingCount()
print>>file1,CCC, ",", CHC, ",", DT, ",", BHC, ",", BPC
print "values have been captured successfully into the csv file"
file1.close()