淘宝商城(天猫)高级技术专家.3年研发+3年性能测试调优/系统测试+4年团队管理与测试架构、研发系统实践. 新舞台新气象, 深化测试基础架构及研发架构,希望能在某个技术领域成为真正的技术大牛。欢迎荐才http://bbs.51testing.com/viewthread.php?tid=120496&extra=&page=1 .邮件: jianzhao.liangjz@alibaba-inc.com,MSN:liangjianzhao@163.com.微博:http://t.sina.com.cn/1674816524

java web应用性能监控工具jwebap

上一篇 / 下一篇  2010-04-27 12:52:28 / 个人分类:java性能监控与调优

性能测试中,我们经常希望一个平台能拦截、profile、分析性能数据,现实在一点点逼近.Jwebap

 

 效果图http://www.jwebap.org/detect/console/?null

 官方文档:http://www.jwebap.org/index_zh.htm

 作者blog:http://leadyu.javaeye.com/

 

Jwebap是无代码侵入、需要修改web.xml配置文件的java应用监控工具,轻易获取jdbc调用/http调用、方法调用耗时及是否有jdbc泄露。核心原理:应用asm字节码操作框架实现动态monitor

   另外一个工具:http://jamonapi.sourceforge.net/

1.1.1   下载

http://sourceforge.net/projects/jwebap/files/

1.1.2   部署

解压后的jwebap_0.6.1.jar, tracer_0.6.1.jarjwebap_0.6.1_all\lib目录下jar复制到jboss-4.2.2.GA\server\default\lib目录下。

 



修改tracer_0.6.1.jar/META-INF/plugin.xml文件,红色为修改项:

<?xml version="1.0" encoding="UTF-8"?>

<plugin>

      <!--component-->

      <component name="HttpComponent" type="org.jwebap.plugin.tracer.http.HttpComponent">

             <component-param>

                    <name>trace-filter-active-time</name>

                    <value>-1</value>

                    <description>(ms) timings filter's over time</description>

             </component-param>

             <component-param>

                    <name>trace-max-size</name>

                    <value>1000</value>

                    <description>max over-time trace size</description>

             </component-param>

      </component>

      <component name="MethodComponent" type="org.jwebap.plugin.tracer.method.MethodComponent">

             <component-param>

                    <name>trace-filter-active-time</name>

                    <value>-1</value>

                    <description>(ms) timings filter's over time</description>

             </component-param>

             <component-param>

                    <name>trace-max-size</name>

                    <value>1000</value>

                    <description>max over-time trace size</description>

             </component-param>

             <component-param style="longtext">

                   <name>detect-clazzs</name>

                    <value>

                    com.ali.*;

                    </value>

                    <description>

                    package name and class name that monitored by MethodComponent,

                    e.g.: 'test.*;test.Test' , divided by ';'

                    </description>

             </component-param>

      </component>

      <component name="JdbcComponent" type="org.jwebap.plugin.tracer.jdbc.JdbcComponent">

             <component-param>

                    <name>trace-filter-active-time</name>

                    <value>-1</value>

                    <description>(ms) timings filter's over time</description>

             </component-param>

             <component-param>

                    <name>trace-max-size</name>

                    <value>1000</value>

                    <description>max over-time trace size</description>

             </component-param>

             <component-param style="longtext">

                    <name>connection-listener</name>

                    <value>

             org.jwebap.plugin.tracer.http.ServletOpenedConnectionListener;org.jwebap.plugin.tracer.method.MethodOpenedConnectionListener

                    </value>

                    <description>Connection Listener</description>

             </component-param>

             <component-param style="longtext">

                    <name>driver-clazzs</name>

                   <value>org.apache.commons.dbcp.BasicDataSource</value>        

                    <!--

                    <value>com.mysql.jdbc.Driver</value>

                    -->

                    <description>

 

                    </description>

             </component-param>

      </component>

      

</plugin>

 

修改好后重新替换入jar。如下是监控spring.war应用的操作过程。

 

修改jwebap.xml放到jboss-4.2.2.GA\server\default\deploy\spring.war\WEB-INF

<?xml version="1.0" encoding="UTF-8"?>

<jwebap>

      <!--plugins-->

      <plugin name="Tracer" ref="${ABSOLUTE_PATH}/tracer_0.6.1.jar"/>

</jwebap>

 

${ABSOLUTE_PATH}是内置的变量,不必修改

 

参考jwebap_0.6.1_all\bin\web-example.xml修改jboss-4.2.2.GA\server\default\deploy\spring.war\WEB-INF\web.xml

 

<!-- begin jwebap-->

      <context-param>

             <param-name>jwebap-config</param-name>

             <param-value>/WEB-INF/jwebap.xml</param-value>

      </context-param>

      <listener>    

             <listener-class>org.jwebap.startup.JwebapListener</listener-class>     

      </listener>

      <filter>

             <filter-name>PageDetectFilter</filter-name>

             <filter-class>org.jwebap.plugin.tracer.http.DetectFilter</filter-class>

             <init-param>

                    <param-name>excludeUrls</param-name>

                    <param-value>/detect;/detect/*;*.js;*.jpg;*.htm;*.html;*.gif;*.png;*.css;*.swf</param-value>

             </init-param>

      </filter>

      <filter-mapping>

             <filter-name>PageDetectFilter</filter-name>

             <url-pattern>/*</url-pattern>

      </filter-mapping>

 

      <servlet>

             <servlet-name>detect</servlet-name>

             <servlet-class>org.jwebap.ui.controler.JwebapServlet</servlet-class>  

      </servlet>

 

      <servlet-mapping>

             <servlet-name>detect</servlet-name>

             <url-pattern>/detect/*</url-pattern>

      </servlet-mapping>

      

      <!-- end jwebap-->

 

有一点特别注意的是,在被监控的程序如spring.war目录jboss-4.2.2.GA\server\default\deploy\spring.war\WEB-INF\lib加入数据库驱动程序如commons-dbcp.jar,否则无法获取jdbc trace数据。

 

 

1.1.3   启动应用及拦截

启动jboss

执行应用操作,ie输入

http://localhost:8080/spring/detect/console/?null可以看到jwebap监控效果

jdbc traces:

 

http监控

 

 

Method监控

 

1.1.4   已知限制及应用场合

 更多讨论可以在javaeye论坛搜索jwebap

 

 对于普通的web程序,jwebap支持不错。可以考虑内部系统开发性能优化时应用。

 

Webx工程只能监控jdbc调用,对于方法和http请求无法拦截.


TAG: 性能监控 jwebap java应用

river.liu小寒江的个人空间 引用 删除 xiaohanjiang   /   2010-06-03 17:31:13
跟jprofiler有什么区别,感觉jp功能已经非常强大了
引用 删除 powerws   /   2010-05-26 15:52:34
hi,请教一个问题,监控class好像没有问题,可是如果监控jar包该如何配置?比如,我要监控war包里WEB-INF下lib里的某个jar包,谢谢。
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar