在这里插入图片描述

前言

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命令查看调用方法输出参数;

原文地址:https://blog.csdn.net/Pireley/article/details/134722073

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_19753.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注