mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-02 22:17:08 +08:00
implements Create_time of process_linux.
This commit is contained in:
parent
b01775ecf9
commit
0dcaecbada
@ -137,14 +137,19 @@ func fillFromStat(pid int32, p *Process) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.Ppid = parseInt32(fields[3])
|
p.Ppid = parseInt32(fields[3])
|
||||||
utime, _ := strconv.ParseFloat(fields[11], 64)
|
utime, _ := strconv.ParseFloat(fields[13], 64)
|
||||||
stime, _ := strconv.ParseFloat(fields[11], 64)
|
stime, _ := strconv.ParseFloat(fields[14], 64)
|
||||||
|
|
||||||
p.Cpu_times = CPU_TimesStat{
|
p.Cpu_times = CPU_TimesStat{
|
||||||
User: float32(utime / CLOCK_TICKS),
|
Cpu: "cpu",
|
||||||
System: float32(stime / CLOCK_TICKS),
|
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])
|
// p.Nice = parseInt32(fields[18])
|
||||||
// use syscall instead of parse Stat file
|
// use syscall instead of parse Stat file
|
||||||
nice, _ := syscall.Getpriority(PRIO_PROCESS, int(pid))
|
nice, _ := syscall.Getpriority(PRIO_PROCESS, int(pid))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user