summaryrefslogtreecommitdiffstats
path: root/devices
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-05-01 12:41:18 -0500
committerSean E. Russell <ser@ser1.net>2020-05-01 12:41:18 -0500
commitf2c63eb1b4cd1df3f7e79a9cc2f23e04d028a69b (patch)
tree79548e9bbd5b666bea9a41ad846bc7395d852c38 /devices
parent4563131b2a34993835e06c66756c46d5c7f06625 (diff)
Fixes #123, refresh delay on start
Diffstat (limited to 'devices')
-rw-r--r--devices/cpu.go6
-rw-r--r--devices/cpu_cpu.go5
2 files changed, 5 insertions, 6 deletions
diff --git a/devices/cpu.go b/devices/cpu.go
index 436ccb1..b4a9799 100644
--- a/devices/cpu.go
+++ b/devices/cpu.go
@@ -5,7 +5,7 @@ import (
"time"
)
-var cpuFuncs []func(map[string]int, time.Duration, bool) map[string]error
+var cpuFuncs []func(map[string]int, 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,7 +16,7 @@ var cpuFuncs []func(map[string]int, 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]int, time.Duration, bool) map[string]error) {
+func RegisterCPU(f func(map[string]int, bool) map[string]error) {
cpuFuncs = append(cpuFuncs, f)
}
@@ -24,7 +24,7 @@ func RegisterCPU(f func(map[string]int, time.Duration, bool) map[string]error) {
// Returns one value per cpu, or a single value if percpu is set to false.
func UpdateCPU(cpus map[string]int, interval time.Duration, logical bool) {
for _, f := range cpuFuncs {
- errs := f(cpus, interval, logical)
+ errs := f(cpus, logical)
if errs != nil {
for k, e := range errs {
log.Printf("%s: %s", k, e)
diff --git a/devices/cpu_cpu.go b/devices/cpu_cpu.go
index 42eff2e..1ee50f7 100644
--- a/devices/cpu_cpu.go
+++ b/devices/cpu_cpu.go
@@ -2,13 +2,12 @@ package devices
import (
"fmt"
- "time"
psCpu "github.com/shirou/gopsutil/cpu"
)
func init() {
- f := func(cpus map[string]int, iv time.Duration, l bool) map[string]error {
+ f := func(cpus map[string]int, l bool) map[string]error {
cpuCount, err := psCpu.Counts(l)
if err != nil {
return nil
@@ -17,7 +16,7 @@ func init() {
if cpuCount > 10 {
formatString = "CPU%02d"
}
- vals, err := psCpu.Percent(iv, l)
+ vals, err := psCpu.Percent(0, l)
if err != nil {
return map[string]error{"gopsutil": err}
}