From owner-freebsd-questions@FreeBSD.ORG Fri Nov 20 02:37:42 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E4E4106568F for ; Fri, 20 Nov 2009 02:37:42 +0000 (UTC) (envelope-from mel.flynn+fbsd.questions@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id E49D18FC24 for ; Fri, 20 Nov 2009 02:37:41 +0000 (UTC) Received: from mx1.sbmail.office-on-the.net (mx1.sbmail.office-on-the.net [192.168.2.107]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id BDAF57E853 for ; Thu, 19 Nov 2009 17:37:40 -0900 (AKST) Received: from dspam.sbmail.office-on-the.net (mx1.sbmail.office-on-the.net [192.168.2.107]) by mx1.sbmail.office-on-the.net (Postfix) with SMTP id 40F29C2CB05 for ; Thu, 19 Nov 2009 17:37:40 -0900 (AKST) Received: from webmail.testbox.ath.cx (mx1.sbmail.office-on-the.net [192.168.2.107]) by mx1.sbmail.office-on-the.net (Postfix) with ESMTP id 62A52C2CB04; Thu, 19 Nov 2009 17:37:39 -0900 (AKST) MIME-Version: 1.0 Date: Thu, 19 Nov 2009 17:37:39 -0900 From: Mel Flynn To: cronfy In-Reply-To: <4B0579CE.2020203@sprinthost.ru> References: <4B042C50.6060904@sprinthost.ru> <5f09d2bccc69d1f101c5c22151ef0c05@sbmail.office-on-the.net> <4B0579CE.2020203@sprinthost.ru> Message-ID: X-Sender: mel.flynn+fbsd.questions@mailing.thruhere.net User-Agent: RoundCube Webmail/0.2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-DSPAM-Result: Innocent X-DSPAM-Processed: Thu Nov 19 17:37:39 2009 X-DSPAM-Confidence: 1.0000 X-DSPAM-Improbability: 1 in 98689407 chance of being spam X-DSPAM-Probability: 0.0023 X-DSPAM-Signature: 14,4b0600f342361709340808 X-DSPAM-Factors: 27, but, 0.40000, but, 0.40000, reports, 0.40000, e+last, 0.40000, friend, 0.40000, e, 0.40000, cronfy, 0.40000, >+stats, 0.40000, that+are, 0.40000, let's, 0.40000, producing+diffs, 0.40000, Is+it, 0.40000, References*<4B042C50.6060904+sprinthost.ru>, 0.40000, restriction, 0.40000, Like, 0.40000, list+of, 0.40000, stats+>, 0.40000, Content-Type*charset="UTF+8", 0.40000, 10, 0.40000, 10, 0.40000, On+Thu, 0.40000, radius+is, 0.40000, Received*webmail.testbox.ath.cx, 0.40000, a+wheel, 0.40000, saving, 0.40000, References*on, 0.40000, Subject*get+accounting, 0.40000 Cc: freebsd-questions@freebsd.org Subject: Re: get accounting info for running process X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2009 02:37:42 -0000 On Thu, 19 Nov 2009 20:01:02 +0300, cronfy 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