consul: Expose runtime stats for debugging

pull/89/head
Armon Dadgar 11 years ago
parent a5ab73e67d
commit 2c45bd6fe9

@ -342,6 +342,7 @@ func (c *Client) Stats() map[string]map[string]string {
"known_servers": toString(uint64(len(c.consuls))), "known_servers": toString(uint64(len(c.consuls))),
}, },
"serf_lan": c.serf.Stats(), "serf_lan": c.serf.Stats(),
"runtime": runtimeStats(),
} }
return stats return stats
} }

@ -528,6 +528,7 @@ func (s *Server) Stats() map[string]map[string]string {
"raft": s.raft.Stats(), "raft": s.raft.Stats(),
"serf_lan": s.serfLAN.Stats(), "serf_lan": s.serfLAN.Stats(),
"serf_wan": s.serfWAN.Stats(), "serf_wan": s.serfWAN.Stats(),
"runtime": runtimeStats(),
} }
return stats return stats
} }

@ -7,6 +7,7 @@ import (
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"strconv" "strconv"
) )
@ -139,3 +140,15 @@ func uint64ToBytes(u uint64) []byte {
binary.BigEndian.PutUint64(buf, u) binary.BigEndian.PutUint64(buf, u)
return buf 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…
Cancel
Save