get accounting info for running process
Dan Nelson
dnelson at allantgroup.com
Wed Nov 18 19:12:35 UTC 2009
In the last episode (Nov 18), cronfy said:
> Is it possible to find out how much a process have used CPU user
> time/system time/IO operations for now by it's pid? Like in sa, but for
> running process.
It's available to userland programs via the kern.proc.all syscall. it
returns an array of "struct kinfo_proc", one for each process. One of the
elements is ki_rusage, which contains the data that the sa command uses.
The ps command can easily be extended to print these fields. See this patch
at http://lists.freebsd.org/pipermail/freebsd-hackers/2009-March/027918.html
for an example. (I still need to file that PR...)
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-questions
mailing list