---
title: "图解JProfiler监控远程机器"
author: "jeffen2006"
date: "2006-12-21T10:52:48Z"
tags: ["JVM", "Linux", "SUN", "Windows", "XML"]
categories: ["企业架构"]
slug: "jprofiler"
draft: false
lastmod: "2006-12-21T10:52:48Z"
id: 39931
url: "https://jeffen2006.iteye.com/blog/39931"
---

近来我们的服务器频频出现资源耗尽崩溃的情况，于是决定找一款监控的软件进行分析。在javaeye上看了很多帖子后决定使用JProfiler。闲话少说，我们需要监控远端服务器上的程序如何做呢。

准备工作：在本地机器和远端机器上都安装好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等等。

三、填写远程机器地址，我这里是10.1.4.88。

四、填写远程机器JProfiler的安装地址，我这里是D:\\Program Files\\jprofiler4。

五、选择远程机器的java运行环境，我这里是sun\\1.5.0\\hotspot。

六、默认监控端口8849。

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

八、选择远程机器读取配置文件的位置，我这里是D:\\Program Files\\jprofiler4。同时我手工维护配置文件的改动，选择manual同步。

九、这里要注意，重点在这里，我就是没有看这个说明信息才导致前面配置的屡次失败。

Integration type: \[Generic application]  
Selected JVM: Sun 1.5.0 (hotspot)  
Startup mode: Don't wait for JProfiler GUI, startup immediately

Important: The local config file C:\\Documents and Settings\\sz-xjs-yangy\\.jprofiler4\\config.xml must be copied manually to D:\\Program Files\\jprofiler4 on the remote computer when the profiling settings are changed.

(1) Please insert

"-agentlib:jprofilerti=port=8849,nowait,id=166,config=D:\\Program Files\\jprofiler4\\config.xml"  "-Xbootclasspath/a:D:\\Program Files\\jprofiler4\\bin\\agent.jar"

into the start command of your remote application right after the java command.

(2) Please add

D:\\Program Files\\jprofiler4\\bin\\windows

to the environment variable PATH.

A remote session named Remote application on 10.1.4.88 will be created that connects to a running instance of the remote application that is started with the modified start command.

解释一下，就是将配置文件config.xml 从我本机C:\\Documents and Settings\\sz-xjs-yangy\\.jprofiler4拷贝到[\\\\10.1.4.88\\D$\\Program]() Files\\jprofiler4， 然后将D:\\Program Files\\jprofiler4\\bin\\windows加入到环境变量PATH中，最后运行你的java程序时加入提示的参数。

我就按照这些说明配置好，然后运行我的测试程序jeffen.test1.test1：  
D:\\yy&gt;java "-agentlib:jprofilerti=port=8849,nowait,id=165,config=D:\\Program Files\\jprofiler4\\config.xml"  "-Xbootclasspath/a:D:\\Program Files\\jprofiler4\\bin\\agent.jar"  jeffen.test1.test1

运行成功后。执行下步。

十、 选择yes，finish。

这个远程监控的session就建好了，可以马上连接进行监控了，上面配置中还有些其他的选择，有兴趣的可以看看说明都试试。