因为最近自己一直在做一个weblogic项目监控的web工程,而苦于网上关于weblogic监控可获取属性的信息少之又少,所以自己对此做了一点小小的总结,希望看到的人能少走一些弯路。

首先,从建立Mbean server的连接说起,

public class MonitorWeblogic {

public static final Logger LOG = Logger.getLogger(MonitorWeblogic.class);

private static MBeanServerConnection connection;

private static JMXConnector connector;

private static final ObjectName service;

// 实例化 DomainRuntimeServiceMBean 对象名

// 这样可以通过类使用此对象名。

static {

try {

service = new ObjectName(

"com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean");

} catch (MalformedObjectNameException e) {

throw new AssertionError(e.getMessage());

}

}

/**实例化与 Domain Runtime MBean Server的连接 */

public static void initConnection(String protocol,String hostname, String portString,

String username, String password) throws IOException,

MalformedURLException {

Integer portInteger = Integer.valueOf(portString);

int port = portInteger.intValue();

String jndiroot = "/jndi/";

String mserver = "weblogic.management.mbeanservers.domainruntime";

JMXServiceURL serviceURL = new JMXServiceURL(protocol, hostname, port,

jndiroot + mserver);

Hashtable h = new Hashtable();

h.put(Context.SECURITY_PRINCIPAL, username);

h.put(Context.SECURITY_CREDENTIALS, password);

h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote");

connector = JMXConnectorFactory.connect(serviceURL, h);

connection = connector.getMBeanServerConnection();

}

}

这里建立的是一个Domain Runtimes MBean Server的连接,initConnection方法以用户名、密码以及监控地址和端口为参数,在实例化类时传递参数。对于weblogic,还包括一下MBean的服务器类型。Runtime MBean Server 和 Edit MBean Server。对应MBean服务器的功能如下:

Edit MBean Server: 修改域的配置,监视配置MBean待定层次结构的更改

Runtime MBean Server: 仅监视活动的配置MBean,而不监视运行时MBean

Domain Runtime MBean Server: 对多个服务器监视运行时MBean(在本次的实践中,采用的就是Domain Runtime MBean Server)

