From owner-freebsd-questions@FreeBSD.ORG Wed Nov 18 19:12:35 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 566F5106566B for ; Wed, 18 Nov 2009 19:12:35 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email1.allantgroup.com (email1.emsphone.com [199.67.51.115]) by mx1.freebsd.org (Postfix) with ESMTP id 1BEDA8FC1F for ; Wed, 18 Nov 2009 19:12:34 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email1.allantgroup.com (8.14.0/8.14.0) with ESMTP id nAIJCXn5094070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 18 Nov 2009 13:12:34 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id nAIJCXgo056988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 18 Nov 2009 13:12:33 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id nAIJCX6u056986; Wed, 18 Nov 2009 13:12:33 -0600 (CST) (envelope-from dan) Date: Wed, 18 Nov 2009 13:12:33 -0600 From: Dan Nelson To: cronfy Message-ID: <20091118191233.GC89004@dan.emsphone.com> References: <4B042C50.6060904@sprinthost.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B042C50.6060904@sprinthost.ru> X-OS: FreeBSD 7.2-STABLE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: ClamAV version 0.94.1, clamav-milter version 0.94.1 on email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Wed, 18 Nov 2009 13:12:34 -0600 (CST) X-Scanned-By: MIMEDefang 2.45 Cc: FreeBSD 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: Wed, 18 Nov 2009 19:12:35 -0000 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@allantgroup.com