当前位置:文档之家› jprofiler监控工具使用说明

jprofiler监控工具使用说明

JProfiler安装部署说明JProfiler是一个全功能的Java剖析工具(profiler),专用于分析J2SE和J2EE应用程序。

它把CPU、执行绪和内存的剖析组合在一个强大的应用中。

JProfiler可提供许多IDE整合和应用服务器整合用途。

JProfiler直觉式的GUI让你可以找到效能瓶颈、抓出内存漏失(memory leaks)、并解决执行绪的问题。

它让你得以对heap walker作资源回收器的root analysis,可以轻易找出内存漏失;heap快照(snapshot)模式让未被参照(reference)的对象、稍微被参照的对象、或在终结(finalization)队列的对象都会被移除;整合精灵以便剖析浏览器的Java外挂功能,JProfiler功能很强大,可以监控普通的java application, applet, java web start, application server 等。

除了可以监控本地的程序,还可以对远程服务器上跑的应用进行监控。

目前JProfiler最新版本是6.0,由于JProfiler需要注册码,网上找到的资源中windows、linux都破解的只有4.3.2版本,这次就使用这个版本进行说明。

最新版下载连接/download/jprofiler/files.php。

一、安装说明在监控端安装windows版的jprofiler4,在服务器端安装linux版的jprofiler4。

windows下安装:点击exe文件进行安装,安装后使用文件中的注册码进行注册linux下服务端安装:直接解压即可二、配置对java application的监控下面以JProfiler监控远程应用程序为例,来说明对远程应用程序监控的配置方法:一、首先启动JProfiler,出现quick start对话框,选择An application on a remote computer,next,如下图:二、有2个选项,on this computer和on a remote computer,这里是选择被监控的程序的位置,这里选择on a remote computer,同时选择远程机器的类型是windows还是linux等,如下图:三、填写远程机器地址,这里是192.168.9.53,如下图:四、填写远程机器JProfiler的安装地址,我这里是/home/sps/jprofiler4,如下图:五、选择远程机器的java运行环境,这里是sun\1.5.0\hotspot,如下图:六、默认监控端口8849,如下图:七、Wait for ……为了在开发环境中获取监控的信息,它将等待远程计算机上的Jprofile GUI 启动,并和本机建立连接,这种方式比较便于修改jprofiler的配置信息。

Don't wait for …… 不必等待远程计算机的Jprofile GUI 先启动和建立连接,立即启动。

但在启动远程应用程序前必须校验当前所配置会话的配置文件。

虚拟机参数将参考Jprofile 的config 文件的路径。

选择Don't wait,立刻启动。

八、选择远程机器读取配置文件的位置,这里是/home/sps/jprofiler4/config,同时手工维护配置文件的改动,选择manual同步。

同步方式:Manual synchronization;copy to diretory;execute command:提供三种同步方式,这里选择的是第一个手工同步,如下图:九、这里要注意,重点在这里,如果不看清楚这个说明信息,会导致配置失败,需要将里面的信息拷贝出来。

Integration type: [Generic application]Selected JVM: Sun 1.5.0 (hotspot)Startup mode: Don't wait for JProfiler GUI, startup immediatelyImportant: The local config file C:\Documents andSettings\Administrator\.jprofiler4\config.xml must be copied manually to/home/sps/jprofiler4/config on the remote computer when the profiling settings are changed.(1) Please insert-agentlib:jprofilerti=port=8849,nowait,id=133,config=/home/sps/jprofiler4/config/config .xml -Xbootclasspath/a:/home/sps/jprofiler4/bin/agent.jarinto the start command of your remote application right after the java command.(2) Please add/home/sps/jprofiler4/bin/linux-x86to the environment variable LD_LIBRARY_PATH.A remote session named Remote application on 192.168.9.53 will be created that connects to a running instance of the remote application that is started with the modified start command.解释一下:1、将配置文件config.xml 从本机C:/Documents and Settings/Administrator/.jprofiler4/拷贝到远程服务器192.168.9.53上的/home/sps/jprofiler4/config/目录下;2、在java启动脚本中增加下面信息-agentlib:jprofilerti=port=8849,nowait,id=133,config=/home/sps/jprofiler4/config/config .xml -Xbootclasspath/a:/home/sps/jprofiler4/bin/agent.jar,注:在启动脚本中,增加上面信息后,会嵌套启动jprofiler4进程,对性能会有一定的影响,但具体影响程度暂无法评估,所以在不需要监控时,建议对这些脚本进行注释。

