阿里云Arthas使用——通过watch命令查看类的返回值 & 捞数据出来

在这里插入图片描述

前言

Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用 load、内存、gc、线程的状态信息,并能在不修改应用代码的情况下,对业务问题进行诊断,包括查看方法调用的出入参、异常,监测方法执行耗时,类加载信息等,大大提升线上问题排查效率。

本篇博客介绍如何通过watch命令查看调用方法的输出参数。

其他的Arthas博客文章如下:

引出


1.JVM调优的工具阿里云的Arthas的使用,安装和使用;
2.watch命令查看调用方法的输出参数

https://arthas.aliyun.com/doc/install-detail.html

as.sh方式的安装

报错:telnet is not installed

[root@iZuf61wy7p4tbr7lmwv18iZ software]# ./as.sh 
Error: telnet is not installed. Try to use java -jar arthas-boot.jar
 yum install -y telnet-server.x86_64
 yum install -y telnet.x86_64

在这里插入图片描述

在这里插入图片描述

报错:unzip is not installed

[root@iZuf61wy7p4tbr7lmwv18iZ software]# ./as.sh 
Error: unzip is not installed. Try to use java -jar arthas-boot.jar
yum -y install telnet.x86_64 unzip zip

在这里插入图片描述

报错:no available java process to attach

Error: no available java process to attach

在这里插入图片描述

通过Arthas进行捞数据

分析出要watch的类

一步一步分析要watch的类

在这里插入图片描述

找到是哪个类的哪个方法

在这里插入图片描述

watch命令

https://arthas.aliyun.com/doc/commands.html

让你能方便的观察到指定函数的调用情况。能观察到的范围为:返回值抛出异常入参,通过编写 OGNL 表达式进行对应变量的查看。

观察表达式,默认值是{params, target, returnObj}

在这里插入图片描述

通过as.sh启动arthas

在这里插入图片描述

启动arthas成功

在这里插入图片描述

watch com.wattsonic.iot.gateway.modbus.command.GroupCommand parseResult 'returnObj' -x3

在这里插入图片描述

[arthas@5418]$ watch com.wattsonic.iot.gateway.modbus.command.GroupCommand parseResult 'returnObj' -x3
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 120 ms, listenerId: 5
method=com.wattsonic.iot.gateway.modbus.command.GroupCommand.parseResult location=AtExit
ts=2023-11-29 17:27:41; [cost=0.336862ms] result=@HashMap[
    @String[L2加热器目标水温]:@Long[0],
    @String[L3加热器目标水温]:@Long[0],
    @String[L1加热器24h用电量]:@Long[0],
    @String[L2加热器24h用电量]:@Long[0],
    @String[加热器状态STATE1]:@Long[1500],
    @String[最大总功率]:@Long[0],
    @String[L2加热器负载功率]:@Long[0],
    @String[L3加热器负载功率]:@Long[0],
    @String[加热器状态STATE2]:@Long[0],
    @String[L3加热器24h用电量]:@Long[0],
    @String[L2加热器当前温度]:@Long[1500],
    @String[L1加热器负载功率]:@Long[0],
    @String[L1加热器目标水温]:@Long[0],
    @String[L1加热器当前温度]:@Long[0],
    @String[L3加热器当前温度]:@Long[1500],
]

在这里插入图片描述


总结

1.JVM调优的工具阿里云的Arthas的使用,安装和使用;
2.watch命令查看调用方法的输出参数;

猜你喜欢

转载自blog.csdn.net/Pireley/article/details/134722073
今日推荐