From 5ccfc7cbc6f406192e1eb20d84dcfa49814e57ad Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Tue, 18 Feb 2020 09:44:29 -0600 Subject: Adds widget metrics output Doc cleanup Missed changes --- layout/layout.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'layout') diff --git a/layout/layout.go b/layout/layout.go index c78bb67..f72cc0b 100644 --- a/layout/layout.go +++ b/layout/layout.go @@ -108,8 +108,12 @@ func processRow(c gotop.Config, numRows int, rowDefs [][]widgetRule) (ui.GridIte return ui.NewRow(1.0/float64(numRows), uiColumns...), rowDefs } +type Metric interface { + EnableMetric() +} + func makeWidget(c gotop.Config, widRule widgetRule) interface{} { - var w interface{} + var w Metric switch widRule.Widget { case "cpu": cpu := widgets.NewCpuWidget(c.UpdateInterval, c.GraphHorizontalScale, c.AverageLoad, c.PercpuLoad) @@ -130,7 +134,8 @@ func makeWidget(c gotop.Config, widRule widgetRule) interface{} { } w = cpu case "disk": - w = widgets.NewDiskWidget() + dw := widgets.NewDiskWidget() + w = dw case "mem": m := widgets.NewMemWidget(c.UpdateInterval, c.GraphHorizontalScale) m.LineColors["Main"] = ui.Color(c.Colorscheme.MainMem) @@ -174,6 +179,9 @@ func makeWidget(c gotop.Config, widRule widgetRule) interface{} { log.Printf("Invalid widget name %s. Must be one of %v", widRule.Widget, widgetNames) return ui.NewBlock() } + if c.ExportPort != "" { + w.EnableMetric() + } return w } -- cgit v1.2.3