Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Nov 2009 17:37:39 -0900
From:      Mel Flynn <mel.flynn+fbsd.questions@mailing.thruhere.net>
To:        cronfy <cronfy@sprinthost.ru>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: get accounting info for running process
Message-ID:  <d59d9de021f1f5f63e28cc068ed68cc6@sbmail.office-on-the.net>
In-Reply-To: <4B0579CE.2020203@sprinthost.ru>
References:  <4B042C50.6060904@sprinthost.ru> <5f09d2bccc69d1f101c5c22151ef0c05@sbmail.office-on-the.net> <4B0579CE.2020203@sprinthost.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 19 Nov 2009 20:01:02 +0300, cronfy <cronfy@sprinthost.ru> wrote:
>>> Is it possible to find out how much a process have used CPU user=20
>>> time/system time/IO operations for now by it's pid? Like in sa, but f=
or

>>> running process.
>>>    =20
>=20
> Dan, Mel, thanks for your answers. I examined 'ps' sources and decided=20
> to use  kvm_getprocs() and rusage structure.
>=20
> I am trying to create a daemon that would report system accounting stat=
s=20
> for every X seconds, let's say 10.  'sa' reports about terminated=20
> processes only, but it would be nice to have more detailed system usage=
=20
> stats per user for a given time interval (i.e. last 10 seconds),=20
> including tasks that are not finished at the moment of querying.
>=20
> I can achieve this by querying list of processes each 10 seconds and=20
> producing diffs between previous and current list, saving these to some=
=20
> log and combining data with /var/account/acct file.
>=20
> The only thing I do not want to do is to invent a wheel ;-) I googled=20
> much for such solutions, but did not find any. May be someone knows=20
> existing products that has this functionality already?

I don't know of anything like that, but ... there is of course radius.
Depends what you want to do with the info. If usage restriction is your
ultimate goal, then radius is your friend.

--=20
Mel




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