aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-06-30 07:58:49 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-06-30 07:58:49 +0800
commite896cab82ccad8f1c4fb13892d67ba7452948403 (patch)
treeb2967ce1ed56ae19660319e8bb7a849698187a74 /cmd/geth
parent7c4ed8055cc036214279e3ebded74c58d6808d05 (diff)
parent5f3792c2a750dd95adeccbd5cf0cb19ecddfb43f (diff)
downloaddexon-e896cab82ccad8f1c4fb13892d67ba7452948403.tar.gz
dexon-e896cab82ccad8f1c4fb13892d67ba7452948403.tar.zst
dexon-e896cab82ccad8f1c4fb13892d67ba7452948403.zip
Merge pull request #1360 from obscuren/peter-metrics
Rebased peter's PR
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/main.go25
-rw-r--r--cmd/geth/monitorcmd.go9
2 files changed, 10 insertions, 24 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index fcf7f27f0..3e945687b 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -39,11 +39,11 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/comms"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
- "github.com/rcrowley/go-metrics"
)
const (
@@ -272,6 +272,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
utils.LogJSONFlag,
utils.PProfEanbledFlag,
utils.PProfPortFlag,
+ utils.MetricsEnabledFlag,
utils.SolcPathFlag,
utils.GpoMinGasPriceFlag,
utils.GpoMaxGasPriceFlag,
@@ -288,27 +289,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
return nil
}
// Start system runtime metrics collection
- go func() {
- allocs := metrics.GetOrRegisterMeter("system/memory/allocs", metrics.DefaultRegistry)
- frees := metrics.GetOrRegisterMeter("system/memory/frees", metrics.DefaultRegistry)
- inuse := metrics.GetOrRegisterMeter("system/memory/inuse", metrics.DefaultRegistry)
- pauses := metrics.GetOrRegisterMeter("system/memory/pauses", metrics.DefaultRegistry)
-
- stats := make([]*runtime.MemStats, 2)
- for i := 0; i < len(stats); i++ {
- stats[i] = new(runtime.MemStats)
- }
- for i := 1; ; i++ {
- runtime.ReadMemStats(stats[i%2])
-
- allocs.Mark(int64(stats[i%2].Mallocs - stats[(i-1)%2].Mallocs))
- frees.Mark(int64(stats[i%2].Frees - stats[(i-1)%2].Frees))
- inuse.Mark(int64(stats[i%2].Alloc - stats[(i-1)%2].Alloc))
- pauses.Mark(int64(stats[i%2].PauseTotalNs - stats[(i-1)%2].PauseTotalNs))
-
- time.Sleep(3 * time.Second)
- }
- }()
+ go metrics.CollectProcessMetrics(3 * time.Second)
}
func main() {
diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go
index fe771b561..6593b3614 100644
--- a/cmd/geth/monitorcmd.go
+++ b/cmd/geth/monitorcmd.go
@@ -75,7 +75,12 @@ func monitor(ctx *cli.Context) {
if len(monitored) == 0 {
list := expandMetrics(metrics, "")
sort.Strings(list)
- utils.Fatalf("No metrics specified.\n\nAvailable:\n - %s", strings.Join(list, "\n - "))
+
+ if len(list) > 0 {
+ utils.Fatalf("No metrics specified.\n\nAvailable:\n - %s", strings.Join(list, "\n - "))
+ } else {
+ utils.Fatalf("No metrics collected by geth (--%s).\n", utils.MetricsEnabledFlag.Name)
+ }
}
sort.Strings(monitored)
if cols := len(monitored) / ctx.Int(monitorCommandRowsFlag.Name); cols > 6 {
@@ -285,7 +290,7 @@ func updateChart(metric string, data []float64, base *int, chart *termui.LineCha
}
// Update the chart's label with the scale units
units := dataUnits
- if strings.Contains(metric, "/Percentiles/") || strings.Contains(metric, "/pauses/") {
+ if strings.Contains(metric, "/Percentiles/") || strings.Contains(metric, "/pauses/") || strings.Contains(metric, "/time/") {
units = timeUnits
}
chart.Border.Label = metric