@@ -30,6 +30,7 @@ import (
30
30
"runtime"
31
31
"strconv"
32
32
"strings"
33
+ "time"
33
34
34
35
"github.com/codegangsta/cli"
35
36
"github.com/ethereum/ethash"
@@ -42,6 +43,7 @@ import (
42
43
"github.com/ethereum/go-ethereum/rpc/comms"
43
44
"github.com/mattn/go-colorable"
44
45
"github.com/mattn/go-isatty"
46
+ "github.com/rcrowley/go-metrics"
45
47
)
46
48
47
49
const (
@@ -285,6 +287,28 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
285
287
}
286
288
return nil
287
289
}
290
+ // Start system runtime metrics collection
291
+ go func () {
292
+ used := metrics .GetOrRegisterMeter ("system/memory/used" , metrics .DefaultRegistry )
293
+ total := metrics .GetOrRegisterMeter ("system/memory/total" , metrics .DefaultRegistry )
294
+ mallocs := metrics .GetOrRegisterMeter ("system/memory/mallocs" , metrics .DefaultRegistry )
295
+ frees := metrics .GetOrRegisterMeter ("system/memory/frees" , metrics .DefaultRegistry )
296
+
297
+ stats := make ([]* runtime.MemStats , 2 )
298
+ for i := 0 ; i < len (stats ); i ++ {
299
+ stats [i ] = new (runtime.MemStats )
300
+ }
301
+ for i := 1 ; ; i ++ {
302
+ runtime .ReadMemStats (stats [i % 2 ])
303
+
304
+ used .Mark (int64 (stats [i % 2 ].Alloc - stats [(i - 1 )% 2 ].Alloc ))
305
+ total .Mark (int64 (stats [i % 2 ].TotalAlloc - stats [(i - 1 )% 2 ].TotalAlloc ))
306
+ mallocs .Mark (int64 (stats [i % 2 ].Mallocs - stats [(i - 1 )% 2 ].Mallocs ))
307
+ frees .Mark (int64 (stats [i % 2 ].Frees - stats [(i - 1 )% 2 ].Frees ))
308
+
309
+ time .Sleep (3 * time .Second )
310
+ }
311
+ }()
288
312
}
289
313
290
314
func main () {
0 commit comments