this tool helps to mointor connection pool during performance testing
import java.io.*; import java.util.Iterator; import java.util.ResourceBundle; import java.util.Set; import javax.naming.Context; import weblogic.jndi.Environment; import weblogic.management.MBeanHome; import weblogic.management.configuration.ExecuteQueueMBean; import weblogic.management.runtime.JDBCConnectionPoolRuntimeMBean; import weblogic.management.runtime.ExecuteQueueRuntimeMBean; import weblogic.management.WebLogicMBean; import weblogic.management.RemoteMBeanServer; import weblogic.management.runtime.JMSDestinationRuntimeMBean; import weblogic.management.runtime.JVMRuntimeMBean; public class Performance_Monitor { public Performance_Monitor() { } public static void main(String args[]) { Object obj = null; try { Object obj1 = null; Object obj2 = null; int i = 0; Set set = null; Set set1 = null; Set set2 = null; Set set3 = null; Object obj3 = null; Object obj4 = null; System.out.println("*********"); String url=""; String domain=""; String username=""; String password=""; String poolname1=""; String poolname2=""; String ExecuteQueuename1=""; String ExecuteQueuename2=""; String poolcheck=""; String Threadcheck=""; String Heapcheck=""; ResourceBundle prop = null; prop = ResourceBundle.getBundle("Performance"); url=prop.getString("url").trim(); username=prop.getString("username").trim(); password=prop.getString("password").trim(); domain = prop.getString("domain").trim(); poolname1= prop.getString("poolname1").trim(); poolname2= prop.getString("poolname2").trim(); ExecuteQueuename1= prop.getString("ExecuteThreadname1").trim(); ExecuteQueuename2= prop.getString("ExecuteThreadname2").trim(); poolcheck= prop.getString("poolcheck").trim(); Threadcheck= prop.getString("Threadcheck").trim(); Heapcheck= prop.getString("Heapcheck").trim(); try { Environment environment = new Environment(); environment.setProviderUrl(url); environment.setSecurityPrincipal(username); environment.setSecurityCredentials(password); Context context = environment.getInitialContext(); MBeanHome mbeanhome = (MBeanHome)context.lookup("weblogic.management.adminhome"); set1 = mbeanhome.getMBeansByType("JDBCConnectionPoolRuntime"); set2 = mbeanhome.getMBeansByType("ExecuteQueueRuntime"); //Set mbeanSet = home.getMBeansByType("JMSDestinationRuntime"); set3 = mbeanhome.getMBeansByType("JVMRuntime"); } catch(Exception exception1) { System.out.println("Exception caught: 2 " + exception1); } String s4 = null; File file = new File("ExQ.txt"); FileWriter filewriter = new FileWriter(file, true); System.out.println("Monitoring pool......."); do { Iterator iterator1 = set1.iterator(); Iterator iterator2 = set2.iterator(); Iterator iterator3 = set3.iterator(); try { do { if(Threadcheck.equals("Y") || Threadcheck.equals("y")) { // for(int k=0;k<7;k++) while(iterator2.hasNext()) { //if(!iterator2.hasNext()) //break; ExecuteQueueRuntimeMBean executequeueruntimembean = (ExecuteQueueRuntimeMBean)iterator2.next(); if(executequeueruntimembean.getName().equals("weblogic.kernel.Default")||executequeueruntimembean.getName().equals(ExecuteQueuename1)||executequeueruntimembean.getName().equals(ExecuteQueuename2) ) { System.out.println("\n"+executequeueruntimembean.getParent().toString()+" "+executequeueruntimembean.getName()+" "+executequeueruntimembean.getExecuteThreadCurrentIdleCount()); } } } /*if(Heapcheck.equals("Y")||Heapcheck.equals("y")) { //for(int j=0;j<3;j++) while(iterator3.hasNext()) { //if(!iterator3.hasNext()) //break; JVMRuntimeMBean jvmruntimembean= (JVMRuntimeMBean)iterator3.next(); System.out.println("\n"+jvmruntimembean.getName()+" "+"Free:"+jvmruntimembean.getHeapFreeCurrent() + " " +"current: "+ jvmruntimembean.getHeapSizeCurrent() ); } }*/ /*if(poolcheck.equals("Y")||poolcheck.equals("y")) { while(iterator1.hasNext()) //if(!iterator1.hasNext()) // break; { JDBCConnectionPoolRuntimeMBean jdbcconnectionpoolruntimembean = (JDBCConnectionPoolRuntimeMBean)iterator1.next(); if(jdbcconnectionpoolruntimembean.getName().equals(poolname1)||jdbcconnectionpoolruntimembean.getName().equals(poolname2) ) { System.out.println("\n"+jdbcconnectionpoolruntimembean.getName()+" "+"currentcount="+jdbcconnectionpoolruntimembean.getActiveConnectionsCurrentCount()+" and "+"highcount="+jdbcconnectionpoolruntimembean.getActiveConnectionsHighCount()+"\n"); System.out.println("\n-----------------------------------------------------------------------"); }} }*/ } while(true); } catch(Exception exception2) { System.out.println("Exception caught: 3 " + exception2); } try { Thread.sleep(500L); } catch(InterruptedException interruptedexception) { System.out.println("Interrupted Exception...." + interruptedexception); } //filewriter.write("\n--------------------------------------------------------------------------------"); } while(true); } catch(Exception exception) { System.out.println("Interrupted Exception...." + exception); } } }