Search This Blog

Friday, June 22, 2012

WLST JMS monitoring stats to CSV file

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
  1. Open a file with write access.
  2. Get the RUNNING servers of the domain from domainRuntimeService.
  3. Print the headers of JMS counters.
  4. Get the details of JMS servers using JMSRuntime and JMSServers functions.
  5. Using a loop get the jms server destinations.
  6. Using a loop get the details of the parameters like ConsumersCurrentCount, ConsumersHighCount etc of the destinations and store those to variables.
  7. Print the variables.
  8. 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()

1 comment:

  1. Win Exciting and Cool Prizes Everyday @ www.2vin.com, Everyone can win by answering simple questions.Earn points for referring your friends and exchange your points for cool gifts.

    ReplyDelete

Please write your comment here

Popular Posts