29 lines
442 B
Go
29 lines
442 B
Go
package system
|
|
|
|
import (
|
|
"math"
|
|
"runtime"
|
|
"strconv"
|
|
|
|
"github.com/shirou/gopsutil/v3/cpu"
|
|
)
|
|
|
|
func staticCpu() CPU {
|
|
var p CPU
|
|
p.Threads = strconv.Itoa(runtime.NumCPU()) + " threads"
|
|
c, err := cpu.Info()
|
|
if err == nil {
|
|
p.Name = c[0].ModelName
|
|
} else {
|
|
p.Name = "none detected"
|
|
}
|
|
return p
|
|
}
|
|
|
|
func (c *Config) liveCpu() {
|
|
p, err := cpu.Percent(0, false)
|
|
if err != nil {
|
|
return
|
|
}
|
|
c.System.Live.CPU = math.RoundToEven(p[0])
|
|
}
|