`
touchmm
  • 浏览: 1068512 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

JMX access WEBLOGIC9.2

阅读更多

JMX access WEBLOGIC9.2

Development environment as well as the reference packet
weblogic9.0 running on JDK5.0 or higher than the 5.0 version.
JAR package reference:
Only need to introduce weblogic .jar can be had, weblogic9.2's JAR size is about 51.4 MB.
Do not need the introduction of JMX packages , such as mx4j.jar

Open Pre-development process:
A good programming practice is conducive to this end, we will be some commonly used parameters extracted, placed in a separate class, are as follows:

/**
* @author leonelwong@126.com
* @version 0.9 2010-3-24 9:48:59 Information stored constants
*/
public class Constant {

public static String ServerProtocol = "t3";

public static String ServerIp = "127.0.0.1";

public static String ServerJndiroot = "/jndi/";

public static int ServerPort = 7001;

public static String ServerUsername = "weblogic";

public static String ServerPassword = "weblogic";

public static String ServerClassName = "weblogic.management .mbeanservers.domainruntime";

public static String ServerPROTOCOLName ="weblogic.management.remote";

public static String ThreadPoolRuntime = "ThreadPoolRuntime";

public static String JDBCConnectionPoolRuntime = "JDBCConnectionPoolRuntime";

public static String WebAppComponentRuntime = "WebAppComponentRuntime";

/**
* Thread all property
*/
public static String[] THREAD_ATTRIBUTES = { "CompletedRequestCount",
"ExecuteThreadIdleCount", "ExecuteThreadTotalCount", "HealthState",
"HoggingThreadCount", "MinThreadsConstraintsCompleted",
"MinThreadsConstraintsPending", "Name", "Parent",
"PendingUserRequestCount", "QueueLength",
"SharedCapacityForWorkManagers", "StandbyThreadCount", "Suspended ",
"Throughput", "Type" };

/**
* JDBC All property
*/
public static String[] JDBC_ATTRIBUTES = { "ActiveConnectionsAverageCount",
"ActiveConnectionsCurrentCount", "ActiveConnectionsHighCount",
"ConnectionDelayTime", "ConnectionLeakProfileCount",
"ConnectionsTotalCount", "CurrCapacity", "DeploymentState",
"Enabled", "FailuresToReconnectCount", "HighestNumAvailable",
"HighestNumUnavailable", "LeakedConnectionCount", "MaxCapacity",
"ModuleId", "Name", "NumAvailable", "NumUnavailable", "Parent",
"PoolState", "Properties", "State", "StatementProfileCount",
"Type", "VersionJDBCDriver", "WaitingForConnectionCurrentCount",
"WaitingForConnectionHighCount", "WaitSecondsHighCount" };

/**
* webapp All property
*/
public static String[] WEBAPP_ATTRIBUTES = { "ComponentName",
"ContextRoot", "DeploymentState",
"FilterDispatchedRequestsEnabled", "IndexDirectoryEnabled",
"JSPCompileCommand", "JSPDebug", "JSPKeepGenerated",
"JSPPageCheckSecs", "JSPVerbose", "LogFilename", "ModuleId",
"ModuleURI", "Name", "OpenSessionsCurrentCount",
"OpenSessionsHighCount", "Parent", "ServletReloadCheckSecs",
"ServletSessionsMonitoringIds", "SessionCookieComment",
"SessionCookieDomain", "SessionCookieMaxAgeSecs",
"SessionCookieName", "SessionCookiePath", "SessionIDLength",
"SessionInvalidationIntervalSecs", "SessionMonitoringEnabled",
"SessionsOpenedTotalCount", "SessionTimeoutSecs",
"SingleThreadedServletPoolSize", "SourceInfo", "Status", "Type" };

public static String ExecuteThreads = "ExecuteThreads";
}


Maybe you have discovered, and 9.2 parameters have been many more than the 7.0, so many parameters does it mean that 9.2 of the access method as opposed to 7.0 of the access methods and sampling method is different from that seen it.
9.2 The access methods are mainly based MbeanServerConnection this class there were also some MbeanHome of methods, such as queryMBeans (parameter 1, parameter 2), as MbeanHome, 9.2 inside, has been marked as obsolete.
Here we will JMX way to access weblogic9.2.

import

 java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable ;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.MBeanServerConnection;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
import weblogic.management.runtime.ExecuteThread;

/**
* @author leonelwong@126.com
* @version 0.9 2010-3-24 15:26:03 JMX Access webLogic9.2
*/
public class WebLogicJMXConsole {
JMXConnector connector = null;

MBeanServerConnection mscon = null;

private List threadPools;

private List JDBCPools;

private List wabAppPools;

/**
* Get the JMX API client connector . Use this type of object you can establish a connection to a connector server <br>
* Through the environment defined default parameters for this object <br>
* Objects created by the JMXConnectorFactory.connect connected <br>
* Pass the returned object can be MBeanServerConnection
*/
protected void initParams() {
// This object needs to be close
try {
threadPools = new ArrayList();
JDBCPools = new ArrayList();
wabAppPools = new ArrayList();
// JMX API The connector server address objects
JMXServiceURL serviceURL = new JMXServiceURL(Constant.ServerProtocol,Constant.ServerIp,Constant.ServerPort, Constant.ServerJndiroot + Constant.ServerClassName);
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, Constant.ServerUsername);
h.put(Context.SECURITY_CREDENTIALS, Constant.ServerPassword);
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,Constant.ServerPROTOCOLName);
connector = JMXConnectorFactory.connect(serviceURL, h);
mscon = connector.getMBeanServerConnection();
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Print out the thread information
*/
public void printThreadMbeansInfo() {
try {
if (threadPools.size() < 1) {
return;
}
System.out.println("============================ Output thread information =====================================");
for (int p = 0; p < threadPools.size(); p++) {
System.out.println((ObjectName) threadPools.get(p));
Set mbeans = mscon.queryMBeans((ObjectName) threadPools.get(p),null);
System.out.println(" A total of :" + mbeans.size() + " Matches ");
for (Iterator itr = mbeans.iterator(); itr.hasNext();) {
ObjectInstance objectIns = (ObjectInstance) itr.next();
AttributeList aList = mscon.getAttributes(objectIns.getObjectName(), Constant.THREAD_ATTRIBUTES);
for (int i = 0; i < aList.size(); i++) {
Attribute att = (Attribute) aList.get(i);
System.out.println(att.getName() + " :"+ att.getValue());
}
ExecuteThread[] executeThreads = (ExecuteThread[]) mscon.getAttribute(objectIns.getObjectName(),Constant.ExecuteThreads);
if (executeThreads != null) {
System.out.println("============================ More thread information =====================================");
for (int j = 0; j < executeThreads.length; j++) {
System.out.println("Name :"+ executeThreads[j].getName());
System.out.println("Total Requests :" + executeThreads[j].getServicedRequestTotalCount());
System.out.println("Current Request :"+ executeThreads[j].getCurrentRequest());
System.out.println("Transaction :"+ executeThreads[j].getTransaction());
System.out.println("User :"+ executeThreads[j].getUser());
System.out.println("Idle :"+ executeThreads[j].isIdle());
//System.out.println("Stuck :"+ executeThreads[j].isStuck());
//System.out.println("Hogger :"+ executeThreads[j].isHogger());
//System.out.println("Standby :"+ executeThreads[j].isStandby());
System.out.println("=========================================================================");
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Print out a JDBC connection pool related data
*/
public void printJDBCMbeansInfo() {
System.out.println("============================ Output JDBC information =====================================");
printMbeansInfo(JDBCPools, Constant.JDBC_ATTRIBUTES);
}
/**
* Print out the WEBAPP related data
*/
public void printWebAppMbeansInfo() {
System.out.println("============================ Output WEBAPP information =====================================");
printMbeansInfo(wabAppPools, Constant.WEBAPP_ATTRIBUTES);
}

/**
* Print out the specified information related data
*/
public void printMbeansInfo(List utilList,String[] arrays) {
try {
if (utilList.size() < 1) {
return;
}
System.out.println(" A total of :" + utilList.size() + " Matches ");
for (int p = 0; p < utilList.size(); p++) {
System.out.println((ObjectName) utilList.get(p));
Set mbeans = mscon.queryMBeans((ObjectName) utilList.get(p),null);
for (Iterator itr = mbeans.iterator(); itr.hasNext();) {
ObjectInstance objectIns = (ObjectInstance) itr.next();
AttributeList aList = mscon.getAttributes(objectIns.getObjectName(), arrays);
for (int i = 0; i < aList.size(); i++) {
Attribute att = (Attribute) aList.get(i);
System.out.println(att.getName() + " :"+ att.getValue());
}
System.out.println("===========================================================================");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Read the information, and the appropriate data into corresponding List In
*/
public void fortch4SetList() {
try {
Set mbeans = mscon.queryNames(null, null);
if(mbeans==null){
return;
}
//System.out.println(" Length :" + mbeans.size());
for (Iterator itr = mbeans.iterator(); itr.hasNext();) {
ObjectName objectName = (ObjectName) itr.next();
// Get all the threads. ObjectName
if (objectName.getCanonicalName().indexOf("Type=" + Constant.ThreadPoolRuntime) > -1) {
threadPools.add(objectName);
}
// Get all JDBC ObjectName
if (objectName.getCanonicalName().indexOf("Type=" + Constant.JDBCConnectionPoolRuntime) > -1) {
JDBCPools.add(objectName);
}
// Get all the webApp ObjectName
if (objectName.getCanonicalName().indexOf("Type=" + Constant.WebAppComponentRuntime) > -1) {
wabAppPools.add(objectName);
}
//System.out.println(objectName.getCanonicalName());
}
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Close the connection
*/
public void closeConnection() {
try {
if (this.connector != null) {
this.connector.close();
}
} catch (IOException e) {
e.printStackTrace();
}

}

public static void main(String[] args) {
WebLogicJMXConsole test = new WebLogicJMXConsole();
test.initParams();
test.printThreadMbeansInfo();
test.fortch4SetList();
test.printJDBCMbeansInfo();
test.printWebAppMbeansInfo();
test.closeConnection();
}
}



The same is by visiting queryMBeans method, we can also get Set encapsulated data, but these Set the type of data encapsulation and 7.0 but not the same, who are interested can track what the data type of all ObjectInstance, so we value also can not use the previous approach to value, and needs the Attribute class to value, is obtained from the ObjectInstance, you can get through the following ways
ExecuteThread [] executeThreads = (ExecuteThread []) mscon.getAttribute (objectIns.getObjectName (), Constant.ExecuteThreads)
You can also enter a series of attributes to return to the AttributeList, and then an iterative way, one by one to obtain the name and the value of each Attribute
AttributeList aList = mscon.getAttributes (objectIns.getObjectName (), Constant.THREAD_ATTRIBUTES);

分享到:
评论

相关推荐

    windows下weblogic 9.2 安装部署 配置域 发布工程 详细图解文档

    此外,还可以通过JMX接口和 WLST(WebLogic Scripting Tool)进行自动化管理。 总的来说,Windows下的WebLogic 9.2安装部署、配置域和发布工程是一个涉及多方面知识的过程,需要对Java EE、WebLogic Server的架构...

    jmx监控weblogic,tomcat,websphere源码

    在本项目中,"jmx监控weblogic,tomcat,websphere源码"涉及了使用JMX来监控三个主流的Java应用服务器:WebLogic、Tomcat和WebSphere。这些服务器都是企业级应用部署的常见选择,对它们的监控对于确保系统性能、稳定性...

    通过jmx监控管理weblogic

    BEA WebLogic Server实现了JMX大部分的API,并且提供了一个完全兼容JMX的控制台来管理各种资源。OPEN SOURCE的应用服务器JBoss也是基于JMX来实现。并且对之评价很高,认为是目前为止最好的软件集成工具。JBoss的成功...

    WebLogic Server 9.2安装和操作手册

    WebLogic Server 9.2 是Oracle公司出品的一款企业级Java应用服务器,它提供了全面的Java EE(Java Platform, Enterprise Edition)支持,用于构建、部署和管理分布式应用程序。本手册将详细介绍在Windows 2003系统上...

    Java 版jmx 监控中间件weblogic

    Java版 jmx 监控weblogic 生成html

    jmx_access&password;

    在使用JMC时,`jmx_access&password;` 文件起着至关重要的作用,特别是与JMX(Java Management Extensions)安全相关的配置有关。 JMX 是Java平台的一个标准接口,允许开发者管理应用程序、设备和服务。它提供了一...

    loadrunner 监视 weblogic(JMX) 操作详细步骤.txt

    ### LoadRunner监视WebLogic(JMX)操作详细步骤 #### 一、概述 在性能测试过程中,经常需要对服务器端的应用程序进行监控以确保系统能够稳定运行,并及时发现潜在的问题。LoadRunner作为一款强大的性能测试工具,...

    jetty-jmx-9.2.17.v20160517.jar

    java运行依赖jar包

    jetty-jmx-9.2.15.v20160210.jar

    java运行依赖jar包

    WeblogicJMX:Weblogic JMX 实用程序

    网络逻辑JMX这是一个正在进行的工作,将经常更新,直到完成一组用于 9.X 及更高版本的 Weblogic 服务器的 JMX 服务器实用程序。 目前实时给出一些监控统计,后续会更新更多功能特征目前可以使用以下功能: JVM 监控...

    weblogic学习

    - "Weblogic9.2集群配置手册.docx" 专门讲解WebLogic 9.2版本的集群配置,包括配置步骤和注意事项。 - "Weblogic.pdf" 可能是一份完整的WebLogic官方文档,涵盖广泛的知识点。 - "weblogic调优.ppt" 是一份关于...

    LR上配置监控WEBLOGIC

    其次,需要在WebLogic的控制台上配置安全策略,比如启用ACL(Access Control List)。 - 配置步骤如下: - 登录WebLogic控制台。 - 选择“安全性”-&gt;“全局服务角色映射”-&gt;“编辑”-&gt;“添加”-&gt;输入“weblogic....

    WebLogic 12c(12.2.1.2)升级方案

    - **脚本工具**:WebLogic 9.2 之后引入了 WLST (WebLogic Scripting Tool),取代了旧的 weblogic.Admin 工具。 - **第三方类包和框架**:随着 JDK 的重大变更,一些第三方类包和框架可能不再支持,需要根据新的 JDK...

    jmx监控activeMQ监控

    在ActiveMQ中开启jmx监控需要进行一些配置,包括编辑bin/activemq文件和conf/activemq.xml文件,以及设置jmx.password和jmx.access文件的权限。在配置过程中,需要注意jmxremote.port和rmi.port的设置,确保它们不...

    tomcat_weblogic_jmx.txt

    ### Tomcat 和 WebLogic 的 JMX 开通方式详解 #### 一、JMX 简介 Java Management Extensions (JMX) 是一个为应用程序、设备、系统等提供标准管理界面的框架。它允许开发者监控和管理资源(如应用程序、设备和服务...

    weblogic92调优.zip

    - **监控与诊断**:使用WebLogic的内置监控工具,如JMX和WLST,定期收集和分析性能指标,以便及时发现问题并作出相应调整。 调优是一个持续的过程,需要根据实际负载和性能需求进行动态调整。每个环境都有其独特性...

    weblogic监控 weblogic调优 weblogic版本区别 weblogic启动关闭脚本

    此外,还可以利用JMX(Java Management Extensions)和WLDF(WebLogic Diagnostic Framework)进行更深入的监控和诊断,以便及时发现并解决性能问题。 二、WebLogic调优 WebLogic调优主要包括JVM参数调整、内存设置...

    Weblogic 套件和Weblogic 标准版 Weblogic 企业版 功能对比

    WebLogic Standard Edition是面向中型到大型企业的基本版本,它支持最新的Java EE 5规范,包括Servlets 2.5/2.4/2.3/2.2、JSP 2.1/2.0/1.2/1.1、JSF 1.2、JSTL 1.2、JDBC 3.0、JNDI 1.2、JMX 1.2/1.0、JTA 1.2/1.1、...

    weblogic的MX程序设计

    本文将重点介绍如何通过Java Management Extensions (JMX)来进行WebLogic Server的监控与管理,主要针对WebLogic Server 8.1版本,运行于JDK 1.4环境下。 #### 二、JMX简介 JMX(Java Management Extensions)是一...

    weblogic weblogic weblogic

    9. **监控与诊断**:通过JMX(Java Management Extensions)和管理控制台,可以实时监控服务器状态,收集性能数据,并进行问题诊断。 10. **持续集成与自动化**:WebLogic支持Maven、Gradle等构建工具,便于集成到...

Global site tag (gtag.js) - Google Analytics