2023-07-09 23:04:17 +08:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/shirou/gopsutil/cpu"
|
2023-07-15 23:29:03 +08:00
|
|
|
"time"
|
2023-07-09 23:04:17 +08:00
|
|
|
)
|
|
|
|
|
2023-07-15 23:29:03 +08:00
|
|
|
func (i *InfoUtils) GetCpuInfo() []cpu.InfoStat {
|
2023-07-09 23:04:17 +08:00
|
|
|
infoStats, _ := cpu.Info()
|
|
|
|
return infoStats
|
|
|
|
}
|
2023-07-15 23:29:03 +08:00
|
|
|
|
|
|
|
func (i *InfoUtils) GetCpuUsage() []float64 {
|
|
|
|
info, _ := cpu.Percent(time.Second, false)
|
|
|
|
return info
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *InfoUtils) GetCpuTimes() []cpu.TimesStat {
|
|
|
|
info, _ := cpu.Times(false)
|
|
|
|
return info
|
|
|
|
}
|