feat(docs): add right menu and optimize (#2224) #2161

This commit is contained in:
Fatpandac 2022-07-25 16:19:40 +08:00 committed by GitHub
parent d776a93b1e
commit 1b91777d74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 7233 additions and 481 deletions

View File

@ -1,6 +1,6 @@
## Arthas
![arthas](site/src/site/sphinx/arthas.png)
![arthas](site/docs/.vuepress/public/images/arthas.png)
[![Build Status](https://github.com/alibaba/arthas/workflows/JavaCI/badge.svg)](https://github.com/alibaba/arthas/actions)
[![codecov](https://codecov.io/gh/alibaba/arthas/branch/master/graph/badge.svg)](https://codecov.io/gh/alibaba/arthas)
@ -101,7 +101,7 @@ You can enter its interactive interface by executing `as.sh`, or execute `as.sh
* https://arthas.aliyun.com/doc/en/dashboard
![dashboard](site/src/site/sphinx/_static/dashboard.png)
![dashboard](site/docs/.vuepress/public/images/dashboard.png)
#### Thread
@ -301,7 +301,7 @@ ts=2018-09-18 10:11:45;thread_name=http-bio-8080-exec-10;id=d9;is_daemon=true;pr
See what is slowing down your method invocation with trace command:
![trace](site/src/site/sphinx/_static/trace.png)
![trace](site/docs/.vuepress/public/images/trace.png)
#### Watch
@ -388,7 +388,7 @@ $ classloader
* https://arthas.aliyun.com/doc/en/web-console
![web console](site/src/site/sphinx/_static/web-console-local.png)
![web console](site/docs/.vuepress/public/images/web-console-local.png)
#### Profiler/FlameGraph
@ -408,7 +408,7 @@ OK
View profiler results under arthas-output via browser:
![](site/src/site/sphinx/_static/arthas-output-svg.jpg)
![](site/docs/.vuepress/public/images/arthas-output-svg.jpg)
#### Arthas Spring Boot Starter

View File

@ -2,7 +2,7 @@
## Arthas
![arthas](site/src/site/sphinx/arthas.png)
![arthas](site/docs/.vuepress/public/images/arthas.png)
[![Build Status](https://github.com/alibaba/arthas/workflows/JavaCI/badge.svg)](https://github.com/alibaba/arthas/actions)
[![codecov](https://codecov.io/gh/alibaba/arthas/branch/master/graph/badge.svg)](https://codecov.io/gh/alibaba/arthas)
@ -91,7 +91,7 @@ curl -L https://arthas.aliyun.com/install.sh | sh
* https://arthas.aliyun.com/doc/dashboard
![dashboard](site/src/site/sphinx/_static/dashboard.png)
![dashboard](site/docs/.vuepress/public/images/dashboard.png)
#### Thread
@ -287,7 +287,7 @@ ts=2018-09-18 10:11:45;thread_name=http-bio-8080-exec-10;id=d9;is_daemon=true;pr
观察方法执行的时候哪个子调用比较慢:
![trace](site/src/site/sphinx/_static/trace.png)
![trace](site/docs/.vuepress/public/images/trace.png)
#### Watch
@ -377,7 +377,7 @@ $ classloader
* https://arthas.aliyun.com/doc/web-console
![web console](site/src/site/sphinx/_static/web-console-local.png)
![web console](site/docs/.vuepress/public/images/web-console-local.png)
#### Profiler/FlameGraph/火焰图
@ -396,7 +396,7 @@ OK
通过浏览器查看profiler结果
![](site/src/site/sphinx/_static/arthas-output-svg.jpg)
![](site/docs/.vuepress/public/images/arthas-output-svg.jpg)
#### Arthas Spring Boot Starter

View File

@ -1,5 +1,8 @@
const { localTheme } = require("./theme/index");
const {
activeHeaderLinksPlugin,
} = require("@vuepress/plugin-active-header-links");
const { copyCodePlugin } = require("vuepress-plugin-copy-code2");
const { redirectPlugin } = require("vuepress-plugin-redirect");
const { searchPlugin } = require("@vuepress/plugin-search");
@ -35,6 +38,7 @@ module.exports = {
lastUpdated: "上次更新",
contributorsText: "贡献者",
backToHome: "回到首页",
rightMenuText: "目录",
warning: "注意",
tip: "提示",
danger: "警告",
@ -105,5 +109,9 @@ module.exports = {
return redirects;
},
}),
activeHeaderLinksPlugin({
headerLinkSelector: "div.right-menu-item > a",
delay: 100,
}),
],
};

View File

@ -4,6 +4,38 @@ module.exports = [
"meta",
{ name: "viewport", content: "width=device-width, initial-scale=1.0" },
],
["meta", { property: "og:title", content: "Arthas" }],
[
"meta",
{
property: "og:image:alt",
content:
"Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - Fatpandac/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas",
},
],
["meta", { property: "og:image", content: "/images/arthas_mate_image.png" }],
[
"meta",
{
property: "og:description",
content:
"Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - Fatpandac/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas",
},
],
["meta", { property: "og:image:width", content: "1200" }],
["meta", { property: "og:image:height", content: "600" }],
[
"meta",
{ property: "twitter:image:src", content: "/images/arthas_mate_image.png" },
],
[
"meta",
{
property: "twitter:image:alt",
content:
"Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - Fatpandac/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas",
},
],
[
"script",
{},

View File

@ -46,7 +46,7 @@ module.exports = [
link: "/en/doc/download.md",
},
{
text: "COMMUNITY",
link: "https://github.com/alibaba/arthas/issues",
text: "COMMANDS",
link: "/en/doc/commands.md",
},
];

View File

@ -46,7 +46,7 @@ module.exports = [
link: "/doc/download.md",
},
{
text: "社区",
link: "https://github.com/alibaba/arthas/issues",
text: "命令列表",
link: "/doc/commands.md",
},
];

View File

@ -31,90 +31,7 @@ module.exports = {
},
],
},
{
text: "Commands",
collapsible: true,
link: "/en/doc/commands.md",
children: [
{
text: "jvm",
collapsible: false,
children: [
"/en/doc/dashboard.md",
"/en/doc/thread.md",
"/en/doc/jvm.md",
"/en/doc/memory.md",
"/en/doc/sysprop.md",
"/en/doc/sysenv.md",
"/en/doc/vmoption.md",
"/en/doc/perfcounter.md",
"/en/doc/logger.md",
"/en/doc/mbean.md",
"/en/doc/getstatic.md",
"/en/doc/ognl.md",
"/en/doc/heapdump.md",
"/en/doc/vmtool.md",
],
},
{
text: "class/classloader",
collapsible: false,
children: [
"/en/doc/sc.md",
"/en/doc/sm.md",
"/en/doc/jad.md",
"/en/doc/classloader.md",
"/en/doc/mc.md",
"/en/doc/dump.md",
"/en/doc/retransform.md",
"/en/doc/redefine.md",
],
},
{
text: "monitor/watch/trace - related",
collapsible: false,
children: [
"/en/doc/monitor.md",
"/en/doc/watch.md",
"/en/doc/trace.md",
"/en/doc/stack.md",
"/en/doc/tt.md",
],
},
{
text: "other",
collapsible: false,
children: [
"/en/doc/profiler.md",
"/en/doc/cat.md",
"/en/doc/echo.md",
"/en/doc/grep.md",
"/en/doc/base64.md",
"/en/doc/tee.md",
"/en/doc/pwd.md",
"/en/doc/auth.md",
"/en/doc/options.md",
],
},
{
text: "Basic",
collapsible: false,
children: [
"/en/doc/help.md",
"/en/doc/cls.md",
"/en/doc/session.md",
"/en/doc/reset.md",
"/en/doc/history.md",
"/en/doc/quit.md",
"/en/doc/stop.md",
{
text: "keymap",
link: "/en/doc/keymap.md",
},
],
},
],
},
"/en/doc/commands.md",
"/en/doc/web-console.md",
"/en/doc/tunnel.md",
"/en/doc/http-api.md",

View File

@ -35,90 +35,7 @@ module.exports = {
},
],
},
{
text: "命令列表",
collapsible: true,
link: "/doc/commands.md",
children: [
{
text: "jvm相关",
collapsible: false,
children: [
"/doc/dashboard.md",
"/doc/thread.md",
"/doc/jvm.md",
"/doc/memory.md",
"/doc/sysprop.md",
"/doc/sysenv.md",
"/doc/vmoption.md",
"/doc/perfcounter.md",
"/doc/logger.md",
"/doc/mbean.md",
"/doc/getstatic.md",
"/doc/ognl.md",
"/doc/heapdump.md",
"/doc/vmtool.md",
],
},
{
text: "class/classloader相关",
collapsible: false,
children: [
"/doc/sc.md",
"/doc/sm.md",
"/doc/jad.md",
"/doc/classloader.md",
"/doc/mc.md",
"/doc/dump.md",
"/doc/retransform.md",
"/doc/redefine.md",
],
},
{
text: "monitor/watch/trace相关",
collapsible: false,
children: [
"/doc/monitor.md",
"/doc/watch.md",
"/doc/trace.md",
"/doc/stack.md",
"/doc/tt.md",
],
},
{
text: "其他",
collapsible: false,
children: [
"/doc/profiler.md",
"/doc/cat.md",
"/doc/echo.md",
"/doc/grep.md",
"/doc/base64.md",
"/doc/tee.md",
"/doc/pwd.md",
"/doc/auth.md",
"/doc/options.md",
],
},
{
text: "基础命令",
collapsible: false,
children: [
"/doc/help.md",
"/doc/cls.md",
"/doc/session.md",
"/doc/reset.md",
"/doc/history.md",
"/doc/quit.md",
"/doc/stop.md",
{
text: "keymap",
link: "/doc/keymap.md",
},
],
},
],
},
"/doc/commands.md",
"/doc/web-console.md",
"/doc/tunnel.md",
"/doc/http-api.md",

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -1,3 +1,7 @@
:root {
--sidebar-width: 17rem;
}
.site-name.can-hide {
display: none;
}

View File

@ -0,0 +1,57 @@
<script setup>
import RightMenu from "./RightMenu.vue";
import PageMeta from "@theme/PageMeta.vue";
import PageNav from "@theme/PageNav.vue";
import { usePageData } from "@vuepress/client";
function showRightMenu() {
const pages = usePageData();
return pages.value.headers.length > 1;
}
</script>
<template>
<main class="page">
<slot name="top" />
<div
:class="showRightMenu() && 'right-menu-padding'"
class="theme-default-content"
>
<slot name="content-top" />
<RightMenu v-if="showRightMenu()" />
<Content />
<slot name="content-bottom" />
</div>
<PageMeta :class="showRightMenu() && 'right-menu-padding'" />
<PageNav :class="showRightMenu() && 'right-menu-padding'" />
<slot name="bottom" />
</main>
</template>
<style lang="scss" scoped>
@media (min-width: 1300px) {
.page {
.theme-default-content.right-menu-padding {
padding-right: 240px;
padding-left: 0px;
}
.page-meta.right-menu-padding {
padding-right: 240px;
padding-left: 0px;
}
.page-nav.right-menu-padding {
padding-right: 240px;
padding-left: 0px;
}
}
}
</style>

View File

@ -0,0 +1,181 @@
<!--
Base From Vdoing Theme
SRC: https://github.com/xugaoyi/vuepress-theme-vdoing/blob/master/vdoing/components/RightMenu.vue
-->
<template>
<div class="right-menu-wrapper">
<div class="right-menu-margin">
<div class="right-menu-title">{{ menu }}</div>
<div class="right-menu-content">
<div
:class="[
'right-menu-item',
'level' + item.level,
{ active: item.slug === hashText },
]"
v-for="(item, i) in headers"
:key="i"
>
<a
:href="'#' + item.slug"
v-if="item.title.replace(/[^\x00-\xff]/g, '01').length >= 27"
:title="item.title"
>{{ item.title }}</a
>
<a :href="'#' + item.slug" v-else>{{ item.title }}</a>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { useRoute } from "vue-router";
import { onMounted, watch, ref } from "vue";
import { usePageData } from "@vuepress/client";
import { useThemeLocaleData } from "@vuepress/theme-default/lib/client/composables/useThemeData";
const pages = usePageData();
const theme = useThemeLocaleData();
const menu = ref("");
const headers = ref([]);
let hashText = ref("");
menu.value = theme.value.rightMenuText ?? "Table of Contents";
function getHeadersData() {
headers.value = pages.value.headers;
}
function getHashText() {
hashText.value = decodeURIComponent(window.location.hash.slice(1));
}
onMounted(() => {
getHeadersData();
getHashText();
});
watch(useRoute(), () => {
headers.value = pages.value.headers;
getHashText();
});
</script>
<style lang="scss">
$rightMenuWidth: 230px;
.theme-default-content {
.right-menu-wrapper {
.right-menu-margin {
border-left: 1px solid var(--c-border);
}
}
}
.right-menu-wrapper {
width: $rightMenuWidth;
float: right;
margin-right: -($rightMenuWidth + 20px);
position: sticky;
top: 0;
font-size: 0.8rem;
.right-menu-margin {
margin-top: calc(var(--navbar-height) + 1rem);
border-radius: 3px;
overflow: hidden;
}
.right-menu-title {
padding: 10px 15px 0 15px;
background: var(--mainBg);
font-size: 1rem;
&:after {
content: "";
display: block;
width: 100%;
height: 1px;
background: var(--c-border);
margin-top: 10px;
}
}
.right-menu-content {
max-height: 80vh;
position: relative;
overflow: hidden;
background: var(--mainBg);
padding: 4px 3px 4px 0;
&::-webkit-scrollbar {
width: 3px;
height: 3px;
}
&::-webkit-scrollbar-track-piece {
background: none;
}
&::-webkit-scrollbar-thumb:vertical {
background-color: hsla(0, 0%, 49%, 0.3);
}
&:hover {
overflow-y: auto;
padding-right: 0;
}
.right-menu-item {
padding: 4px 15px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
position: relative;
&.level2 {
font-size: 0.8rem;
}
&.level3 {
padding-left: 27px;
}
&.level4 {
padding-left: 37px;
}
&.level5 {
padding-left: 47px;
}
&.level6 {
padding-left: 57px;
}
&.active {
&:before {
content: "";
position: absolute;
top: 5px;
left: 0;
width: 3px;
height: 14px;
background: var(--c-text-accent);
border-radius: 0 4px 4px 0;
}
a {
color: var(--c-text-accent);
opacity: 1;
}
}
a {
color: var(--textColor);
opacity: 0.75;
display: inline-block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
&:hover {
opacity: 1;
}
}
}
}
}
@media (max-width: 1300px) {
.theme-default-content .right-menu-wrapper {
display: none;
}
}
</style>

View File

@ -13,6 +13,7 @@ exports.localTheme = (options) => {
"components/NavbarDropdown.vue"
),
"@theme/AutoLink.vue": path.resolve(__dirname, "components/AutoLink.vue"),
"@theme/Page.vue": path.resolve(__dirname, "components/Page.vue"),
},
};
};

View File

@ -1,10 +1,10 @@
# 简介
![](/images/arthas.png)
Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用 load、内存、gc、线程的状态信息并能在不修改应用代码的情况下对业务问题进行诊断包括查看方法调用的出入参、异常监测方法执行耗时类加载信息等大大提升线上问题排查效率。
## Arthas阿尔萨斯能为你做什么
![](/images/arthas.png)
### Arthas阿尔萨斯能为你做什么
`Arthas` 是 Alibaba 开源的 Java 诊断工具,深受开发者喜爱。
@ -22,3 +22,7 @@ Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用
`Arthas` 支持 JDK 6+,支持 Linux/Mac/Windows采用命令行交互模式同时提供丰富的 `Tab` 自动补全功能,进一步方便进行问题的定位和诊断。
**如果您在使用 Arthas请让我们知道您的使用对我们非常重要[查看](https://github.com/alibaba/arthas/issues/111)**
### Contributors
[![](https://opencollective.com/arthas/contributors.svg?width=890&button=false)](https://github.com/alibaba/arthas/graphs/contributors)

View File

@ -1,92 +1,5 @@
# 进阶使用
## 基础命令
- [help](help.md)——查看命令帮助信息
- [cat](cat.md)——打印文件内容,和 linux 里的 cat 命令类似
- [echo](echo.md)——打印参数,和 linux 里的 echo 命令类似
- [grep](grep.md)——匹配查找,和 linux 里的 grep 命令类似
- [base64](base64.md)——base64 编码转换,和 linux 里的 base64 命令类似
- [tee](tee.md)——复制标准输入到标准输出和指定的文件,和 linux 里的 tee 命令类似
- [pwd](pwd.md)——返回当前的工作目录,和 linux 命令类似
- [cls](cls.md)——清空当前屏幕区域
- [session](session.md)——查看当前会话的信息
- [reset](reset.md)——重置增强类,将被 Arthas 增强过的类全部还原Arthas 服务端关闭时会重置所有增强过的类
- [version](version.md)——输出当前目标 Java 进程所加载的 Arthas 版本号
- [history](history.md)——打印命令历史
- [quit](quit.md)——退出当前 Arthas 客户端,其他 Arthas 客户端不受影响
- [stop](stop.md)——关闭 Arthas 服务端,所有 Arthas 客户端全部退出
- [keymap](keymap.md)——Arthas 快捷键列表及自定义快捷键
## jvm 相关
- [dashboard](dashboard.md)——当前系统的实时数据面板
- [thread](thread.md)——查看当前 JVM 的线程堆栈信息
- [jvm](jvm.md)——查看当前 JVM 的信息
- [sysprop](sysprop.md)——查看和修改 JVM 的系统属性
- [sysenv](sysenv.md)——查看 JVM 的环境变量
- [vmoption](vmoption.md)——查看和修改 JVM 里诊断相关的 option
- [perfcounter](perfcounter.md)——查看当前 JVM 的 Perf Counter 信息
- [logger](logger.md)——查看和修改 logger
- [getstatic](getstatic.md)——查看类的静态属性
- [ognl](ognl.md)——执行 ognl 表达式
- [mbean](mbean.md)——查看 Mbean 的信息
- [heapdump](heapdump.md)——dump java heap, 类似 jmap 命令的 heap dump 功能
- [vmtool](vmtool.md)——从 jvm 里查询对象,执行 forceGc
## class/classloader 相关
- [sc](sc.md)——查看 JVM 已加载的类信息
- [sm](sm.md)——查看已加载类的方法信息
- [jad](jad.md)——反编译指定已加载类的源码
- [mc](mc.md)——内存编译器,内存编译`.java`文件为`.class`文件
- [retransform](retransform.md)——加载外部的`.class`文件retransform 到 JVM 里
- [redefine](redefine.md)——加载外部的`.class`文件redefine 到 JVM 里
- [dump](dump.md)——dump 已加载类的 byte code 到特定目录
- [classloader](classloader.md)——查看 classloader 的继承树urls类加载信息使用 classloader 去 getResource
## monitor/watch/trace 相关
::: warning
请注意,这些命令,都通过字节码增强技术来实现的,会在指定类的方法中插入一些切面来实现数据统计和观测,因此在线上、预发使用时,请尽量明确需要观测的类、方法以及条件,诊断结束要执行 `stop` 或将增强过的类执行 `reset` 命令。
:::
- [monitor](monitor.md)——方法执行监控
- [watch](watch.md)——方法执行数据观测
- [trace](trace.md)——方法内部调用路径,并输出方法路径上的每个节点上耗时
- [stack](stack.md)——输出当前方法被调用的调用路径
- [tt](tt.md)——方法执行数据的时空隧道,记录下指定方法每次调用的入参和返回信息,并能对这些不同的时间下调用进行观测
## profiler/火焰图
- [profiler](profiler.md)--使用[async-profiler](https://github.com/jvm-profiling-tools/async-profiler)对应用采样,生成火焰图
## 鉴权
- [auth](auth.md)——鉴权
## options
- [options](options.md)——查看或设置 Arthas 全局开关
## 管道
Arthas 支持使用管道对上述命令的结果进行进一步的处理,如`sm java.lang.String * | grep 'index'`
- [grep](grep.md)——搜索满足条件的结果
- plaintext——将命令的结果去除 ANSI 颜色
- wc——按行统计输出结果
## 后台异步任务
当线上出现偶发的问题,比如需要 watch 某个条件,而这个条件一天可能才会出现一次时,异步后台任务就派上用场了,详情请参考[这里](async.md)
- 使用 `>` 将结果重写向到日志文件,使用 `&` 指定命令是后台运行session 断开不影响任务执行(生命周期默认为 1 天)
- jobs——列出所有 job
- kill——强制终止任务
- fg——将暂停的任务拉到前台执行
- bg——将暂停的任务放到后台执行
## Web Console
通过 websocket 连接 Arthas。
@ -155,3 +68,10 @@ pid 58883
在 tunnel server 里有一个示例的回报代码,用户可以自己在服务器上实现。
[StatController.java](https://github.com/alibaba/arthas/blob/master/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/web/StatController.java)
## 其他特性
- [异步命令支持](async.md)
- [执行结果存日志](save-log.md)
- [批处理的支持](batch-support.md)
- [ognl 表达式的用法说明](https://github.com/alibaba/arthas/issues/11)

View File

@ -1,50 +1,89 @@
# 命令列表
- [dashboard](dashboard.md)
- [thread](thread.md)
- [jvm](jvm.md)
- [memory](memory.md)
- [sysprop](sysprop.md)
- [sysenv](sysenv.md)
- [vmoption](vmoption.md)
- [perfcounter](perfcounter.md)
- [logger](logger.md)
- [mbean](mbean.md)
- [getstatic](getstatic.md)
- [ognl](ognl.md)
- [sc](sc.md)
- [sm](sm.md)
- [dump](dump.md)
- [heapdump](heapdump.md)
- [vmtool](vmtool.md)
- [jad](jad.md)
- [classloader](classloader.md)
- [mc](mc.md)
- [retransform](retransform.md)
- [redefine](redefine.md)
- [monitor](monitor.md)
- [watch](watch.md)
- [trace](trace.md)
- [stack](stack.md)
- [tt](tt.md)
- [profiler](profiler.md)
- [cat](cat.md)
- [echo](echo.md)
- [grep](grep.md)
- [base64](base64.md)
- [tee](tee.md)
- [pwd](pwd.md)
- [auth](auth.md)
- [options](options.md)
## jvm 相关
### Arthas 基础命令
- [dashboard](dashboard.md) - 当前系统的实时数据面板
- [getstatic](getstatic.md) - 查看类的静态属性
- [heapdump](heapdump.md) - dump java heap, 类似 jmap 命令的 heap dump 功能
- [jvm](jvm.md) - 查看当前 JVM 的信息
- [logger](logger.md) - 查看和修改 logger
- [mbean](mbean.md) - 查看 Mbean 的信息
- [memory](memory.md) - 查看 JVM 的内存信息
- [ognl](ognl.md) - 执行 ognl 表达式
- [perfcounter](perfcounter.md) - 查看当前 JVM 的 Perf Counter 信息
- [sysenv](sysenv.md) - 查看 JVM 的环境变量
- [sysprop](sysprop.md) - 查看和修改 JVM 的系统属性
- [thread](thread.md) - 查看当前 JVM 的线程堆栈信息
- [vmoption](vmoption.md) - 查看和修改 JVM 里诊断相关的 option
- [vmtool](vmtool.md) - 从 jvm 里查询对象,执行 forceGc
- [help](help.md)
- [cls](cls.md)
- [session](session.md)
- [reset](reset.md)
- [version](version.md)
- [history](history.md)
- [quit](quit.md)
- [stop](stop.md)
- [keymap](keymap.md)
## class/classloader 相关
- [classloader](classloader.md) - 查看 classloader 的继承树urls类加载信息使用 classloader 去 getResource
- [dump](dump.md) - dump 已加载类的 byte code 到特定目录
- [jad](jad.md) - 反编译指定已加载类的源码
- [mc](mc.md) - 内存编译器,内存编译`.java`文件为`.class`文件
- [redefine](redefine.md) - 加载外部的`.class`文件redefine 到 JVM 里
- [retransform](retransform.md) - 加载外部的`.class`文件retransform 到 JVM 里
- [sc](sc.md) - 查看 JVM 已加载的类信息
- [sm](sm.md) - 查看已加载类的方法信息
## monitor/watch/trace 相关
::: warning
请注意,这些命令,都通过字节码增强技术来实现的,会在指定类的方法中插入一些切面来实现数据统计和观测,因此在线上、预发使用时,请尽量明确需要观测的类、方法以及条件,诊断结束要执行 `stop` 或将增强过的类执行 `reset` 命令。
:::
- [monitor](monitor.md) - 方法执行监控
- [stack](stack.md) - 输出当前方法被调用的调用路径
- [trace](trace.md) - 方法内部调用路径,并输出方法路径上的每个节点上耗时
- [tt](tt.md) - 方法执行数据的时空隧道,记录下指定方法每次调用的入参和返回信息,并能对这些不同的时间下调用进行观测
- [watch](watch.md) - 方法执行数据观测
## profiler/火焰图
- [profiler](profiler.md) - 使用[async-profiler](https://github.com/jvm-profiling-tools/async-profiler)对应用采样,生成火焰图
## 鉴权
- [auth](auth.md) - 鉴权
## options
- [options](options.md) - 查看或设置 Arthas 全局开关
## 管道
Arthas 支持使用管道对上述命令的结果进行进一步的处理,如`sm java.lang.String * | grep 'index'`
- [grep](grep.md) - 搜索满足条件的结果
- plaintext - 将命令的结果去除 ANSI 颜色
- wc - 按行统计输出结果
## 后台异步任务
当线上出现偶发的问题,比如需要 watch 某个条件,而这个条件一天可能才会出现一次时,异步后台任务就派上用场了,详情请参考[这里](async.md)
- 使用 `>` 将结果重写向到日志文件,使用 `&` 指定命令是后台运行session 断开不影响任务执行(生命周期默认为 1 天)
- jobs - 列出所有 job
- kill - 强制终止任务
- fg - 将暂停的任务拉到前台执行
- bg - 将暂停的任务放到后台执行
## 基础命令
- [base64](base64.md) - base64 编码转换,和 linux 里的 base64 命令类似
- [cat](cat.md) - 打印文件内容,和 linux 里的 cat 命令类似
- [cls](cls.md) - 清空当前屏幕区域
- [echo](echo.md) - 打印参数,和 linux 里的 echo 命令类似
- [grep](grep.md) - 匹配查找,和 linux 里的 grep 命令类似
- [help](help.md) - 查看命令帮助信息
- [history](history.md) - 打印命令历史
- [keymap](keymap.md) - Arthas 快捷键列表及自定义快捷键
- [pwd](pwd.md) - 返回当前的工作目录,和 linux 命令类似
- [quit](quit.md) - 退出当前 Arthas 客户端,其他 Arthas 客户端不受影响
- [reset](reset.md) - 重置增强类,将被 Arthas 增强过的类全部还原Arthas 服务端关闭时会重置所有增强过的类
- [session](session.md) - 查看当前会话的信息
- [stop](stop.md) - 关闭 Arthas 服务端,所有 Arthas 客户端全部退出
- [tee](tee.md) - 复制标准输入到标准输出和指定的文件,和 linux 里的 tee 命令类似
- [version](version.md) - 输出当前目标 Java 进程所加载的 Arthas 版本号

View File

@ -1,6 +1,6 @@
# 联系我们
## 招聘
### 招聘
- [期待你的加入](https://mp.weixin.qq.com/s/XQv8GnqGT3pzceVwzeiy-A)

View File

@ -4,15 +4,15 @@
不在本列表里的问题,请到 issue 里搜索。 [https://github.com/alibaba/arthas/issues](https://github.com/alibaba/arthas/issues)
:::
##### 日志文件在哪里?
### 日志文件在哪里?
日志文件路径: `~/logs/arthas/arthas.log`
##### Arthas attach 之后对原进程性能有多大的影响
### Arthas attach 之后对原进程性能有多大的影响
[https://github.com/alibaba/arthas/issues/44](https://github.com/alibaba/arthas/issues/44)
##### target process not responding or HotSpot VM not loaded
### target process not responding or HotSpot VM not loaded
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
@ -21,7 +21,7 @@ com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: ta
3. 尝试按[quick-start](quick-start.md)里的方式 attach math-game。
4. 更多情况参考: [https://github.com/alibaba/arthas/issues/347](https://github.com/alibaba/arthas/issues/347)
##### trace/watch 等命令能否增强 jdk 里的类?
### trace/watch 等命令能否增强 jdk 里的类?
默认情况下会过滤掉`java.`开头的类和被`BootStrap ClassLoader`加载的类。可以通过参数开启。
@ -35,7 +35,7 @@ options unsafe true
通过 java.lang.instrument.Instrumentation#appendToBootstrapClassLoaderSearch append 到`Bootstrap ClassLoader`的 jar 包需要开启 unsafe。
:::
##### 怎么以`json`格式查看结果
### 怎么以`json`格式查看结果
```bash
options json-format true
@ -43,16 +43,16 @@ options json-format true
更多参考 [options](options.md)
##### Arthas 能否跟踪 native 函数
### Arthas 能否跟踪 native 函数
不能。
##### 能不能查看内存里某个变量的值
### 能不能查看内存里某个变量的值
1. 可以使用[`vmtool`](vmtool.md)命令。
2. 可以用一些技巧,用[`tt`](tt.md)命令拦截到对象,或者从静态函数里取到对象。
##### 方法同名过滤
### 方法同名过滤
同名方法过滤可以通过匹配表达式,可以使用[表达式核心变量](advice-class.md)中所有变量作为已知条件,可以通过判断参数个数`params.length ==1`, 参数类型`params[0] instanceof java.lang.Integer`、返回值类型 `returnObj instanceof java.util.List` 等等一种或者多种组合进行过滤。
@ -64,13 +64,13 @@ options json-format true
watch demo.MathGame primeFactors '{params,returnObj,throwExp}' 'params.length >0 && returnObj instanceof java.util.List' -v
```
##### 怎么 watch、trace 构造函数
### 怎么 watch、trace 构造函数
```bash
watch demo.MathGame <init> '{params,returnObj,throwExp}' -v
```
##### 怎样 watch、trace 内部类?
### 怎样 watch、trace 内部类?
在 JVM 规范里内部类的格式是`OuterClass$InnerClass`。
@ -78,7 +78,7 @@ watch demo.MathGame <init> '{params,returnObj,throwExp}' -v
watch OuterClass$InnerClass
```
##### 输入中文/Unicode 字符
### 输入中文/Unicode 字符
把中文/Unicode 字符转为`\u`表示方法:
@ -86,7 +86,7 @@ watch OuterClass$InnerClass
ognl '@java.lang.System@out.println("Hello \u4e2d\u6587")'
```
##### java.lang.ClassFormatError: null、skywalking arthas 兼容使用
### java.lang.ClassFormatError: null、skywalking arthas 兼容使用
当出现这个错误日志`java.lang.ClassFormatError: null`,通常情况下都是被其他字节码工具修改过与 arthas 修改字节码不兼容。
@ -96,15 +96,15 @@ ognl '@java.lang.System@out.println("Hello \u4e2d\u6587")'
参考: [https://github.com/alibaba/arthas/issues/2165](https://github.com/alibaba/arthas/issues/2165)
##### Arthas 能不能离线使用
### Arthas 能不能离线使用
可以。下载全量包解压即可,参考: [下载](download.md)。
##### Attach docker/k8s 里的 pid 为 1 的进程失败
### Attach docker/k8s 里的 pid 为 1 的进程失败
参考: [https://github.com/alibaba/arthas/issues/362#issuecomment-448185416](https://github.com/alibaba/arthas/issues/362#issuecomment-448185416)
##### 为什么下载了新版本的 Arthas连接的却是旧版本
### 为什么下载了新版本的 Arthas连接的却是旧版本
比如启动的 `as.sh/arthas-boot.jar` 版本是 3.5._ 的,但是连接上之后,打印的 arthas 版本是 3.4._ 的。

View File

@ -32,3 +32,7 @@ Arthas is built to solve these issues. A developer can troubleshoot production i
- Supports Linux/Mac/Windows
**If you are using Arthas, please let us know. Your feedback is very important to us: [View](https://github.com/alibaba/arthas/issues/111)**
### Contributors
[![](https://opencollective.com/arthas/contributors.svg?width=890&button=false)](https://github.com/alibaba/arthas/graphs/contributors)

View File

@ -1,92 +1,5 @@
# Advanced Usage
## Basic
- [help](help.md) - display Arthas help
- [cls](cls.md) - clear the screen
- [cat](cat.md) - Concatenate and print files
- [echo](echo.md) - write arguments to the standard output
- [grep](grep.md) - Pattern searcher
- [base64](base64.md) - Encode and decode using Base64 representation.
- [tee](tee.md) - Copies standard input to standard output, making a copy in zero or more files.
- [pwd](pwd.md) - Return working directory name
- [session](session.md) - display current session information
- [reset](reset.md) - reset all the enhanced classes. All enhanced classes will also be reset when Arthas server is closed by `stop`
- [version](version.md) - print the version for the Arthas attached to the current Java process
- [history](history.md) - view command history
- [quit/exit](quit.md) - exit the current Arthas session, without effecting other sessions
- [stop](stop.md) - terminate the Arthas server, all Arthas sessions will be destroyed
- [keymap](keymap.md) - keymap for Arthas keyboard shortcut
## JVM
- [dashboard](dashboard.md) - dashboard for the system's real-time data
- [thread](thread.md) - show java thread information
- [jvm](jvm.md) - show JVM information
- [sysprop](sysprop.md) - view/modify system properties
- [sysenv](sysenv.md) — view system environment variables
- [vmoption](vmoption.md) - view/modify the vm diagnostic options.
- [perfcounter](perfcounter.md) - show JVM Perf Counter information
- [logger](logger.md) - print the logger information, update the logger level
- [getstatic](getstatic.md) - examine class's static properties
- [ognl](ognl.md) - execute ognl expression
- [mbean](mbean.md) - show Mbean information
- [heapdump](heapdump.md) - dump java heap in hprof binary format, like `jmap`
- [vmtool](vmtool.md) - jvm tool, getInstances in jvm, forceGc
## class/classloader
- [sc](sc.md) - check the info for the classes loaded by JVM
- [sm](sm.md) - check methods info for the loaded classes
- [jad](jad.md) - decompile the specified loaded classes
- [mc](mc.md) - Memory compiler, compiles `.java` files into `.class` files in memory
- [retransform](retransform.md) - load external `*.class` files and retransform it into JVM
- [redefine](redefine.md) - load external `*.class` files and re-define it into JVM
- [dump](dump.md) - dump the loaded classes in byte code to the specified location
- [classloader](classloader.md) - check the inheritance structure, urls, class loading info for the specified class; using classloader to get the url of the resource e.g. `java/lang/String.class`
## monitor/watch/trace - related
::: warning
**Attention**: commands here are taking advantage of byte-code-injection, which means we are injecting some [aspects](https://en.wikipedia.org/wiki/Aspect-oriented_programming) into the current classes for monitoring and statistics purpose. Therefore, when using it for online troubleshooting in your production environment, you'd better **explicitly specify** classes/methods/criteria, and remember to remove the injected code by `stop` or `reset`.
:::
- [monitor](monitor.md) - monitor method execution statistics
- [watch](watch.md) - display the input/output parameter, return object, and thrown exception of specified method invocation
- [trace](trace.md) - trace the execution time of specified method invocation
- [stack](stack.md) - display the stack trace for the specified class and method
- [tt](tt.md) - time tunnel, record the arguments and returned value for the methods and replay
## authentication
- [auth](auth.md) - authentication
## options
- [options](options.md) - check/set Arthas global options
## profiler/flame graph
- [profiler](profiler.md) - use [async-profiler](https://github.com/jvm-profiling-tools/async-profiler) to generate flame graph
## pipe
Arthas provides `pipe` to process the result returned from commands further, e.g. `sm java.lang.String * | grep 'index'`. Commands supported in `pipe`:
- grep - filter the result with the given keyword
- plaintext - remove the ANSI color
- wc - count lines
## async jobs
[async](async.md) can be handy when a problem is hardly to reproduce in the production environment, e.g. one `watch` condition may happen only once in one single day.
- job control - use `>` to redirect result into the log file, use `&` to put the job to the background. Job keeps running even if the session is disconnected (the session lifecycle is 1 day by default)
- jobs - list all jobs
- kill - forcibly terminate the job
- fg - bring the suspend job to the foreground
- bg - put the job to run in the background
## Web Console
Arthas supports living inside a browser. The communication between arthas and browser is via websocket.
@ -155,3 +68,10 @@ At startup, use the `stat-url` option, such as: `./as.sh --stat-url 'http://192.
There is a sample data report in the tunnel server that users can implement on their own.
[StatController.java](https://github.com/alibaba/arthas/blob/master/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/web/StatController.java)
## Other features
- [Async support](async.md)
- [log the output](logger.md)
- [batch](batch-support.md)
- [how to use ognl](https://github.com/alibaba/arthas/issues/11)

View File

@ -1,56 +1,88 @@
# All Commands
- [dashboard](dashboard.md)
- [thread](thread.md)
- [jvm](jvm.md)
- [memory](memory.md)
- [sysprop](sysprop.md)
- [sysenv](sysenv.md)
- [vmoption](vmoption.md)
- [perfcounter](perfcounter.md)
- [logger](logger.md)
- [mbean](mbean.md)
- [getstatic](getstatic.md)
## jvm - related
- [ognl](ognl.md)
- [dashboard](dashboard.md) - dashboard for the system's real-time data
- [getstatic](getstatic.md) - examine class's static properties
- [heapdump](heapdump.md) - dump java heap in hprof binary format, like `jmap`
- [jvm](jvm.md) - show JVM information
- [logger](logger.md) - print the logger information, update the logger level
- [mbean](mbean.md) - show Mbean information
- [ognl](ognl.md) - execute ognl expression
- [perfcounter](perfcounter.md) - show JVM Perf Counter information
- [sysenv](sysenv.md) — view system environment variables
- [sysprop](sysprop.md) - view/modify system properties
- [thread](thread.md) - show java thread information
- [vmoption](vmoption.md) - view/modify the vm diagnostic options.
- [vmtool](vmtool.md) - jvm tool, getInstances in jvm, forceGc
- [sc](sc.md)
- [sm](sm.md)
- [dump](dump.md)
- [heapdump](heapdump.md)
- [vmtool](vmtool.md)
## class/classloader - related
- [jad](jad.md)
- [classloader](classloader.md)
- [mc](mc.md)
- [retransform](retransform.md)
- [redefine](redefine.md)
- [classloader](classloader.md) - check the inheritance structure, urls, class loading info for the specified class; using classloader to get the url of the resource e.g. `java/lang/String.class`
- [dump](dump.md) - dump the loaded classes in byte code to the specified location
- [jad](jad.md) - decompile the specified loaded classes
- [mc](mc.md) - Memory compiler, compiles `.java` files into `.class` files in memory
- [redefine](redefine.md) - load external `*.class` files and re-define it into JVM
- [retransform](retransform.md) - load external `*.class` files and retransform it into JVM
- [sc](sc.md) - check the info for the classes loaded by JVM
- [sm](sm.md) - check methods info for the loaded classes
- [monitor](monitor.md)
- [watch](watch.md)
- [trace](trace.md)
- [stack](stack.md)
- [tt](tt.md)
## monitor/watch/trace - related
- [profiler](profiler.md)
::: warning
**Attention**: commands here are taking advantage of byte-code-injection, which means we are injecting some [aspects](https://en.wikipedia.org/wiki/Aspect-oriented_programming) into the current classes for monitoring and statistics purpose. Therefore, when using it for online troubleshooting in your production environment, you'd better **explicitly specify** classes/methods/criteria, and remember to remove the injected code by `stop` or `reset`.
:::
- [cat](cat.md)
- [echo](echo.md)
- [grep](grep.md)
- [base64](base64.md)
- [tee](tee.md)
- [pwd](pwd.md)
- [auth](auth.md)
- [options](options.md)
- [monitor](monitor.md) - monitor method execution statistics
- [stack](stack.md) - display the stack trace for the specified class and method
- [trace](trace.md) - trace the execution time of specified method invocation
- [tt](tt.md) - time tunnel, record the arguments and returned value for the methods and replay
- [watch](watch.md) - display the input/output parameter, return object, and thrown exception of specified method invocation
### Basic Arthas Commands
## authentication
- [help](help.md) - examines help information
- [cls](cls.md) - clears out the screen
- [session](session.md) - examines the current session
- [reset](reset.md) - resets enhanced classes. All enhanced classes will be reset to their original states. When Arthas server closes, all these enhanced classes will be reset too
- [version](version.md) - prints out Arthas's version
- [auth](auth.md) - authentication
## options
- [options](options.md) - check/set Arthas global options
## profiler/flame graph
- [profiler](profiler.md) - use [async-profiler](https://github.com/jvm-profiling-tools/async-profiler) to generate flame graph
## pipe
Arthas provides `pipe` to process the result returned from commands further, e.g. `sm java.lang.String * | grep 'index'`. Commands supported in `pipe`:
- grep - filter the result with the given keyword
- plaintext - remove the ANSI color
- wc - count lines
## async jobs
[async](async.md) can be handy when a problem is hardly to reproduce in the production environment, e.g. one `watch` condition may happen only once in one single day.
- job control - use `>` to redirect result into the log file, use `&` to put the job to the background. Job keeps running even if the session is disconnected (the session lifecycle is 1 day by default)
- jobs - list all jobs
- kill - forcibly terminate the job
- fg - bring the suspend job to the foreground
- bg - put the job to run in the background
## Basic Arthas Commands
- [base64](base64.md) - Encode and decode using Base64 representation.
- [cat](cat.md) - Concatenate and print files
- [cls](cls.md) - clear the screen
- [echo](echo.md) - write arguments to the standard output
- [grep](grep.md) - Pattern searcher
- [help](help.md) - display Arthas help
- [history](history.md) - view command history
- [quit](quit.md) - exit the current Arthas client without affecting other clients
- [stop](stop.md) - terminates the Arthas server, all the Arthas clients connecting to this server will be disconnected
- [keymap](keymap.md) - lists all Arthas keyboard shortcuts and shortcut customizations.
- [keymap](keymap.md) - keymap for Arthas keyboard shortcut
- [pwd](pwd.md) - Return working directory name
- [quit/exit](quit.md) - exit the current Arthas session, without effecting other sessions
- [reset](reset.md) - reset all the enhanced classes. All enhanced classes will also be reset when Arthas server is closed by `stop`
- [session](session.md) - display current session information
- [stop](stop.md) - terminate the Arthas server, all Arthas sessions will be destroyed
- [tee](tee.md) - Copies standard input to standard output, making a copy in zero or more files.
- [version](version.md) - print the version for the Arthas attached to the current Java process

View File

@ -4,15 +4,15 @@
For questions that are not in this list, please search in issues. [https://github.com/alibaba/arthas/issues](https://github.com/alibaba/arthas/issues)
:::
##### Where is the log file?
### Where is the log file?
Log file path: `~/logs/arthas/arthas.log`
##### How much impact does Arthas attach have on the performance of the original process?
### How much impact does Arthas attach have on the performance of the original process?
[https://github.com/alibaba/arthas/issues/44](https://github.com/alibaba/arthas/issues/44)
##### target process not responding or HotSpot VM not loaded
### target process not responding or HotSpot VM not loaded
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
@ -21,7 +21,7 @@ com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: ta
3. Try to attach math-game in [quick-start](quick-start.md).
4. For more information: [https://github.com/alibaba/arthas/issues/347](https://github.com/alibaba/arthas/issues/347)
##### Can commands such as trace/watch enhance the classes in jdk?
### Can commands such as trace/watch enhance the classes in jdk?
By default, classes beginning with `java.` or the classes loaded by the `Bootstrap ClassLoader` are filtered out, but they can be turned on:
@ -35,7 +35,7 @@ See more at [options](options.md)
To support the jars appended by java.lang.instrument.Instrumentation#appendToBootstrapClassLoaderSearch need to enable unsafe.
:::
##### How to view the result in `json` format
### How to view the result in `json` format
```bash
options json-format true
@ -43,16 +43,16 @@ options json-format true
See more at [options](options.md)
##### Can arthas trace native methods
### Can arthas trace native methods
No.
##### Can arthas view the value of a variable in memory?
### Can arthas view the value of a variable in memory?
1. You can use [`vmtool`](vmtool.md) command.
2. You can use some tricks to intercept the object with the [`tt`](tt.md) command, or fetch it from a static method.
##### How to filter method with the same name?
### How to filter method with the same name?
You can used all variables in [fundamental fields in expressions](advice-class.md) for the condition express to filter method with the same name, you can use the number of parameters `params.length ==1`,parameter type `params[0] instanceof java.lang.Integer`,return value type `returnObj instanceof java.util.List` and so on in one or more combinations as condition express.
@ -64,13 +64,13 @@ example [math-game](quick-start.md)
watch demo.MathGame primeFactors '{params,returnObj,throwExp}' 'params.length >0 && returnObj instanceof java.util.List' -v
```
##### How to watch or trace constructor?
### How to watch or trace constructor?
```bash
watch demo.MathGame <init> '{params,returnObj,throwExp}' -v
```
##### How to watch or trace inner classes?
### How to watch or trace inner classes?
In the JVM specification the name of inner classes is `OuterClass$InnerClass`.
@ -78,7 +78,7 @@ In the JVM specification the name of inner classes is `OuterClass$InnerClass`.
watch OuterClass$InnerClass
```
##### Enter Unicode characters
### Enter Unicode characters
Convert Unicode characters to `\u` representation:
@ -86,7 +86,7 @@ Convert Unicode characters to `\u` representation:
ognl '@java.lang.System@out.println("Hello \u4e2d\u6587")'
```
##### java.lang.ClassFormatError: null, skywalking arthas compatible use
### java.lang.ClassFormatError: null, skywalking arthas compatible use
When error log appear `java.lang.ClassFormatError: null`, it is usually modified by other bytecode tools that are not compatible with arthas modified bytecode.
@ -96,15 +96,15 @@ For example: use skywalking V8.1.0 below [cannot trace, watch classes enhanced b
Reference: [https://github.com/alibaba/arthas/issues/2165](https://github.com/alibaba/arthas/issues/2165)
##### Can I use arthas offline?
### Can I use arthas offline?
Yes. Just download the full size package and unzip it, refer to: [Download](download.md).
##### Attach the process with pid 1 in docker/k8s failed
### Attach the process with pid 1 in docker/k8s failed
Reference: [https://github.com/alibaba/arthas/issues/362#issuecomment-448185416](https://github.com/alibaba/arthas/issues/362#issuecomment-448185416)
##### Why is the new version of Arthas downloaded, but the old version is connected?
### Why is the new version of Arthas downloaded, but the old version is connected?
For example, the started version of `as.sh/arthas-boot.jar` is 3.5._, but after connecting, the printed arthas version is 3.4._.

6715
site/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@vuepress/plugin-active-header-links": "^2.0.0-beta.49",
"@vuepress/plugin-search": "^2.0.0-beta.48",
"prettier": "2.7.1",
"vuepress": "^2.0.0-beta.48",