#207 Replace scaleCpu option with dedicated column CPU Scaled

The new column is disabled by default.
This commit is contained in:
Sergey Ponomarev
2020-11-20 23:08:19 +02:00
parent 2792e72d18
commit f377dcaee2
9 changed files with 25 additions and 33 deletions

View File

@@ -11,14 +11,22 @@ import (
type CPUCol struct {
*GaugeCol
scaleCpu bool
}
func NewCPUCol() CompactCol {
return &CPUCol{NewGaugeCol("CPU")}
return &CPUCol{NewGaugeCol("CPU"), false}
}
func NewCpuScaledCol() CompactCol {
return &CPUCol{NewGaugeCol("CPUS"), true}
}
func (w *CPUCol) SetMetrics(m models.Metrics) {
val := m.CPUUtil
if !w.scaleCpu {
val = val * int(m.NCpus)
}
w.BarColor = colorScale(val)
w.Label = fmt.Sprintf("%d%%", val)