-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/extra/stats: add block singature counting tool
- Loading branch information
Showing
8 changed files
with
415 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Entity block signatures count tool. | ||
|
||
The tool uses node consensus and registry API endpoints and computes the per | ||
entity block signature counts. |
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,4 @@ | ||
## Extra | ||
|
||
This directory contains packages depending on (but not directly part of) | ||
oasis-core. |
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 @@ | ||
stats |
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,19 @@ | ||
## Stats | ||
|
||
Queries a node for network stats. Currently implemented per entity block | ||
signature counts. | ||
|
||
## Usage | ||
|
||
``` | ||
extra/stats entity-signatures \ | ||
--address unix:<node_dir>/internal.sock \ | ||
--start-block 0 \ | ||
--end-block 100 \ | ||
--top-n 100 | ||
|Rank |Entity ID |Nodes |Signatures| | ||
------------------------------------------------------------------------------------------ | ||
|1 |ef9ccfc825d5f0087e56937c697b46520f29f81e21d8a289218a4ebaef00509c| 6| 100| | ||
|2 |4ea5328f943ef6f66daaed74cb0e99c3b1c45f76307b425003dbc7cb3638ed35| 1| 80| | ||
... |
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,53 @@ | ||
// Package cmd implements stats cmd tool. | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
flag "github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
|
||
"github.com/oasislabs/oasis-core/go/common/logging" | ||
"github.com/oasislabs/oasis-core/go/common/version" | ||
"github.com/oasislabs/oasis-core/go/oasis-node/cmd/common" | ||
) | ||
|
||
const cfgLogLevel = "log.level" | ||
|
||
var ( | ||
rootCmd = &cobra.Command{ | ||
Use: "stats", | ||
Short: "Oasis stats", | ||
Version: version.SoftwareVersion, | ||
} | ||
|
||
rootFlags = flag.NewFlagSet("", flag.ContinueOnError) | ||
) | ||
|
||
// RootCommand returns the root (top level) cobra.Command. | ||
func RootCommand() *cobra.Command { | ||
return rootCmd | ||
} | ||
|
||
// Execute spawns the main entry point after handling the command line arguments. | ||
func Execute() { | ||
var logLevel logging.Level | ||
if err := logLevel.Set(viper.GetString(cfgLogLevel)); err != nil { | ||
common.EarlyLogAndExit(fmt.Errorf("root: failed to set log level: %w", err)) | ||
} | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
common.EarlyLogAndExit(err) | ||
} | ||
} | ||
|
||
func init() { | ||
logLevel := logging.LevelInfo | ||
rootFlags.Var(&logLevel, cfgLogLevel, "log level") | ||
_ = viper.BindPFlags(rootFlags) | ||
rootCmd.PersistentFlags().AddFlagSet(rootFlags) | ||
|
||
// Register all of the sub-commands. | ||
RegisterStatsCmd(rootCmd) | ||
} |
Oops, something went wrong.