-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5767 from filecoin-project/feat/node-status-api
node status api
- Loading branch information
Showing
9 changed files
with
239 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/filecoin-project/lotus/build" | ||
) | ||
|
||
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 := GetFullNodeAPI(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(build.Finality) { | ||
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 | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters