一、基於JVisualVM的可視化監控
1、打開C:\Program Files\Java\jdk1.8.0_131\bin下的jvisualvm.exe
2、打開后,會列出本機所有的Java進程

3、安裝插件visualvm
1)查看java的版本

2)打開https://visualvm.github.io/pluginscenters.html
選擇131

3)打開工具-> 插件->設置

編輯, 設置為https://visualvm.github.io/uc/8u131/updates.xml.gz

然后在可用插件中選擇Visual GC,然后“安裝”

然后安裝BTrace

4、使用JVisualVM+BTrace 查看訪問參數
前置條件: 接口測創建和BTrace腳本的創建,參考https://www.cnblogs.com/linlf03/p/10165881.html
BTrace打開位置為

然后將Btrace腳本復制進去
package com.example.monitor_tuning.chapter4;
import com.sun.btrace.AnyType;
import com.sun.btrace.BTraceUtils;
import com.sun.btrace.annotations.*;
/**
* 此Btrace腳本和要跟蹤的代碼不是放在同一個工程里的。這里演示方便,放在一起。
*/
@BTrace
public class PrintArgSimple {
/*要攔截哪個類,哪個方法,什么時候攔截*/
@OnMethod(
clazz = "com.example.monitor_tuning.chapter4.Ch4Controller",
method="arg1",
location = @Location(Kind.ENTRY)
)
/*ProbeClassName 方法類名; ProbeMethodName 方法名 ; AnyType[] 方法參數*/
public static void anyRead(@ProbeClassName String pcn, @ProbeMethodName String pmn, AnyType[] args)
{
BTraceUtils.printArray(args);
BTraceUtils.println(pcn + "," + pmn);
BTraceUtils.println();
}
}
點擊start,編譯完成
訪問http://localhost:8080/monitor_tuning/ch4/arg1?name=Bob
顯示效果:

