Merge pull request #2821 from filecoin-project/feat/miner-allinfo
miner: Command to dump all miner info
This commit is contained in:
commit
0073f10b62
@ -238,7 +238,7 @@ var CommonCommands = []*cli.Command{
|
||||
logCmd,
|
||||
waitApiCmd,
|
||||
fetchParamCmd,
|
||||
versionCmd,
|
||||
VersionCmd,
|
||||
}
|
||||
|
||||
var Commands = []*cli.Command{
|
||||
@ -256,7 +256,7 @@ var Commands = []*cli.Command{
|
||||
WithCategory("developer", fetchParamCmd),
|
||||
WithCategory("network", netCmd),
|
||||
WithCategory("network", syncCmd),
|
||||
versionCmd,
|
||||
VersionCmd,
|
||||
}
|
||||
|
||||
func WithCategory(cat string, cmd *cli.Command) *cli.Command {
|
||||
|
12
cli/net.go
12
cli/net.go
@ -18,16 +18,16 @@ var netCmd = &cli.Command{
|
||||
Name: "net",
|
||||
Usage: "Manage P2P Network",
|
||||
Subcommands: []*cli.Command{
|
||||
netPeers,
|
||||
NetPeers,
|
||||
netConnect,
|
||||
netListen,
|
||||
netId,
|
||||
NetListen,
|
||||
NetId,
|
||||
netFindPeer,
|
||||
netScores,
|
||||
},
|
||||
}
|
||||
|
||||
var netPeers = &cli.Command{
|
||||
var NetPeers = &cli.Command{
|
||||
Name: "peers",
|
||||
Usage: "Print peers",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
@ -93,7 +93,7 @@ var netScores = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var netListen = &cli.Command{
|
||||
var NetListen = &cli.Command{
|
||||
Name: "listen",
|
||||
Usage: "List listen addresses",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
@ -147,7 +147,7 @@ var netConnect = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
var netId = &cli.Command{
|
||||
var NetId = &cli.Command{
|
||||
Name: "id",
|
||||
Usage: "Get node identity",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var versionCmd = &cli.Command{
|
||||
var VersionCmd = &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "Print version",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
|
@ -24,7 +24,13 @@ import (
|
||||
var infoCmd = &cli.Command{
|
||||
Name: "info",
|
||||
Usage: "Print miner info",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
Subcommands: []*cli.Command{
|
||||
infoAllCmd,
|
||||
},
|
||||
Action: infoCmdAct,
|
||||
}
|
||||
|
||||
func infoCmdAct(cctx *cli.Context) error {
|
||||
color.NoColor = !cctx.Bool("color")
|
||||
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
@ -171,7 +177,6 @@ var infoCmd = &cli.Command{
|
||||
// * Sealed sectors (count / bytes)
|
||||
// * Power
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
type stateMeta struct {
|
||||
|
143
cmd/lotus-storage-miner/info_all.go
Normal file
143
cmd/lotus-storage-miner/info_all.go
Normal file
@ -0,0 +1,143 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
lcli "github.com/filecoin-project/lotus/cli"
|
||||
)
|
||||
|
||||
var infoAllCmd = &cli.Command{
|
||||
Name: "all",
|
||||
Usage: "dump all related miner info",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
|
||||
api, acloser, err := lcli.GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer acloser()
|
||||
_ = api
|
||||
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
// Top-level info
|
||||
|
||||
fmt.Println("#: Version")
|
||||
if err := lcli.VersionCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Miner Info")
|
||||
if err := infoCmdAct(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Verbose info
|
||||
|
||||
fmt.Println("\n#: Storage List")
|
||||
if err := storageListCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Worker List")
|
||||
if err := sealingWorkersCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: PeerID")
|
||||
if err := lcli.NetId.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Listen Addresses")
|
||||
if err := lcli.NetListen.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Very Verbose info
|
||||
fmt.Println("\n#: Peers")
|
||||
if err := lcli.NetPeers.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Sealing Jobs")
|
||||
if err := sealingJobsCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Sched Diag")
|
||||
if err := sealingSchedDiagCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Storage Ask")
|
||||
if err := getAskCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Storage Deals")
|
||||
if err := dealsListCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Sector List")
|
||||
if err := sectorsListCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("\n#: Sector Refs")
|
||||
if err := sectorsRefsCmd.Action(cctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Very Very Verbose info
|
||||
fmt.Println("\n#: Per Sector Info")
|
||||
|
||||
list, err := nodeApi.SectorsList(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sort.Slice(list, func(i, j int) bool {
|
||||
return list[i] < list[j]
|
||||
})
|
||||
|
||||
for _, s := range list {
|
||||
fmt.Printf("\n##: Sector %d Status\n", s)
|
||||
|
||||
fs := &flag.FlagSet{}
|
||||
for _, f := range sectorsStatusCmd.Flags {
|
||||
f.Apply(fs)
|
||||
}
|
||||
if err := fs.Parse([]string{"--log", "--on-chain-info", fmt.Sprint(s)}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := sectorsStatusCmd.Action(cli.NewContext(cctx.App, fs, cctx)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("\n##: Sector %d Storage Location\n", s)
|
||||
|
||||
fs = &flag.FlagSet{}
|
||||
if err := fs.Parse([]string{fmt.Sprint(s)}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := storageFindCmd.Action(cli.NewContext(cctx.App, fs, cctx)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
@ -266,7 +266,7 @@ var getAskCmd = &cli.Command{
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
|
||||
fmt.Fprintf(w, "Price per GiB / Epoch\tMin. Piece Size (w/bit-padding)\tMax. Piece Size (w/bit-padding)\tExpiry (Epoch)\tExpiry (Appx. Rem. Time)\tSeq. No.\n")
|
||||
fmt.Fprintf(w, "Price per GiB/Epoch\tMin. Piece Size (padded)\tMax. Piece Size (padded)\tExpiry (Epoch)\tExpiry (Appx. Rem. Time)\tSeq. No.\n")
|
||||
if ask == nil {
|
||||
fmt.Fprintf(w, "<miner does not have an ask>\n")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user