Fix use of deprecated function
This commit is contained in:
parent
2a3288ffd0
commit
1d30d9eecd
@ -98,7 +98,7 @@ func (p *process) cpuTimes() (*cpuTimesStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := &cpuTimesStat{
|
s := &cpuTimesStat{
|
||||||
total: times.Total(),
|
total: cpuTotal(times),
|
||||||
system: times.System,
|
system: times.System,
|
||||||
user: times.User,
|
user: times.User,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -285,7 +285,7 @@ func (u *util) cpuTimes() (*cpuTimesStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := &cpuTimesStat{
|
s := &cpuTimesStat{
|
||||||
total: times[0].Total(),
|
total: cpuTotal(×[0]),
|
||||||
system: times[0].System,
|
system: times[0].System,
|
||||||
user: times[0].User,
|
user: times[0].User,
|
||||||
idle: times[0].Idle,
|
idle: times[0].Idle,
|
||||||
@ -496,3 +496,8 @@ func (u *util) readFile(path string) ([]string, error) {
|
|||||||
|
|
||||||
return lines, nil
|
return lines, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cpuTotal(c *cpu.TimesStat) float64 {
|
||||||
|
return c.User + c.System + c.Idle + c.Nice + c.Iowait + c.Irq +
|
||||||
|
c.Softirq + c.Steal + c.Guest + c.GuestNice
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user