diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-25 23:18:42 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-25 23:18:42 +0800 |
commit | b0a5be4495962c291a25cbea793e43bad0781510 (patch) | |
tree | e058201e7b29c3cb8efd710e20ec1e1f97f64368 /cmd/geth/main.go | |
parent | e64625aa8215985c85f97f914a98db081e07714f (diff) | |
parent | e9c0b5431cbd7430ddec9fd17983241018fd8a55 (diff) | |
download | go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.tar go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.tar.gz go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.tar.bz2 go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.tar.lz go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.tar.xz go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.tar.zst go-tangerine-b0a5be4495962c291a25cbea793e43bad0781510.zip |
Merge pull request #1321 from karalabe/cut-it-open-3000
Metrics collecting and reporting support
Diffstat (limited to 'cmd/geth/main.go')
-rw-r--r-- | cmd/geth/main.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 963aced15..fcf7f27f0 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -30,6 +30,7 @@ import ( "runtime" "strconv" "strings" + "time" "github.com/codegangsta/cli" "github.com/ethereum/ethash" @@ -42,6 +43,7 @@ import ( "github.com/ethereum/go-ethereum/rpc/comms" "github.com/mattn/go-colorable" "github.com/mattn/go-isatty" + "github.com/rcrowley/go-metrics" ) const ( @@ -72,6 +74,7 @@ func init() { upgradedbCommand, removedbCommand, dumpCommand, + monitorCommand, { Action: makedag, Name: "makedag", @@ -284,6 +287,28 @@ 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) + } + }() } func main() { |