初始化连接后,就要开始获取weblogic上各种属性的值了,这个地方正是本文的重点。很多人可能知道通过getServerRuntimes()方法来获取运行服务器属性的值,通过getAttribute(ObjectName name,String attribute)获取监控属性的值。但大部分人应该会和我一样,因为不了解MBean中 attribute对象有哪些内容而苦恼。不过还好,MBean给我们提供了一个getMbeanInfo(ObjectName name)方法,让我们可以获取Mbean的大部分attributes和操作信息。由于这段信息过于冗长,没法完整的贴出,我在此截取一小段:javax.management.modelmbean.ModelMBeanInfoSupport[description=<p>An application represents a J2EE Enterprise application packaged in an EAR file or EAR exploded directory. The EAR file or directory contains a set of components such as WAR, EJB, and RAR connector components, each of which can be deployed on one or more targets.

......

......

(连起来可以绕地球一圈,看得眼睛都花了)

相信大部分人没有耐心把这么长一段信息完整的看完,所以我对它做了个总结,说明一下MBeanInfo中主要的内容有哪些

1. Modules in application can have one of the following states:

UNPREPARED  应用中所有组件都未准备就绪或活跃状态

PREPARED   应用中所有组件都已准备就绪或活跃状态

ACTIVATED  应用中至少有一个组件是活跃的

他们的具体信息可能在register mbean 时出现了点差错,我已经予以改正

2. MBean中 一些Interface的介绍和操作,然而这些对我们获取监控属性值并没有什么用

3. ModelMBeanAttributeInfo: MBean 可获得的应用属性名称和属性具体内容,我挑选了一些可能用到的:

WseeRuntimes

ApplicationName

Parent

EAR

ApplicationVersion

Type

WseeV2Runtimes

LibraryRuntimes

ClassRedefinitionRuntime

WorkManagerRuntimes

MinThreadsConstraintRuntimes

HealthState

Name

ActiveVersionState

ComponentRuntimes

QueryCacheRuntimes

WseeRuntimes   :

Description:the list of Web Service runtime instances that are contained in this Enterprise application

通过 getWseeV2Runtimes获取,

接口为Lweblogic.management.runtime.WseeRuntimeMBean

Type ObjectName

ApplicationName:

Description:The name of the Enterprise application.

type  Attribute

Parent:

Description:the immediate parent for this MBean。

type  ObjectName

接口weblogic.management.WebLogicMBean

ApplicationVersion:

Description:The Enterprise application's version identifier

Type:

Description:Returns the type of the MBean

WseeV2Runtimes:

Description:Returns the list of Web Service runtime instances that are contained at the application scope of this Enterprise application

接口Lweblogic.management.runtime.WseeV2RuntimeMBean

LibraryRuntimes:

Description:Returns the list of library runtime instances for each J2EE library that is contained in this Enterprise application

接口Lweblogic.management.runtime.LibraryRuntimeMBean

ClassRedefinitionRuntime:

Description:If class fast-swap feature is enabled for the application, return the runtime mbean to monitor and control the class fast-swap within the application

接口com.bea.wls.redef.runtime.ClassRedefinitionRuntimeMBean

WorkManagerRuntimes:

Description:Returns the list of work manager runtime instances for each application-scoped work manager that is associated with this Enterprise application

接口

Lweblogic.management.runtime.WorkManagerRuntimeMBean;,

MinThreadsConstraintRuntimes:

Description:Get the runtime mbeans for all MinThreadsConstraints defined at the app-level

接口Lweblogic.management.runtime.MinThreadsConstraintRuntimeMBean

HealthState:

Description:The HealthState mbean for the application

Types: weblogic.health.HealthState

Name:

The name of this configuration

ActiveVersionState:

Description:Specifies whether this application version is the currently active version

OptionalPackageRuntimes:

Description:Returns the list of optional package runtime instances for each J2EE optional package that is contained in this Enterprise application

接口:Lweblogic.management.runtime.LibraryRuntimeMBean

RequestClassRuntimes:

Description:Get the runtime mbeans for all request classes defined at the app-level

接口

Lweblogic.management.runtime.RequestClassRuntimeMBean;,

ComponentRuntimes:

Description:Returns the list of component runtime instances for each J2EE component (such as an EJB or a Web application) that is contained in this Enterprise application

接口Lweblogic.management.runtime.ComponentRuntimeMBean

QueryCacheRuntimes:

Description:Returns a list of QueryCacheRuntimeMBeans configured for this application.

接口Lweblogic.management.runtime.QueryCacheRuntimeMBean

MaxThreadsConstraintRuntimes:

Description:Get the runtime mbeans for all MaxThreadsConstraints defined at the app-level

Type:Ljavax.management.ObjectName

接口Lweblogic.management.runtime.MaxThreadsConstraintRuntimeMBean

4.ModelMBeanOperationInfo:(主要是Mbean的一些操作,实际使用的概率不大)

lookupWseeV2Runtime:

Returns a named Web Service runtime instance that is contained at application scope of this Enterprise application

接口weblogic.management.runtime.WseeV2RuntimeMBean

lookupWorkManagerRuntime:

Lookup the WorkManagerRuntimeMBean given the component name and work manager name. If the component name is null then the WorkManagerRuntime is retrieved from the application itself

接口weblogic.management.runtime.WorkManagerRuntimeMBean

lookupQueryCacheRuntime:

Returns a QueryCacheRuntimeMBean for the app-scoped query-cache with name 'cacheName'

lookupMinThreadsConstraintRuntime:

lookup MinThreadsConstraintRuntime given its name

hasApplicationCache :

Returns True if the application has an (EJB) Application Level Cache

虽然整理了这么多mbean 的属性和操作信息,但大部分都是针对服务器和应用运行状态以及线程的,可能还是不能完整的获取应用的具体信息。因此又对从ComponentRuntimes中取出来的内容进行了分析和整理

这是其中的两条:

com.bea:ServerRuntime=AdminServer,Name=AdminServer_/monitor-webapp,Location=AdminServer,Type=WebAppComponentRuntime,ApplicationRuntime=sg-i6000-monitor-webapp

com.bea:ServerRuntime=AdminServer,Name=DataSource-ws,Location=AdminServer,Type=JDBCDataSourceRuntime

从中可以获得应用所在服务器以及应用类型的信息分别存在ComponentRuntimes的Location 和Type属性中,这样就能针对应用类型和所在服务器对在weblogic部署的应用和数据源进行区分了!

对于Edit MBean Server, 下次再详述。

通过MBean server监控weblogic应用相关推荐

  1. 通过Nagios监控weblogic服务

    1.前言      前段时间搭建了一套Nagios监控服务,心血来潮想自己写一个脚本,拓展Nagios插件来监控公司的weblogic服务. 环境:weblogic10.3.3.0 . CentOS6 ...

  2. SQL Server 监控系列(文章索引)

    一.前言(Introduction) SQL Server监控在很多时候可以帮助我们了解数据库做了些什么,比如谁谁在什么时候修改了表结构,谁谁在删除了某个对象,当这些事情发生了,老板在后面追着说这是谁 ...

  3. sql server监控

    sql server监控 http://www.mssqltips.com/sqlservertip/2522/sql-server-monitoring-checklist/ 1.查看sql ser ...

  4. Sql Server 监控 Job 执行情况

    由于最近数据库的部分job总是不能十分健康的执行,而监控起来只能登陆db服务器去查看错误日志,维护起来十分麻烦,并且job一般都是比较重要的,比如备份数据库或者清理数据库等等.网站这边,经常由于清理j ...

  5. 用SQL Server 监控 OS Server 的Task Management信息

    用SQL Server 监控 OS Server 的Task Management信息 --原文来自于http://www.databasejournal.com/features/mssql/art ...

  6. SQL Server监控全解析

    SQL Server监控全解析 在SQL Server的日常管理中,让SQL Server高效运行,且性能良好,是DBA需要做的事.DBA需要了解数据库的日常运行情况,对性能进行分析和调优,需要对线上 ...

  7. 0. SQL Server监控清单

    数据库服务器的监控可大致分为两类: (1) 状态监控:数据库服务器有没有在健康地运行? (2) 性能监控:健康运行的同时,有没有性能问题?可不可以更快些? 一. 服务器 1. 状态监控 (1) 服务器 ...

  8. Jconsole/jvisualvm远程监控weblogic中间件配置

    1.进入linu操作界面,进入到启动服务目录下 2.选择要监控的服务的启动项,进入到编辑状态(注意:要先将该文件进行备份),如下图所示 3.修改USER_AGRS域,添加如下内容,注意修改IP USE ...

  9. SQL Server监控常规计数器收集参考(mssql阻塞的跟踪查询,死锁的跟踪查询,改善)

    常规计数器收集操作系统服务器的服务器性能信息,包括Processor.磁盘.网络.内存 Processor 处理器 1.1 % Processor Time指处理器用来执行非闲置线程时间的百分比.通过 ...

最新文章

  1. C++ 笔记(30)— 友元函数与友元类
  2. 通过Dockerfile构建Docker镜像
  3. JStorm与Storm源码分析(三)--Scheduler,调度器
  4. 【Python学习系列二十一】pandas库基本操作
  5. oracle更新统计信息执行计划,为准确生成执行计划更新统计信息-analyze与dbms_stats...
  6. 微信分享链接时,怎样才能带上带缩略图和简介?
  7. IDEA无法识别pom.xml文件,内容全部显示为灰色,或者无颜色
  8. POJ 2031 Building a Space Station
  9. c语言运算优先级与结合方向的问题
  10. vba编写的出库单(可添加出库项目记录、生成、打印出库单)
  11. 无线网460王者荣耀服务器,王者荣耀460ms解决方法:王者荣耀网速460ms怎么办?...
  12. Intel无线网卡linux,Deepin 15.8/Ubuntu 18.04用intel无线网卡9260ac速度跑不满的解决
  13. 版本管理·玩转git(团队合作)
  14. 三日月くるみ - 魔法みたいな恋したい
  15. Infor SyteLine ERP 客户端使用设置
  16. MVC 几种过滤器及如何使用
  17. 多智能体中的图论——图论中的定义(一)
  18. 【体感游戏】没有iPhone也能玩AIWI
  19. MOS管驱动电路详解
  20. html wap 转换,html移动端wap页面、图片多少宽度最合适?【转载】

热门文章

  1. python-迭代器实现异步(在串行中)
  2. 总结CSS3新特性(Transition篇)
  3. Spring4Shell 漏洞已遭Mirai 僵尸网络利用
  4. Eltima SDK 中存在27个漏洞,影响多家云服务提供商
  5. HackerOne《2020年黑客驱动安全报告》:中国白帽子的收入增长幅度最大
  6. python高级-异常(13)
  7. 中台之上(一):重视业务架构,不要让“业务的归业务、技术的归技术”
  8. TCP/IP研究(2)-TCB
  9. 05 吸收应用-会整理还不够?教你吸收、联想、输出、应用
  10. 关于路由器操作系统的那点事儿