mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 22:06:20 +00:00
consul: Expose runtime stats for debugging
This commit is contained in:
parent
a5ab73e67d
commit
2c45bd6fe9
@ -342,6 +342,7 @@ func (c *Client) Stats() map[string]map[string]string {
|
||||
"known_servers": toString(uint64(len(c.consuls))),
|
||||
},
|
||||
"serf_lan": c.serf.Stats(),
|
||||
"runtime": runtimeStats(),
|
||||
}
|
||||
return stats
|
||||
}
|
||||
|
@ -528,6 +528,7 @@ func (s *Server) Stats() map[string]map[string]string {
|
||||
"raft": s.raft.Stats(),
|
||||
"serf_lan": s.serfLAN.Stats(),
|
||||
"serf_wan": s.serfWAN.Stats(),
|
||||
"runtime": runtimeStats(),
|
||||
}
|
||||
return stats
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
@ -139,3 +140,15 @@ func uint64ToBytes(u uint64) []byte {
|
||||
binary.BigEndian.PutUint64(buf, u)
|
||||
return buf
|
||||
}
|
||||
|
||||
// runtimeStats is used to return various runtime information
|
||||
func runtimeStats() map[string]string {
|
||||
return map[string]string{
|
||||
"os": runtime.GOOS,
|
||||
"arch": runtime.GOARCH,
|
||||
"version": runtime.Version(),
|
||||
"max_procs": strconv.FormatInt(int64(runtime.GOMAXPROCS(0)), 10),
|
||||
"goroutines": strconv.FormatInt(int64(runtime.NumGoroutine()), 10),
|
||||
"cpu_count": strconv.FormatInt(int64(runtime.NumCPU()), 10),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user