Saturday, August 25, 2012

WebLogic, detecting stuck threads with JMX and Java

Surprisingly, the "Health" reported in the Servers monitoring tab





is NOT the ServerRuntime.HealthState, but rather the

/serverRuntime/ThreadPoolRuntime/ThreadPoolRuntime.HealthState

the parent of this MBean is com.bea:Name=osbpl1ms1,Type=ServerRuntime, its type and name are ThreadPoolRuntime

which also contains a weblogic.health.HealthState

For this reason, to the code of the previous post I have added a new method:

    public static String getThisServerThreadPoolHealth() throws Exception {
 MBeanServerConnection connection = initConnection();
 ObjectName runtimeService = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
 String managedServerName = (String) connection.getAttribute(runtimeService, "ServerName");
 ObjectName serverRT = new ObjectName("com.bea:Name=" + managedServerName + ",Type=ServerRuntime");
 System.out.println("serverRT=" + serverRT);
 ObjectName serverTP = (ObjectName)connection.getAttribute(serverRT, "ThreadPoolRuntime");
 weblogic.health.HealthState tpHealthState = (weblogic.health.HealthState) connection.getAttribute(serverTP, "HealthState");
 return healthStateToString(tpHealthState.getState());
    }





No comments: