Files
lotus/cli/status.go
Peter Rabbitson 1bc8a8b32c chore: remove (deprecated) deps on build/ proxy-constants
This is a large diff, yet should have exactly zero functional changes

Ideally as a result of this some parts of the depchain will become lighter,
with downstream reaping the same benefits as the team that initiated this split.

P.S. work was done while forming better intuition of current dependency graph
2024-07-22 17:36:12 +04:00

61 lines
1.5 KiB
Go

package cli
import (
"fmt"
"github.com/urfave/cli/v2"
"github.com/filecoin-project/lotus/chain/actors/policy"
)
var StatusCmd = &cli.Command{
Name: "status",
Usage: "Check node status",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "chain",
Usage: "include chain health status",
},
},
Action: func(cctx *cli.Context) error {
apic, closer, err := GetFullNodeAPIV1(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)
inclChainStatus := cctx.Bool("chain")
status, err := apic.NodeStatus(ctx, inclChainStatus)
if err != nil {
return err
}
fmt.Printf("Sync Epoch: %d\n", status.SyncStatus.Epoch)
fmt.Printf("Epochs Behind: %d\n", status.SyncStatus.Behind)
fmt.Printf("Peers to Publish Messages: %d\n", status.PeerStatus.PeersToPublishMsgs)
fmt.Printf("Peers to Publish Blocks: %d\n", status.PeerStatus.PeersToPublishBlocks)
if inclChainStatus && status.SyncStatus.Epoch > uint64(policy.ChainFinality) {
var ok100, okFin string
if status.ChainStatus.BlocksPerTipsetLast100 >= 4.75 {
ok100 = "[OK]"
} else {
ok100 = "[UNHEALTHY]"
}
if status.ChainStatus.BlocksPerTipsetLastFinality >= 4.75 {
okFin = "[OK]"
} else {
okFin = "[UNHEALTHY]"
}
fmt.Printf("Blocks per TipSet in last 100 epochs: %f %s\n", status.ChainStatus.BlocksPerTipsetLast100, ok100)
fmt.Printf("Blocks per TipSet in last finality: %f %s\n", status.ChainStatus.BlocksPerTipsetLastFinality, okFin)
}
return nil
},
}