在 JVM 启动参数中添加,然后重启应用。
- -javaagent:/home/admin/tprofiler/lib/tprofiler.jar
- -Dprofile.properties=/home/admin/tprofiler/lib/profile.properties
- java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient [192.168.132.*.*] [port] status #远程查看状态操作
- java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient [192.168.132.*.*] [port] start #远程开始操作
- java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient [192.168.132.*.*] [port] stop #远程停止操作
- java -cp tprofiler.jar com.taobao.profile.client.TProfilerClient [192.168.132.*.*] [port] flushmethod #远程刷出方法数据
2.2 TProfiler 性能方法的采集
TProfiler 能够生成日志:tmethod.log、tprofiler.log、tsampler.log。
执行如下命令,会生成 method.log 和 thread.log:
- java -cp ../lib/tprofiler-1.0.1.jar com.taobao.profile.analysis.SamplerLogAnalysis tsampler.log method.log thread.log
method.log 文件格式说明:
- 方法信息 采样过程中方法出现次数
- org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1131) 54
- org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:498) 54
- org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) 36
- org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44) 36
- org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:163) 36
- org.jboss.netty.channel.socket.nio.SelectorUtil.select(SelectorUtil.java:38) 36
- org.I0Itec.zkclient.ZkEventThread.run(ZkEventThread.java:67) 36
- com.alibaba.dubbo.remoting.exchange.support.DefaultFuture$RemotingInvocationTimeoutScan.run(DefaultFuture.java:300) 18
- com.taobao.profile.thread.TimeControlThread.run(TimeControlThread.java:116) 18
- com.taobao.profile.thread.SamplerThread.run(SamplerThread.java:57) 18
- com.taobao.profile.thread.TimeControlThread.await(TimeControlThread.java:84) 18
- com.taobao.profile.thread.InnerSocketThread.run(InnerSocketThread.java:44) 18
- com.taobao.profile.thread.DataDumpThread.run(DataDumpThread.java:69) 17
- org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:492) 1
- org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) 1
- com.taobao.profile.thread.DataDumpThread.run(DataDumpThread.java:62) 1
thread.log 文件格式说明:
- 线程信息 采样过程中线程出现次数
- 26 ZkClient-EventThread-26-192.168.150.149:2181 WAITING 18
- 3 Finalizer WAITING 18
- 47 DubboResponseTimeoutScanTimer TIMED_WAITING 18
- 36 New I/O client worker #1-1 RUNNABLE 18
- 29 DubboRegistryFailedRetryTimer-thread-1 TIMED_WAITING 18
- 30 ZkClient-EventThread-30-192.168.150.149:2181 WAITING 18
- 27 main-SendThread(192.168.150.149:2181) RUNNABLE 18
- 31 main-SendThread(192.168.150.149:2181) RUNNABLE 18
- 8 TProfiler-DataDump TIMED_WAITING 18
- 52 DestroyJavaVM RUNNABLE 18
- 12 VM JFR Buffer Thread RUNNABLE 18
- 49 global-client-idle-conn-cleanup-scheduler-4-1 TIMED_WAITING 18
- 5 Signal Dispatcher RUNNABLE 18
- 40 commons-pool-EvictionTimer TIMED_WAITING 18
- 23 main-EventThread WAITING 18
- 10 JFR request timer WAITING 18
- 6 TProfiler-TimeControl TIMED_WAITING 18
- 32 main-EventThread WAITING 18
- 46 jupiter-0-ClientToProxyAcceptor-0 RUNNABLE 18
- 9 TProfiler-Sampler RUNNABLE 18
- 28 main-EventThread WAITING 18
- 2 Reference Handler WAITING 18
- 45 ObjectCleanerThread TIMED_WAITING 18
- 22 main-SendThread(192.168.150.199:2181) RUNNABLE 18
- 19 RMI TCP Accept-0 RUNNABLE 18
- 48 print-cache-job-1 TIMED_WAITING 18
- 7 TProfiler-InnerSocket RUNNABLE 18
- 43 dubbo-remoting-client-heartbeat-thread-2 WAITING 18
- 50 rxnetty-nio-eventloop-2-1 RUNNABLE 18
- 33 DubboSaveRegistryCache-thread-1 WAITING 18
- 42 New I/O client worker #1-2 RUNNABLE 18
- 17 RMI TCP Accept-0 RUNNABLE 18
- 18 RMI TCP Accept-18090 RUNNABLE 18
- 34 DubboClientReconnectTimer-thread-1 WAITING 10
- 54 jupiter-0-ClientToProxyWorker-1 RUNNABLE 10
- 60 jupiter-0-ProxyToServerWorker-1 RUNNABLE 10
- 58 jupiter-0-ProxyToServerWorker-2 RUNNABLE 10
- 53 jupiter-0-ClientToProxyWorker-0 RUNNABLE 10
- 41 DubboClientReconnectTimer-thread-2 TIMED_WAITING 10
- 57 jupiter-0-ProxyToServerWorker-0 RUNNABLE 10
- 55 jupiter-0-ClientToProxyWorker-2 RUNNABLE 10
- 56 jupiter-0-ClientToProxyWorker-3 RUNNABLE 10
- 59 jupiter-0-ProxyToServerWorker-3 RUNNABLE 10
- 41 DubboClientReconnectTimer-thread-2 WAITING 8
- 34 DubboClientReconnectTimer-thread-1 TIMED_WAITING 8
- 37 DubboClientHandler-192.168.149.183:20880-thread-1 TIMED_WAITING 3
- 35 NettyClientBoss-thread-1 TIMED_WAITING 2
- 44 DubboClientHandler-192.168.150.149:20892-thread-1 TIMED_WAITING 2
- 35 NettyClientBoss-thread-1 TERMINATED 1
(编辑:ASP站长网)
|