论坛首页 Java企业应用论坛

记录TPTP监控tomcat

浏览 3359 次
精华帖 (0) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-09-21  

 

 

在做项目过程中,发现性能存在很大问题,想到了TPTP。

 

tptp官网:http://www.eclipse.org/tptp

 

=================下载,安装======================

++++++++++++++++++++++++++++++++++++++++++++++++

注意tptp的版本及eclipse的版本,JDK的版本,官网及介绍文档中均有提到

++++++++++++++++++++++++++++++++++++++++++++++++

 

TPTP All-in-One

 

 

建议下载这个,但是我是分别安装plugin及agentControl,所以重点讲独立安装。

 

TPTP Plugins for Eclipse

 

这个是eclipse的插件,下载完后,将包里的features和plugin中的文件分别放到你的eclipse中,然后重启就装好了

具体安装过程网上有很多,虽然tptp版本很多但是这个基本没有变化

 

这个插件装好以后,运行一般J2SE的项目已经没有任何问题,可以记录线程,运行时间,内存等。

 

Agent Controller

 

如果只装了tptp插件,你会发现没有办法对tomcat等服务器进行监控

 

当你尝试想profile时,会弹出一个dialog,让你选择monitor,但可惜是没有任何monitor!

 

 

 写道
TPTP运行有两种模式, 一种是在TPTP的workbench里,一种是通过JVMPI(类似JVMDI, 远程调试的模式), 第一种需要你的项目导入到TPTP里, 第二种模式,你就可以很随意的在命令行运行你的程序,通过JVMPI(或者JVMTI)将你的JVM attach 到TPTP, 来进行调试

 

 

我其实无法准确解释AgentControl,大家可以去看文档,下载后文件夹中有一个html,介绍了具体使用,非常详细,接下去我就我的使用做个记录(相当于翻译吧)

 

 

 

================Agent Controller安装,配置=======================

 

1 从官网上下载,是个压缩包,也就是无需安装

 

