mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add runtimestats, stack logging to debug
This commit is contained in:
parent
17e2c2df8e
commit
25a3fcf731
19
debug.go
19
debug.go
@ -3,11 +3,14 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"github.com/bcicen/ctop/container"
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
var mstats = &runtime.MemStats{}
|
||||
|
||||
func logEvent(e ui.Event) {
|
||||
var s string
|
||||
s += fmt.Sprintf("Type=%s", quote(e.Type))
|
||||
@ -19,6 +22,22 @@ func logEvent(e ui.Event) {
|
||||
log.Debugf("new event: %s", s)
|
||||
}
|
||||
|
||||
func runtimeStats() {
|
||||
var msg string
|
||||
msg += fmt.Sprintf("cgo calls=%v", runtime.NumCgoCall())
|
||||
msg += fmt.Sprintf(" routines=%v", runtime.NumGoroutine())
|
||||
runtime.ReadMemStats(mstats)
|
||||
msg += fmt.Sprintf(" numgc=%v", mstats.NumGC)
|
||||
msg += fmt.Sprintf(" alloc=%v", mstats.Alloc)
|
||||
log.Debugf("runtime: %v", msg)
|
||||
}
|
||||
|
||||
func runtimeStack() {
|
||||
buf := make([]byte, 32768)
|
||||
buf = buf[:runtime.Stack(buf, true)]
|
||||
log.Infof(fmt.Sprintf("stack:\n%v", string(buf)))
|
||||
}
|
||||
|
||||
// log container, metrics, and widget state
|
||||
func dumpContainer(c *container.Container) {
|
||||
msg := fmt.Sprintf("logging state for container: %s\n", c.Id)
|
||||
|
Loading…
Reference in New Issue
Block a user