mirror of
https://github.com/datarhei/core.git
synced 2025-10-04 23:53:12 +08:00
Fix use of deprecated function
This commit is contained in:
@@ -98,7 +98,7 @@ func (p *process) cpuTimes() (*cpuTimesStat, error) {
|
||||
}
|
||||
|
||||
s := &cpuTimesStat{
|
||||
total: times.Total(),
|
||||
total: cpuTotal(times),
|
||||
system: times.System,
|
||||
user: times.User,
|
||||
}
|
||||
|
@@ -285,7 +285,7 @@ func (u *util) cpuTimes() (*cpuTimesStat, error) {
|
||||
}
|
||||
|
||||
s := &cpuTimesStat{
|
||||
total: times[0].Total(),
|
||||
total: cpuTotal(×[0]),
|
||||
system: times[0].System,
|
||||
user: times[0].User,
|
||||
idle: times[0].Idle,
|
||||
@@ -496,3 +496,8 @@ func (u *util) readFile(path string) ([]string, error) {
|
||||
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user