Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Nov 2009 13:12:33 -0600
From:      Dan Nelson <>
To:        cronfy <>
Cc:        FreeBSD <>
Subject:   Re: get accounting info for running process
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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
for an example.  (I still need to file that PR...)

	Dan Nelson

Want to link to this message? Use this URL: <>