2 设置环境路径

 

 

  • Set TPTP_AC_HOME=<<Agent Controller Home>>
  • Set JAVA_PROFILER_HOME=%TPTP_AC_HOME%\plugins\org.eclipse.tptp.javaprofiler
  • Set PATH=%JAVA_PROFILER_HOME%;%TPTP_AC_HOME%\bin;%PATH%
  •  

    教程上有提到在tptp4.6以上可以简单配置,但是建议这样配置,避免麻烦。

    我的路径:

    *JAVA_PROFILER_HOME:%TPTP_AC_HOME%plugins\org.eclipse.tptp.javaprofiler

    *TPTP_AC_HOME:C:\test\agentTPTP\(我的安装路径,接下去都以这个问安装目录)

    *Path:...;%JAVA_PROFILER_HOME%;%TPTP_AC_HOME%\bin;

    3 运行ACServer.exe

    *在C:\test\agentTPTP\bin下

    *注意在教程上提到过windows vista 7下可能存在权限问题,最好就是右击,run as admin,如果出现一个cmd

    窗口,什么都没有但没有消失那就是说明成功了,如果出现诸如

    [java] Error occurred during initialization of VM
    [java] Could not find agent library on the library path or in the local dir 
    ectory: JPIBootLoader
     
    那就是路径配置错误,一闪消失,应该是权限的问题

    教程上有提到如何测试是否连通,就不说了


    ==================AC命令,模式==============================

     

    这部分是关键,但是由于教程实在讲得很细了,我就直接粘贴,做点注解好了

     

     

    Using the Java Profiler with Java 1.4 (or lower) Virtual Machines

    tptp对于jdk1.5之前与之后再agentControl上还是很有区别的,重点说JDK1.5后

     

     

     

    Using the Java Profiler with Java 1.5 (or higher) Virtual Machines

    1.agentlib:JPIBootLoader=JPIAgent[:[help]|[<option>=<value>,...]];<profiler>[:<option>=<value>,...]

     

     

    这个是启动jvm时的参数,具体意义教程均有说明

     

    server=[standalone | enabled | controlled]

    standalone 独立模式,在这个模式下,eclipse是没有用的,所有参数均在命令行中,检测结束后,会有一个trace.trcxml文件,导入eclipse(file-import-profiling and logging-profiling file)后即可分析,查看(也就是说他是静态的
    The profiling agent runs in a headless mode, which means it is not possible to interact with it from the workbench. Configuration information is provided as part of the command lineand profiling data is stored in a file directly by the profiling agent. The profiling file can then be imported into the workbench at a later date.
    The Java Profiling Agent is manually attached to a JVM instance and generates profiling data to an output file. The default output file is called trace.trcxml, but you can specify a different file name using the file= filename parameter. When this option is selected, the Java Profiling Agent produces an enclosing traceRoot element to form a complete and valid XML document.
    enabled (This is the default.)
    这个最常用,在命令行中执行后,立马到eclipse中,在profiling configuration选项卡中找到   Attach to    Agent,在agent control选项卡中便可以看到正在运行的agent了。
      注意,此时可以在EDIT OPTIONS中设置监控的类型等参数!

    另外,需要注意的是,很多人说tptp监控tomcat等很慢,这个问题,一方面的确是tptp的 原因,但是最重要的是,他们没有设置过滤,监控了所有的包,尤其是在standalone模 式下,如果没有配置filters.txt那么所有的包都监控,机子的内存很快就会不行!

    所以,一定要合适配置要监控的包,其他的全部exclude掉!
    The profiling agent runs in the background of the JVM without consuming resources until it is connected to by the workbench and asked to start monitoring. Data is then streamed over the agent's data channel and consumed by the workbench. This mode allows the application to run normally, but produces no profiling data until a client attaches to the agent to give it instructions. When this option is selected, the Java Profiling Agent produces only XML fragments instead of a complete XML document.
    controlled 这个和enable差不多
    The profiling agent preempts the JVM from initialization (the agent is loaded but it blocks the application from running) until it is attached to from the workbench and given instructions to start monitoring by a client. That is, when the profiling agent is launched in controlled mode, it will appear to hang the JVM until asked to start monitoring and it will produce only XML fragments instead of a complete XML document.

    以下是我的启动脚本,注意Xmx Xms XX:MaxPermSize这些参数试具体情况而定

     写道
    java -Xmx1G -Xms512M -XX:MaxPermSize=512M -agentlib:JPIBootLoader=JPIAgent:server=standalone,filters=filters.txt;CGProf -classpath C:\test\liferay-portal-6.0.5\tomcat-6.0.26\bin\bootstrap.jar -Dcatalina.home=C:\test\liferay-portal-6.0.5\tomcat-6.0.26 -Dcatalina.base=C:\test\liferay-portal-6.0.5\tomcat-6.0.26 org.apache.catalina.startup.Bootstrap -config C:\test\liferay-portal-6.0.5\tomcat-6.0.26\conf\server.xml start
    filters.txt 
    com.company.* * INCLUDE
    org.springframework.* * EXCLUDE
    * * EXCLUDE
      


     

       发表时间:2010-10-03  
    好像只是介绍了一下安装而已
    0 请登录后投票
       发表时间:2010-10-03  
    可以有怎么用的吗?最好有个截图!
    0 请登录后投票
       发表时间:2010-10-03  
    yhjhoo 写道
    可以有怎么用的吗?最好有个截图!


    用是肯定可以的,我国庆后可以附上截图(环境在公司的电脑里)

    现在的问题是非standalone模式下,效率的确有问题,哪怕我设置了filters

    但是在standalone模式下是静态的,对于web服务这种应用线程很多,记录的数据量比较大,而且多次访问在很多数据上是很难观察到的
    0 请登录后投票
    论坛首页 Java企业应用版

    跳转论坛:
    Global site tag (gtag.js) - Google Analytics