From 0dcaecbadac05e9dd766b4fc80e060a6b1358175 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Thu, 24 Apr 2014 19:08:07 +0900 Subject: [PATCH] implements Create_time of process_linux. --- process_linux.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/process_linux.go b/process_linux.go index 98aee99..52746b3 100644 --- a/process_linux.go +++ b/process_linux.go @@ -137,14 +137,19 @@ func fillFromStat(pid int32, p *Process) error { } p.Ppid = parseInt32(fields[3]) - utime, _ := strconv.ParseFloat(fields[11], 64) - stime, _ := strconv.ParseFloat(fields[11], 64) + utime, _ := strconv.ParseFloat(fields[13], 64) + stime, _ := strconv.ParseFloat(fields[14], 64) p.Cpu_times = CPU_TimesStat{ - User: float32(utime / CLOCK_TICKS), - System: float32(stime / CLOCK_TICKS), + Cpu: "cpu", + User: float32(utime * (1000 / CLOCK_TICKS)), + System: float32(stime * (1000 / CLOCK_TICKS)), } + boot_time, _ := Boot_time() + ctime := ((parseUint64(fields[21]) / uint64(CLOCK_TICKS)) + uint64(boot_time)) * 1000 + p.Create_time = int64(ctime) + // p.Nice = parseInt32(fields[18]) // use syscall instead of parse Stat file nice, _ := syscall.Getpriority(PRIO_PROCESS, int(pid))