summaryrefslogtreecommitdiffstats
path: root/layout
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-02-18 09:44:29 -0600
committerSean E. Russell <ser@ser1.net>2020-02-18 10:23:33 -0600
commit5ccfc7cbc6f406192e1eb20d84dcfa49814e57ad (patch)
treecfc97f26f07ac52f289b32b8379a16fcedfd05f8 /layout
parentb61ed8b81b47d686a787e9ceda190d370991167c (diff)
Adds widget metrics output
Doc cleanup Missed changes
Diffstat (limited to 'layout')
-rw-r--r--layout/layout.go12
1 files changed, 10 insertions, 2 deletions
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
}