当前位置: 首页 > news >正文

Arthas常用的命令(三)--monitor、jad 、stack

monitor:监控方法的执行情况

监控指定类中方法的执行情况
用来监视一个时间段中指定方法的执行次数,成功次数,失败次数,耗时等这些信息

  • 参数说明

方法拥有一个命名参数 [c:],意思是统计周期(cycle of output),拥有一个整型的参数值

参数名称参数说明
class-pattern类名表达式匹配
method-pattern方法名表达式匹配
-E开启正则表达式匹配,默认为通配符匹配
-c统计周期,默认值为120秒
  • 示例: 监控demo.MathGame类,并且每5S更新一次状态。
monitor *.MathGame primeFactors -c 5

执行结果如下:

  • 结果说明 :
监控项说明
timestamp时间戳
classJava类
method方法(构造方法、普通方法)
total调用次数
success成功次数
fail失败次数
rt平均耗时
fail-rate失败率

jad 反编译

  • jad 反编译代码:
jad 包的路径.类名 方法名

如果不确定包的路径,也可以用 *. 匹配,比如 Demo类,就是 *.Demo。

示例如下:

jad *.MathGame primeFactors

结果如下:

可以看到反编译后的代码。

[arthas@18228]$ jad *.MathGame primeFactorsClassLoader:
+-sun.misc.Launcher$AppClassLoader@1909752+-sun.misc.Launcher$ExtClassLoader@a14482Location:
/D:/arthas/math-game.jarpublic List<Integer> primeFactors(int number) {
/*44*/     if (number < 2) {
/*45*/         ++this.illegalArgumentCount;throw new IllegalArgumentException("number is: " + number + ", need >= 2");}ArrayList<Integer> result = new ArrayList<Integer>();
/*50*/     int i = 2;
/*51*/     while (i <= number) {
/*52*/         if (number % i == 0) {
/*53*/             result.add(i);
/*54*/             number /= i;
/*55*/             i = 2;continue;}
/*57*/         ++i;}
/*61*/     return result;}Affect(row-cnt:1) cost in 103 ms.

stack 参数说明

作用:输出当前方法被调用的调用路径。

参数名称参数说明
class-pattern类名表达式匹配
method-pattern方法名表达式匹配
condition-express条件表达式
-E开启正则表达式匹配,默认为通配符匹配
-n执行次数限制
-m指定 Class 最大匹配数量,默认值为 50。
  • stack查看调用路径:
[arthas@19440]$ stack *.MathGame primeFactors
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 63 ms, listenerId: 25
ts=2023-06-09 22:57:47;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@1909752@demo.MathGame.primeFactors()at demo.MathGame.run(MathGame.java:24)at demo.MathGame.main(null:-1)
  • 根据执行时间来过滤:
[arthas@19440]$ stack demo.MathGame primeFactors '#cost>0.5'
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 29 ms, listenerId: 29
ts=2023-06-09 23:06:37;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@1909752@demo.MathGame.primeFactors()at demo.MathGame.run(MathGame.java:24)at demo.MathGame.main(null:-1)

参考资料:

https://blog.csdn.net/lydms/article/details/125238249

http://www.lryc.cn/news/461176.html

相关文章:

  • Power BI之常用DAX函数使用介绍——提供数据源练习
  • SQL-触发器(trigger)的详解以及代码演示
  • 【devops】x-ui 实现一键安装 x-ray 打造高速国际冲浪 | xray管理平台
  • Linux系统编程——进程标识、进程创建
  • 【超级福利】openMind开源实习来袭,奖励高达万元,解锁你的AI实践新篇章!
  • React JSX 使用条件语句渲染UI的两种写法
  • 谷歌-BERT-第四步:模型部署
  • 猫咪化身蒲公英,浮毛满屋乱飞,有哪些宠物空气净化器值得购买?
  • 端到端的开源OCR模型:GOT-OCR-2.0,支持场景文本、文档、乐谱、图表、数学公式等内容识别!
  • 自注意力机制self-attention中QKV矩阵的含义
  • 【前端】Bootstrap:栅格系统 (Grid System)
  • 一文读懂,SSL证书怎么验签安装使用?
  • Mysql(八) --- 视图
  • SQL注入原理、类型、危害与防御
  • 第2讲 数据库系统的结构抽象与演变
  • Git创建开发分支命名规则
  • 【纯前端excel导出】vue2纯前端导出excel,使用xlsx插件,修改样式、合并单元格
  • 如何在极速浏览器中实现谷歌浏览器的扩展功能
  • Web安全 - 跨站点请求伪造CSRF(Cross Site Request Forgery)
  • C++游戏开发完整学习路径
  • vue3之 shallowRef、markRaw
  • 影刀RPA实战:操作Mysql数据库
  • 【c++】c++11多线程开发
  • PW37R_V1 产品规格书
  • android11 usb摄像头添加多分辨率支持
  • 【开源免费】基于SpringBoot+Vue.JS房屋租赁系统(JAVA毕业设计)
  • JavaScript全面指南(二)
  • Nginx:Linux配置Nginx
  • WebRTC音频 04 - 关键类
  • Elasticsearch:Redact(编辑) processor