1
0
mirror of https://github.com/divan/expvarmon.git synced 2025-04-25 13:48:54 +08:00
expvarmon/ui_dummy.go
2015-04-21 12:51:01 +03:00

36 lines
726 B
Go

package main
import (
"fmt"
"github.com/pyk/byten"
)
// DummyUI is an simple console UI mockup, for testing purposes.
type DummyUI struct{}
func (u *DummyUI) Init() {}
func (u *DummyUI) Close() {}
func (u *DummyUI) Update(data Data) {
if data.Services == nil {
return
}
for _, service := range data.Services {
fmt.Printf("%s: ", service.Name)
if service.Err != nil {
fmt.Printf("ERROR: %s", service.Err)
continue
}
if service.Memstats != nil {
alloc := byten.Size(int64(service.Memstats.Alloc))
sys := byten.Size(int64(service.Memstats.Sys))
fmt.Printf("%s/%s ", alloc, sys)
}
if service.Goroutines != 0 {
fmt.Printf("goroutines: %d", service.Goroutines)
}
fmt.Printf("\n")
}
}