-
Notifications
You must be signed in to change notification settings - Fork 465
/
inspector.go
131 lines (120 loc) · 3.86 KB
/
inspector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package cmd
import (
"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/pkg/config"
"github.com/filecoin-project/venus/venus-shared/types"
cmds "github.com/ipfs/go-ipfs-cmds"
)
var inspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Show info about the venus node",
},
Subcommands: map[string]*cmds.Command{
"all": allInspectCmd,
"runtime": runtimeInspectCmd,
"disk": diskInspectCmd,
"memory": memoryInspectCmd,
"config": configInspectCmd,
"environment": envInspectCmd,
"protocol": protocolInspectCmd,
},
}
var allInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print all diagnostic information.",
ShortDescription: "Prints out information about filecoin process and its environment.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
var allInfo node.AllInspectorInfo
allInfo.Runtime = env.(*node.Env).InspectorAPI.Runtime()
dsk, err := env.(*node.Env).InspectorAPI.Disk()
if err != nil {
return err
}
allInfo.Disk = dsk
mem, err := env.(*node.Env).InspectorAPI.Memory()
if err != nil {
return err
}
allInfo.Memory = mem
allInfo.Config = env.(*node.Env).InspectorAPI.Config()
allInfo.Environment = env.(*node.Env).InspectorAPI.Environment()
allInfo.FilecoinVersion = env.(*node.Env).InspectorAPI.FilecoinVersion()
return cmds.EmitOnce(res, allInfo)
},
Type: node.AllInspectorInfo{},
}
var runtimeInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print runtime diagnostic information.",
ShortDescription: "Prints out information about the golang runtime.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out := env.(*node.Env).InspectorAPI.Runtime()
return cmds.EmitOnce(res, out)
},
Type: node.RuntimeInfo{},
}
var diskInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print filesystem usage information.",
ShortDescription: "Prints out information about the filesystem.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out, err := env.(*node.Env).InspectorAPI.Disk()
if err != nil {
return err
}
return cmds.EmitOnce(res, out)
},
Type: node.DiskInfo{},
}
var memoryInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print memory usage information.",
ShortDescription: "Prints out information about memory usage.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out, err := env.(*node.Env).InspectorAPI.Memory()
if err != nil {
return err
}
return cmds.EmitOnce(res, out)
},
Type: node.MemoryInfo{},
}
var configInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print in-memory config information.",
ShortDescription: "Prints out information about your filecoin nodes config.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out := env.(*node.Env).InspectorAPI.Config()
return cmds.EmitOnce(res, out)
},
Type: config.Config{},
}
var envInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print filecoin environment information.",
ShortDescription: "Prints out information about your filecoin nodes environment.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out := env.(*node.Env).InspectorAPI.Environment()
return cmds.EmitOnce(res, out)
},
Type: node.EnvironmentInfo{},
}
var protocolInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Show protocol parameter details",
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
params, err := env.(*node.Env).ChainAPI.ProtocolParameters(req.Context)
if err != nil {
return err
}
return re.Emit(params)
},
Type: types.ProtocolParams{},
}