summaryrefslogtreecommitdiffstats
path: root/devices
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-02-28 10:03:41 -0600
committerSean E. Russell <ser@ser1.net>2020-02-28 10:06:05 -0600
commit231b0d03fed93ccc4b5f953f503763966341ec48 (patch)
tree9bb07a88dd0ac7e73fa82935d0909ef4dd0810a8 /devices
parent7a89225d729d4c54c5bc95b21979f48f9cd046b1 (diff)
Extensions.v3.4.x
Diffstat (limited to 'devices')
-rw-r--r--devices/cpu.go6
-rw-r--r--devices/cpu_cpu.go4
2 files changed, 5 insertions, 5 deletions
diff --git a/devices/cpu.go b/devices/cpu.go
index 21d21b6..436ccb1 100644
--- a/devices/cpu.go
+++ b/devices/cpu.go
@@ -5,7 +5,7 @@ import (
"time"
)
-var cpuFuncs []func(map[string]float64, time.Duration, bool) map[string]error
+var cpuFuncs []func(map[string]int, time.Duration, bool) map[string]error
// RegisterCPU adds a new CPU device to the CPU widget. labels returns the
// names of the devices; they should be as short as possible, and the indexes
@@ -16,13 +16,13 @@ var cpuFuncs []func(map[string]float64, time.Duration, bool) map[string]error
//
// labels may be called once and the value cached. This means the number of
// cores should not change dynamically.
-func RegisterCPU(f func(map[string]float64, time.Duration, bool) map[string]error) {
+func RegisterCPU(f func(map[string]int, time.Duration, bool) map[string]error) {
cpuFuncs = append(cpuFuncs, f)
}
// CPUPercent calculates the percentage of cpu used either per CPU or combined.
// Returns one value per cpu, or a single value if percpu is set to false.
-func UpdateCPU(cpus map[string]float64, interval time.Duration, logical bool) {
+func UpdateCPU(cpus map[string]int, interval time.Duration, logical bool) {
for _, f := range cpuFuncs {
errs := f(cpus, interval, logical)
if errs != nil {
diff --git a/devices/cpu_cpu.go b/devices/cpu_cpu.go
index e18b51d..a1d20cd 100644
--- a/devices/cpu_cpu.go
+++ b/devices/cpu_cpu.go
@@ -8,7 +8,7 @@ import (
)
func init() {
- f := func(cpus map[string]float64, iv time.Duration, l bool) map[string]error {
+ f := func(cpus map[string]int, iv time.Duration, l bool) map[string]error {
cpuCount, err := psCpu.Counts(l)
if err != nil {
return nil
@@ -23,7 +23,7 @@ func init() {
}
for i := 0; i < len(vals); i++ {
key := fmt.Sprintf(formatString, i)
- cpus[key] = vals[i]
+ cpus[key] = int(vals[i])
}
return nil
}