Fix use of deprecated function

This commit is contained in:
Ingo Oppermann
2023-02-01 16:24:57 +01:00
parent 2a3288ffd0
commit 1d30d9eecd
2 changed files with 7 additions and 2 deletions

View File

@@ -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,
} }

View File

@@ -285,7 +285,7 @@ func (u *util) cpuTimes() (*cpuTimesStat, error) {
} }
s := &cpuTimesStat{ s := &cpuTimesStat{
total: times[0].Total(), total: cpuTotal(&times[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
}