From f2c63eb1b4cd1df3f7e79a9cc2f23e04d028a69b Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Fri, 1 May 2020 12:41:18 -0500 Subject: Fixes #123, refresh delay on start --- devices/cpu.go | 6 +++--- devices/cpu_cpu.go | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'devices') 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} } -- cgit v1.2.3