- 浏览: 1001316 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
liaozhaijk:
都太较真了。。。其实水平高低能说明什么呢? 印度过CMMI5那 ...
只会SSH成了低薪的代名词? -
xiaofagn:
ffffff
Weblogic 忘了控制台密码怎么办? -
saieuler:
多么想去啊
如何成为一名 Google 软件工程师? -
pudong:
只有大纲吗?
甲方项目管理培训课程大纲 -
dyllove98:
进入页面后眼睛有点花,建议楼主整理一下
重温士兵突击之后 职场风云
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);
相关推荐
java项目,自己做的项目利用jmx监控weblogic,tomcat,websphere源码
Java版 jmx 监控weblogic 生成html
BEA WebLogic Server实现了JMX大部分的API,并且提供了一个完全兼容JMX的控制台来管理各种资源。OPEN SOURCE的应用服务器JBoss也是基于JMX来实现。并且对之评价很高,认为是目前为止最好的软件集成工具。JBoss的成功...
此资源是用于开发人员或者测试人员在使用java mission control时,需要放置在Tomcat中的文件
java运行依赖jar包
java运行依赖jar包
网络逻辑JMX这是一个正在进行的工作,将经常更新,直到完成一组用于 9.X 及更高版本的 Weblogic 服务器的 JMX 服务器实用程序。 目前实时给出一些监控统计,后续会更新更多功能特征目前可以使用以下功能: JVM 监控...
loadrunner 监视 weblogic(JMX) 操作详细步骤.txt
JMX监控weblogic入门教程,基于weblogic自带的JMX,环境:weblogic8,jmx1.0,jdk1.4
tomcat和weblogic的jmx开通方式。。
JMX实战 书中不仅有对于基础知识的介绍,还有对于JMX开发中重大的体系架构问题的深入探讨,总结了大量JMX开发中的设计模式,并讨论了框架、安全性与性能等等。书中提供了几个典型的例子,兼顾各种开发平台,这些...
JVM内存的调优 1. Heap设定与垃圾回收Java Heap分为3个区,Young,Old和Permanent。Young保存刚实例化的对象。当该区被填满时,GC会将对象移到Old区。Permanent区则负责保存反射对象,本文不讨论该区。...
jmx快速上手 jmx快速上手 jmx快速上手 jmx快速上手
Fiddler导出jmx文件,解决Fiddler导出文件中 没有jmx文件选项,各个版本fiddler都适用
Description Resource Path Location Type Missing artifact com.sun.jmx:jmxri:jar:1.2.1 pom.xml /eshop-storm line 2 Maven Dependency Problem
为什么JMX那么受欢迎,JMX到底有那些优势只得人们去学习和理解,本文从JMX的基本架构、hellowold jmx以及spring对JMX的支持讲起,希望大家能通过本文对JMX有个基础的认识,并能通过本文为今后学习JMX打个基础
而根据这个接口的实现则有很多种,比如Weblogic 的JMX实现、MX4J、JBoss的JMX实现。在SUN自己也实现了一份,不过在JDK1.4之前,这件JMX实现(一些JAR包)是可选的,你得去 它的网站上下载。JDK5.0则内嵌了进来,安装...
catalina-jmx-remote.jar放到tomcat/lib目录下 如果是windows版本,编辑TOMCAT_HOME/bin/catalina.bat,在开头加入下面几行: set CATALINA_OPTS=%CATALINA_OPTS% -Djava.rmi.server.hostname=JMX_HOST set CATALINA...
Hbase和Hadoop JMX监控实战