Jprofiler在linux上的安装和配置,以及如何通过windows客户端监控JAVA应用程序

下载安装文件

下载windows版本的JprofilerLinux版本的Jprofiler,且两者版本保持一致。
Jprofiler
下载地址:http://www.ej-technologies.com/

例如本文下载的版本是5.2.4

Windows版本:jprofiler_windows_5_2_4.exe

Linux版本:jprofiler_linux_5_2_4.tar.gz

 

 

 

例子

准备工作完成以后,下面我以一个例子来演示,怎样利用Jprofiler 来监控java程序。

1、编写死循环例子程序,并把它上传到linux服务器

一个死循环的javaTestWhile。然后用jprofiler来监控它消耗cpu的情况。

package com.test;

 

public class TestWhile extends Thread{

    @Override

    public void run() {

       while(true){

           try {

              for (int i = 0; i < 20; i++) {

                  System.out.print("* ");

                  Thread.sleep(1);  //睡眠1ms

              }

              System.out.println("");

           } catch (Exception e) {

           }

       }

    }

    public static void main(String[] args) {

       new TestWhile().start();

    }

}

 

部署该程序到服务器:例如上传classes文件夹下的目录到/home/mpsp/test/目录下

 

 

 

配置windows Jprofile

启动完成后点击菜单Session -àNew Window

 

选择An application server, locally or remotely 来配置一个服务 --ànext

 

 

 

由于本次例子是来监控一个普通的程序所以选择Generic application -ànext

如果你想用jprofiler监控部署在tomcat5.0Web应用,那么请选择Apache Tomcat5.x,配置大同小异。

 

 

 

选择LinuxX86/AMD64 -ànext

选择 startup immediately, connect later with the JProfiler GUI -ànext

 

 

填写Jprofiler部署路径ànext

 

 

 

 

 

Jprofiler config.xml文件所存放的路径,选择在Jpofiler根目录下ànext

 

根据jdk版本选择,我选择sun-1.5 -ànext

 

Jprofiler端口默认是8849,由于一些原因我更改为26010端口—>next

 

 

这段文字建议保持到一个记事本里。

其中重要的有

Important: The local config file C:/Documents and Settings/wwj/.jprofiler5/config.xml must be copied manually to /home/mpsp/jprofiler5 on the remote computer when the profiling settings are changed.

 

config.xml存放的路径C:/Documents and Settings/wwj/.jprofiler5/config.xml,把这个文件上传到Jprofiler的根目录下:/home/mpsp/jprofiler5 ,在上传之前,先把config.xml文件中的javaHome="C:/Java/jre1.5.0_15"更改为服务器的JAVA_HOME路径/home/mpsp/jdk1.5.0_19

 

 

-agentlib:jprofilerti=port=8849,nowait,id=111,config=/home/mpsp/jprofiler5/config.xml  -Xbootclasspath/a:/home/mpsp/jprofiler5/bin/agent.jar

如果要用Jprofiler来监控TestWhile,则需要java 命令前面的加上这些参数

Java -agentlib:jprofilerti=port=8849,nowait,id=111,config=/home/mpsp/jprofiler5/config.xml  -Xbootclasspath/a:/home/mpsp/jprofiler5/bin/agent.jar com.test.TestWhile

 

Please add

/home/mpsp/jprofiler5/bin/linux-x86

to the environment variable LD_LIBRARY_PATH.

在服务器的环境变量里加入LD_LIBRARY_PATH = /home/mpsp/jprofiler5/bin/linux-x86

 

vi /etc/profiler

在末尾加上

LD_LIBRARY_PATH=/home/mpsp/zj_unioncard/jprofiler5/bin/linux-x86

export LD_LIBRARY_PATH

完成后别忘了运行source /etc/profile 让刚才的配置生效

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值