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:
commit
93a90ccfca
@ -1157,10 +1157,19 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui
|
|||||||
return 0, 0, nil, 0, 0, 0, nil, err
|
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{
|
cpuTimes := &cpu.TimesStat{
|
||||||
CPU: "cpu",
|
CPU: "cpu",
|
||||||
User: float64(utime / ClockTicks),
|
User: float64(utime / ClockTicks),
|
||||||
System: float64(stime / ClockTicks),
|
System: float64(stime / ClockTicks),
|
||||||
|
Iowait: float64(iotime / ClockTicks),
|
||||||
}
|
}
|
||||||
|
|
||||||
bootTime, _ := common.BootTimeWithContext(ctx)
|
bootTime, _ := common.BootTimeWithContext(ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user