Commit 8502ad3d authored by Ubuntu's avatar Ubuntu

fix cpu usage

parent f6680c20
...@@ -43,24 +43,9 @@ func getCPU() ([]DeviceInfo, error) { ...@@ -43,24 +43,9 @@ func getCPU() ([]DeviceInfo, error) {
} }
func getCPUUsage() ([]DeviceInfo, error) { func getCPUUsage() ([]DeviceInfo, error) {
cpu, err := ghw.CPU()
if err != nil {
return nil, errors.Wrap(err, "error getting CPU info")
}
res := make([]DeviceInfo, 0, len(cpu.Processors))
// for i, proc := range cpu.Processors {
// fmt.Printf(" %v\n", proc)
// e := DeviceInfo{ res := make([]DeviceInfo, 0, len(cpu.Processors))
// Type: fmt.Sprintf("proc-%d", i),
// Model: proc.Model,
// Param: "proc.NumThreads",
// Power: uint64(proc.NumThreads),
// }
// res = append(res, e)
// }
var rusage syscall.Rusage var rusage syscall.Rusage
...@@ -78,7 +63,7 @@ func getCPUUsage() ([]DeviceInfo, error) { ...@@ -78,7 +63,7 @@ func getCPUUsage() ([]DeviceInfo, error) {
e := DeviceInfo{ e := DeviceInfo{
Type: "cpu", Type: "cpu",
//Model: proc.Model, //Model: proc.Model,
Param: "proc.NumThreads", Param: "syscall.Getrusage",
Power: uint64(float64(total) / float64(time.Second) * 100), Power: uint64(float64(total) / float64(time.Second) * 100),
} }
res = append(res, e) res = append(res, e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment