Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 08 Mar 2009 10:03:10 -0400
From:      Jay Loden <freebsd@jayloden.com>
To:        freebsd-hackers@freebsd.org
Subject:   CPU user/kernel time given the PID
Message-ID:  <49B3D01E.1010600@jayloden.com>

next in thread | raw e-mail | index | archive | help
I'm working on FreeBSD support for a Python library called psutil for reading
process information in a cross-platform fashion. Each platform-specific module
is written in C, so the majority of the FreeBSD code is a C interface to various
process information. I've been having some trouble working out how to get CPU
user/kernel time for a given PID. I took a look at the source to top and ps but
neither really helped since they don't seem to cover the info I was looking for
(or I missed it).

I'm not sure if there's a better way to go about this but I've been looking at
sysctl and the kinfo_proc struct - is there somewhere more appropriate to
retrieve this information? If the kinfo_proc struct is the way to go, then do I
want to use ki_runtime, ki_swtime or something else, and does that mean there's
no distinction between user/kern time for a process? If anyone has code samples
or recommended docs to get me pointed in the right direction that would be great.

Thanks,

-Jay



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49B3D01E.1010600>