Skip to content

Commit

Permalink
cmd/debug:rename doctor to debug (#2815)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored Sep 27, 2022
1 parent 7c95af7 commit 2c4bfd8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
26 changes: 13 additions & 13 deletions cmd/doctor.go → cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,36 @@ import (
"github.com/urfave/cli/v2"
)

var defaultOutDir = filepath.Join(".", "doctor")
var defaultOutDir = filepath.Join(".", "debug")

func cmdDoctor() *cli.Command {
return &cli.Command{
Name: "doctor",
Action: doctor,
Name: "debug",
Action: debug,
Category: "INSPECTOR",
ArgsUsage: "MOUNTPOINT",
Usage: "Collect and display system static and runtime information",
Description: `
It collects and displays information from multiple dimensions such as the running environment and system logs, etc.
Examples:
$ juicefs doctor /mnt/jfs
$ juicefs debug /mnt/jfs
# Result will be output to /var/log/
$ juicefs doctor --out-dir=/var/log /mnt/jfs
$ juicefs debug --out-dir=/var/log /mnt/jfs
# Get the last up to 1000 log entries
$ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 /mnt/jfs
$ juicefs debug --out-dir=/var/log --collect-log --limit=1000 /mnt/jfs
# Get pprof information
$ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /mnt/jfs
$ juicefs debug --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /mnt/jfs
`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "out-dir",
Value: defaultOutDir,
Usage: "the output directory of the result file",
},
&cli.Uint64Flag{
Name: "stats-sec",
Value: 5,
Usage: "stats sampling duration",
},
&cli.BoolFlag{
Name: "collect-log",
Usage: "enable log collection",
Expand All @@ -86,6 +81,11 @@ $ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /
Name: "collect-pprof",
Usage: "enable pprof collection",
},
&cli.Uint64Flag{
Name: "stats-sec",
Value: 5,
Usage: "stats sampling duration",
},
&cli.Uint64Flag{
Name: "trace-sec",
Value: 5,
Expand Down Expand Up @@ -397,7 +397,7 @@ func geneZipFile(srcPath, destPath string) error {
return nil
}

func doctor(ctx *cli.Context) error {
func debug(ctx *cli.Context) error {
setup(ctx, 1)
mp := ctx.Args().First()
inode, err := utils.GetFileInode(mp)
Expand Down
14 changes: 7 additions & 7 deletions cmd/doctor_test.go → cmd/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ import (
. "github.com/smartystreets/goconvey/convey"
)

func TestDoctor(t *testing.T) {
func TestDebug(t *testing.T) {
mountTemp(t, nil, nil, nil)
defer umountTemp(t)
Convey("TestDoctor", t, func() {
Convey("TestDebug", t, func() {
Convey("Mount point does not exist", func() {
mp := "/jfs/test/mp"
So(Main([]string{"", "doctor", mp}), ShouldNotBeNil)
So(Main([]string{"", "debug", mp}), ShouldNotBeNil)
})

Convey("Directory is not a mount point", func() {
mp := "./"
So(Main([]string{"", "doctor", mp}), ShouldNotBeNil)
So(Main([]string{"", "debug", mp}), ShouldNotBeNil)
})

})

Convey("TestDoctor_OutDir", t, func() {
Convey("TestDebug_OutDir", t, func() {
Convey("Specify a file as out dir", func() {
So(Main([]string{"", "doctor", "--out-dir", "./doctor_test.go", testMountPoint}), ShouldNotBeNil)
So(Main([]string{"", "debug", "--out-dir", "./debug_test.go", testMountPoint}), ShouldNotBeNil)
})
})

Convey("TestDoctor_LogArg", t, func() {
Convey("TestDebug_LogArg", t, func() {
cases := []struct {
arg string
val string
Expand Down
6 changes: 3 additions & 3 deletions docs/en/administration/fault_diagnosis_and_analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ By default, pprof listens on port numbers ranging from 6060 to 6099. That's why
- Memory allocation statistics: `http://localhost:<port>/debug/pprof/heap`
-
:::tip
You can also use the doctor command to automatically collect these runtime information and save it locally. By default, it is saved to the doctor directory under the current directory, for example:
You can also use the debug command to automatically collect these runtime information and save it locally. By default, it is saved to the debug directory under the current directory, for example:
```bash
juicefs doctor --collect-pprof /mnt/jfs
juicefs debug --collect-pprof /mnt/jfs
```
For more information about the doctor command, see [command reference](https://juicefs.com/docs/community/command_reference#juicefs-doctor)
For more information about the debug command, see [command reference](https://juicefs.com/docs/community/command_reference#juicefs-debug)
:::
To make it easier to analyze this runtime information, you can save it locally, e.g.:
Expand Down
16 changes: 8 additions & 8 deletions docs/en/reference/command_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ COMMANDS:
stats Show real time performance statistics of JuiceFS
profile Show profiling of operations completed in JuiceFS
info Show internal information of a path or inode
doctor Show information from multiple dimensions such as the operating environment and system logs
debug Show information from multiple dimensions such as the operating environment and system logs
SERVICE:
mount Mount a volume
umount Unmount a volume
Expand Down Expand Up @@ -1197,7 +1197,7 @@ skip sanity check and force destroy the volume (default: false)
$ juicefs destroy redis://localhost e94d66a8-2339-4abd-b8d8-6812df737892
```

### juicefs doctor
### juicefs debug

#### Description

Expand All @@ -1206,13 +1206,13 @@ It collects and displays information from multiple dimensions such as the operat
#### Synopsis

```
juicefs doctor [command options] MOUNTPOINT
juicefs debug [command options] MOUNTPOINT
```

#### Options

`--out-dir value`<br />
The output directory of the results, automatically created if the directory does not exist (default: ./doctor/)
The output directory of the results, automatically created if the directory does not exist (default: ./debug/)

`--stats-sec value`<br />
The number of seconds to sample .stats file (default: 5)
Expand All @@ -1236,14 +1236,14 @@ The number of seconds to sample profile metrics (default: 30)

```bash
# Collect and display information about the mount point /mnt/jfs
$ juicefs doctor /mnt/jfs
$ juicefs debug /mnt/jfs

# Specify the output directory as /var/log
$ juicefs doctor --out-dir=/var/log /mnt/jfs
$ juicefs debug --out-dir=/var/log /mnt/jfs

# Enable log collection and get the last up to 1000 log entries
$ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 /mnt/jfs
$ juicefs debug --out-dir=/var/log --collect-log --limit=1000 /mnt/jfs

# Enable pprof metrics collection
$ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /mnt/jfs
$ juicefs debug --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /mnt/jfs
```
6 changes: 3 additions & 3 deletions docs/zh_cn/administration/fault_diagnosis_and_analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ curl 'http://localhost:<port>/debug/pprof/heap' > juicefs.heap.pb.gz
```

:::tip 建议
你也可以使用doctor命令自动收集这些运行时信息并保存到本地,默认保存到当前目录下的doctor目录中,例如:
你也可以使用 juicefs debug 命令自动收集这些运行时信息并保存到本地,默认保存到当前目录下的 debug 目录中,例如:
```bash
juicefs doctor --collect-pprof /mnt/jfs
juicefs debug --collect-pprof /mnt/jfs
```
关于doctor命令的更多信息,请查看[命令参考](https://juicefs.com/docs/zh/community/command_reference#juicefs-doctor)
关于 juicefs debug 命令的更多信息,请查看[命令参考](https://juicefs.com/docs/zh/community/command_reference#juicefs-debug)
:::

如果你安装了 `go` 命令,那么可以通过 `go tool pprof` 命令直接分析,例如分析 CPU 性能统计:
Expand Down
16 changes: 8 additions & 8 deletions docs/zh_cn/reference/command_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ COMMANDS:
stats Show real time performance statistics of JuiceFS
profile Show profiling of operations completed in JuiceFS
info Show internal information of a path or inode
doctor Show information from multiple dimensions such as the operating environment and system logs
debug Show information from multiple dimensions such as the operating environment and system logs
SERVICE:
mount Mount a volume
umount Unmount a volume
Expand Down Expand Up @@ -1200,7 +1200,7 @@ juicefs destroy [command options] META-URL UUID
$ juicefs destroy redis://localhost e94d66a8-2339-4abd-b8d8-6812df737892
```

### juicefs doctor
### juicefs debug

#### 描述

Expand All @@ -1209,13 +1209,13 @@ $ juicefs destroy redis://localhost e94d66a8-2339-4abd-b8d8-6812df737892
#### 使用

```
juicefs doctor [command options] MOUNTPOINT
juicefs debug [command options] MOUNTPOINT
```

#### 选项

`--out-dir value`<br />
结果输出目录,若目录不存在则自动创建 (默认:./doctor/)
结果输出目录,若目录不存在则自动创建 (默认:./debug/)

`--stats-sec value`<br />
.stats文件采样秒数 (默认:5)
Expand All @@ -1239,14 +1239,14 @@ profile指标采样秒数 (默认:30)

```bash
# 收集并展示挂载点 /mnt/jfs 的各类信息
$ juicefs doctor /mnt/jfs
$ juicefs debug /mnt/jfs

# 指定输出目录为 /var/log
$ juicefs doctor --out-dir=/var/log /mnt/jfs
$ juicefs debug --out-dir=/var/log /mnt/jfs

# 启用日志收集,并收集最后1000条日志条目
$ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 /mnt/jfs
$ juicefs debug --out-dir=/var/log --collect-log --limit=1000 /mnt/jfs

# 启用pprof指标收集
$ juicefs doctor --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /mnt/jfs
$ juicefs debug --out-dir=/var/log --collect-log --limit=1000 --collect-pprof /mnt/jfs
```

0 comments on commit 2c4bfd8

Please sign in to comment.