From 426b5148e3129e0c31107346bb2ed7e6201d5559 Mon Sep 17 00:00:00 2001 From: JuanLeon Lahoz Date: Tue, 14 Apr 2020 13:33:27 +0200 Subject: [PATCH] Provide an estimation of Iowait metric per process --- process/process_linux.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/process/process_linux.go b/process/process_linux.go index fab7b55..afd5e28 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -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)