使用 JMX (MBean) 记录 WebLogic 状态
我知道我们可以使用 MBean 来获取 WebLogic 的状态。例如,使用 JDBCDataSourceRuntimeMBean (http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e13951/core/index.html) 获取 JDBC 状态。并且使用其他MBean,我们还可以获取EJB,WebService,...的状态,
但这只是当时的状态,如果我想监控历史记录,例如我想知道每个的详细运行时间EJB事务,可以吗?
目的是我们想要监控我们的应用程序性能,一个明显的解决方案是在我们的 EJB 中添加日志并解析它。但如果我们不用写代码就可以从服务器获取它,那就更好了。
另一个问题是,既然JMX是一个标准并且JBoss支持它。如果解决方案能够同时支持WebLogic和JBoss那就更好了。
更新:
我阅读了WebLogic文档,发现 WLDF很好。
- 收集的指标:这可以收集服务器信息。我用它来将 JDBC 状态收集到数据库中。
- Instrumentation:我用这个来记录一个方法的执行时间
以下是官方文档和教程。
收集的指标
- 官方文档:http://download.oracle.com/docs/cd/E12840_01/wls/docs103/wldf_configuring/config_harvester.html
- 博客教程:http://weblogic-server.blogspot.com/2009/12/configuration-diagnostics-jdbc-store.html
工具:
- 官方文档:http://download.oracle.com/docs/cd/E11035_01/wls100/wldf_configuring/config_instrumentation.html
- 博客教程:http://m-button.blogspot.com/2008/11/using-wldf-to-trace-time-taken-by-your.html
唯一不方便的是语法切入点。如果我想监控一个类中的多个方法,我需要编写几个wldf-instrumentation-monitor标签。除非我能找到一个通配符模式来描述它们。
I know we can use MBean to get WebLogic's status. For example, use JDBCDataSourceRuntimeMBean (http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e13951/core/index.html) to get the JDBC status. And use other MBeans, we can also get the status of EJB, WebService, ...
But this is just the status at that time, if I want to monitor the history, for example, I want to know the detail run time of every EJB transaction, is it possible?
The purpose is we want to monitor our application performance, an obvious solution is add log in our EJB and parse it. But if we can get it from server without write code, it will be better.
Another question is, since JMX is a standard and JBoss supports it. If the solution can support both WebLogic and JBoss will be better.
Update:
I read the WebLogic document and found that WLDF is good.
- Collected Metrics: This can collect server information. I use it to collect JDBC status into a database.
- Instrumentation: I use this to record the execute time of a method
The following are the official document and a tutorial.
Collected Metrics
- Official doc: http://download.oracle.com/docs/cd/E12840_01/wls/docs103/wldf_configuring/config_harvester.html
- Blog tutorial: http://weblogic-server.blogspot.com/2009/12/configuration-diagnostics-jdbc-store.html
Instrumentation:
- Official doc: http://download.oracle.com/docs/cd/E11035_01/wls100/wldf_configuring/config_instrumentation.html
- Blog tutorial: http://m-button.blogspot.com/2008/11/using-wldf-to-trace-time-taken-by-your.html
The only inconvenient is the syntax of pointcut. If I want to monitor several methods in a class, I need to write several wldf-instrumentation-monitor tags. Unless I can find a wild card pattern to describe them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这绝对是可能的,但使用现有的 WLDF 框架 - 您可以定义要跟踪的 MBean、将历史数据存储到文件存储并在控制台中绘制它们的图表。
我不推荐记录调试语句的途径,尤其是在生产环境中。根据系统的吞吐量,日志记录带来的额外 I/O 可能会是一笔巨大的开销。
JMX 是访问运行时 Bean 的标准方式,但 WebLogic 和 JBoss 之间的方式有所不同。根据我个人的经验,除非您使用 CA Wily 的 Introscope 等企业解决方案,否则最好使用专门为应用程序服务器编写的单独程序,因为它们通常会突出显示您可能感兴趣的其他指标(如果您有是时候遍历所有 MBean 并确定它们的有用性了,这可能不是问题)。
希望有帮助!
It's definitely possible but it might be easier for you to use the existing WLDF framework - You can define which MBeans you want to track, store historical data to a filestore and graph them within the console.
I don't recommend the route of logging debug statements, especially in a production environment. Depending on the throughput of your system, the additional I/O from logging can be a significant overhead.
JMX is the standard way to access your runtime beans but they are going to differ between WebLogic and JBoss. In my personal experience, unless you're using an enterprise solution such as CA Wily's Introscope, you're better off using the individual programs written specifically for the application server as they usually highlight other metrics you may be interested in (If you have the time to traverse all MBeans and determine how useful they are, this may not be of concern).
Hope that helps!