1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

Merge pull request #856 from juan-leon/delayacct-blkio-ticks-as-iowait

Provide an estimation of Iowait metric per process
This commit is contained in:
shirou 2020-04-15 22:59:17 +09:00 committed by GitHub
commit 93a90ccfca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1157,10 +1157,19 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui
return 0, 0, nil, 0, 0, 0, nil, err
}
// There is no such thing as iotime in stat file. As an approximation, we
// will use delayacct_blkio_ticks (aggregated block I/O delays, as per Linux
// docs). Note: I am assuming at least Linux 2.6.18
iotime, err := strconv.ParseFloat(fields[i+40], 64)
if err != nil {
iotime = 0 // Ancient linux version, most likely
}
cpuTimes := &cpu.TimesStat{
CPU: "cpu",
User: float64(utime / ClockTicks),
System: float64(stime / ClockTicks),
Iowait: float64(iotime / ClockTicks),
}
bootTime, _ := common.BootTimeWithContext(ctx)