Giter Club home page Giter Club logo

wjw0315 / arthas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shiyindaxiaojie/arthas

0.0 0.0 0.0 27.42 MB

阿里巴巴 Java 在线诊断利器,基于 3.6.6 版本改造,支持 tunnel-server 服务自动发现,增加 Spring Security 权限控制。

Home Page: https://arthas.aliyun.com/

License: Apache License 2.0

Shell 1.25% JavaScript 0.96% C++ 2.71% C 10.11% ActionScript 0.01% Objective-C 0.09% Java 74.32% Groovy 0.01% TypeScript 1.65% CSS 0.01% HTML 1.75% CMake 0.01% Batchfile 0.36% Vue 6.58% Dockerfile 0.07% Roff 0.11% SCSS 0.01%

arthas's Introduction

Arthas 在线诊断工具

Arthas 是阿里巴巴开源的在线诊断工具,提供了 Dashboard 负载总览Thread 线程占用Stack 堆栈查看Watch 性能观测 等功能。笔者参考原作者 @wf2311 的实现进行了优化:

  1. 服务发现:自动获取接入的应用列表 IP 和端口,无须手动输入 AgentId
  2. 权限控制:基于 Spring Security 实现登录控制,并支持 Nacos 动态绑定账号与服务

本文档只介绍 arthas-tunnel-server 项目,其他细节请查阅 官方文档

演示图例

改造前

改造后

登录控制

配置管理

arthas:
  tunnel:
    users:
      - name: admin
        password: 123456
        roles: '*' # 全部授权
      - name: user
        password: 123456
        roles:
          - eden-gateway # 特定服务授权

如何构建

本项目默认使用 Maven 来构建,最快的使用方式是 git clone 到本地。在项目的根目录执行 mvn package -T 4C 完成本项目的构建。

如何启动

IDEA 启动

本项目不依赖外部组件,可以直接启动运行。

  1. 在项目目录下运行 mvn install(如果不想运行测试,可以加上 -DskipTests 参数)。
  2. 进入 tunnel-server 目录,执行 mvn spring-boot:run 或者启动 ArthasTunnelApplication 类。运行成功的话,可以看到 Spring Boot 启动成功的界面。
  3. 进入 web-ui 目录,执行 yarn run dev:tunnel 或者 yarn run dev:ui。运行后控制台日志输出 http://localhost:8000 地址,点击访问。

镜像启动

本项目已发布到 Docker Hub,请执行参考命令运行。

docker run -p 8080:8080 --name=arthas-tunnel-server -d shiyindaxiaojie/arthas-tunnel-server

如何部署

FatJar 部署

执行 mvn clean package 打包成一个 fat jar,参考如下命令启动编译后的控制台。

java -Dserver.port=8080 -jar target/arthas-tunnel-server.jar

Docker 部署

本项目使用了 Spring Boot 的镜像分层特性优化了镜像的构建效率,请确保正确安装了 Docker 工具,然后执行以下命令。

docker build -f docker/Dockerfile -t arthas-tunnel-server:{tag} .

Helm 部署

以应用为中心,建议使用 Helm 统一管理所需部署的 K8s 资源描述文件,请参考以下命令完成应用的安装和卸载。

helm install arthas-tunnel-server ./helm # 部署资源
helm uninstall arthas-tunnel-server # 卸载资源

如何接入

为了减少客户端集成的工作,您可以使用 eden-architect 框架,只需要两步就可以完成 Arthas 的集成。

  1. 引入 Arthas 依赖
<dependency>
    <groupId>io.github.shiyindaxiaojie</groupId>
    <artifactId>eden-arthas-spring-boot-starter</artifactId>
</dependency>
  1. 开启 Arthas 配置
spring:
  arthas: 
    enabled: false # 默认关闭,请按需开启

arthas: # 在线诊断工具
  agent-id: ${spring.application.name}@${random.value}
  tunnel-server: ws://localhost:7777/ws # Arthas 地址
  session-timeout: 1800
  telnet-port: 0 # 随机端口
  http-port: 0 # 随机端口

笔者提供了两种不同应用架构的示例,里面有集成 Sentinel 的示例。

  • 面向领域模型的 COLA 架构,代码实例可以查看 eden-demo-cola
  • 面向数据模型的 分层架构,代码实例请查看 eden-demo-layer

变更日志

请查阅 CHANGELOG.md

arthas's People

Contributors

hengyunabc avatar hollowman6 avatar kylixs avatar hearen avatar shiyindaxiaojie avatar beiwei30 avatar ralf0131 avatar xenoamess avatar earayu avatar xuzhiyiyoh avatar xudaotutou avatar fatpandac avatar joecqupt avatar bohrqiu avatar wangji92 avatar superheizai avatar 0xflotus avatar qxo avatar anjia0532 avatar roger3581321 avatar sjha2048 avatar garenchan avatar sheepblueblue avatar yx9o avatar pandaapo avatar dependabot[bot] avatar jamesxuhaozhe avatar lzc-alioo avatar snipercy avatar j-cod3r avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.