Arthas 使用场景

  1. 是否有一个全局视角来查看系统的运行状况?
  2. 为什么 CPU 又升高了,到底是哪里占用了 CPU ?
  3. 运行的多线程有死锁吗?有阻塞吗?
  4. 程序运行耗时很长,是哪里耗时比较长呢?如何监测呢?
  5. 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
  6. 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
  7. 遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
  8. 有什么办法可以监控到 JVM 的实时运行状态?

下载安装

1. 下载 wget https://arthas.gitee.io/arthas-boot.jar
2. 启动 java -jar arthas-boot.jar --target-ip 192.168.200.100 --http-port 8563 PID

默认arthas只能本地访问,上面通过指定ip 和 端口就能远程监控了。

  常用指令   cls 清空面板 ;exit 退出当前会话 ;stop 关闭arthas

Arthas线上问题排查

常用命令

后续再补吧

实战演示

定位调用链路

比如现在有一个请求过来,我要查看它的调用链路,每个方法请求时长,以及每个方法的请求参数和返回值来分析问题。

@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/test")
    public Map test(){
        Map map = new HashMap();
        map.put("code",1);
        map.put("data",userService.getUser());
        map.put("msg","执行成功");
        return map;
    }
}



@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    public User getUser(){
        try {
            Thread.sleep(1000);
        }catch (Exception e){
        }
        return userMapper.getUser();
    }
}



@Service
public class UserMapper {
    public User getUser(){
        return new User();
    }
}
调用链路案例

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-04-27
  • 2021-07-03
  • 2021-08-03
  • 2021-09-30
猜你喜欢
  • 2019-09-18
  • 2022-01-21
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
相关资源
相似解决方案