func serversOverview(servers []engine.Server) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tURL\tReqs/sec\t50ile[ms]\t95ile[ms]\t99ile[ms]\tStatus codes %%\tNet. errors %%\tMessages\n") for _, e := range servers { serverOverview(t, e) } return t.String() }
func serversView(srvs []engine.Server) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tURL\n") if len(srvs) == 0 { return t.String() } for _, v := range srvs { fmt.Fprint(t, serverView(&v)) } return t.String() }
func backendsView(bs []engine.Backend) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tType\n") if len(bs) == 0 { return t.String() } for _, v := range bs { fmt.Fprint(t, backendView(&v)) } return t.String() }
func frontendsView(fs []engine.Frontend) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tRoute\tBackend\tType\n") if len(fs) == 0 { return t.String() } for _, v := range fs { fmt.Fprint(t, frontendView(&v)) } return t.String() }
func listenersView(ls []engine.Listener) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tProtocol\tNetwork\tAddress\tScope\n") if len(ls) == 0 { return t.String() } for _, l := range ls { fmt.Fprint(t, listenerView(&l)) } return t.String() }
func hostsView(hs []engine.Host) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Name\tDefault\n") if len(hs) == 0 { return t.String() } for _, h := range hs { fmt.Fprint(t, hostView(&h)) } return t.String() }
func frontendsOverview(frontends []engine.Frontend) string { t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tRoute\tR/sec\t50ile[ms]\t95ile[ms]\t99ile[ms]\tStatus codes %%\tNet. errors %%\n") if len(frontends) == 0 { return t.String() } for _, l := range frontends { frontendOverview(t, l) } return t.String() }
func middlewaresView(ms []engine.Middleware) string { sort.Sort(&middlewareSorter{ms: ms}) t := goterm.NewTable(0, 10, 5, ' ', 0) fmt.Fprint(t, "Id\tPriority\tType\tSettings\n") if len(ms) == 0 { return t.String() } for _, v := range ms { fmt.Fprint(t, middlewareView(&v)) } return t.String() }
func main() { tm.Clear() // Clear current screen started := 100 finished := 250 // Based on http://golang.org/pkg/text/tabwriter totals := tm.NewTable(0, 10, 5, ' ', 0) fmt.Fprintf(totals, "Time\tStarted\tActive\tFinished\n") fmt.Fprintf(totals, "%s\t%d\t%d\t%d\n", "All", started, started-finished, finished) tm.Println(totals) tm.Flush() }