如:Linux下:$JAVACMD-Did=vgopTool \-cp ${CLASSPATH} \-DCONFIG_FILE=${MY_HOME}/cfg/config.properties \-agentlib:jprofilerti=port=8849,nowait,id=130,config=/home/sps/jprofiler4/config/config .xml -Xbootclasspath/a:/home/sps/jprofiler4/bin/agent.jar com.mgj.main.MainWindows下:java -classpath ../lib/dom4j-1.6.1.jar;"-agentlib:jprofilerti=port=8849,nowait,id=131,config=C:\Documents andSettings\Administrator\.jprofiler4\config.xml" "-Xbootclasspath/a:C:\ProgramFiles\jprofiler4\bin\agent.jar" com/mgj/main/Main3、/home/sps/jprofiler4/bin/linux-x86加入到环境变量中,变量名称为:LD_LIBRARY_PATH十、选择yes,finish。

这个远程监控的session就建好了,可以马上连接进行监控了,上面配置中还有些其他的选择,可以根据情况进行不同的配置。

注意:拷贝config.xml 到远程时,必须完成第10步。

在第9步的时候config.xml 未完成,此时拷贝,会出现 session 找不到的错误。

三、配置对application server的监控下面以JProfiler+Jboss为例,来说明JProfiler对远程application server监控的配置方法:打开JProfiler显示QuickStart对话框:1、选择An application server,locally or remotely,如下图:2、选择服务器点击Next进入“服务器选择”对话框,选择JBoss 4.x,如下图3、选择监控目标:本地或远程,本次选择远程,如下图:4、填写监控服务器ip地址,如下图:5、填写监控服务器中jprofiler的安装目录,如下图:6、选择启动脚本点击Next进入“启动脚本选择”对话框,输入JBoss启动脚本(run.bat)的路径,远程的可以将jboss 启动脚本(run.sh)下载到本地,然后选择。

如下图:7、选择JVM的厂商、版本和模式点击Next进入“JVM选择”对话框,我们选择Sun公司的hotspot 1.5.0,如下图:8、输入JProfiler的端口号点击Next进入“JProfiler端口输入”对话框,保持默认不变,如下图:9、选择JBoss是否在连接到JProfiler后再启动JBoss点击Next进入选择页面1、JBoss是否在连接到JProfiler后再启动2、不等待JProfiler连接,直接启动这里选择2,只在需要监控时才连接,对jboss运行不产生影响,如下图:10 填写linux下jprofiler配置文件的保存路径11、确认配置点击Next进入“确认配置”对话框,确认配置是否正确,如下图,如果不正确点击Back到相应对话框进行修改。

这里要注意几个地方:1、配置文件的保存路径C:\Documents and Settings\Administrator\.jprofiler4\config.xml2、运行脚本名称:c:\run_jprofiler.sh注意脚本里面的下列代码,就是本次配置新增的JAVA_OPTS="-agentlib:jprofilerti=port=8849,nowait,id=116,config=/home/sps/jprofiler4/con fig/config.xml -Xbootclasspath/a:/home/sps/jprofiler4/"12、配置完成点击Next进入“完成配置”对话框,点击finish完成配置,配置完成后将本地的配置文件C:\Documents and Settings\Administrator\.jprofiler4\config.xml 拷贝到linux下放置配置文件的地方,如://home/sps/jprofiler5/config将新生成的jboss启动脚本c:\run_jprofiler.sh 拷贝到linux下jboss的bin目录下注:在启动脚本中,增加启动jprofiler4脚本信息,会嵌套启动jprofiler4进程,对性能会有一定的影响,但具体影响程度暂无法评估,所以在不需要监控时,建议对这些脚本进行注释。

相关主题