From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 4 16:21:05 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 28E8CF8F for ; Mon, 4 Aug 2014 16:21:05 +0000 (UTC) Received: from albert.catwhisker.org (mx.catwhisker.org [198.144.209.73]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D76CB25BA for ; Mon, 4 Aug 2014 16:21:04 +0000 (UTC) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.14.9/8.14.9) with ESMTP id s74GKuRm009532; Mon, 4 Aug 2014 09:20:56 -0700 (PDT) (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.14.9/8.14.9/Submit) id s74GKuAA009531; Mon, 4 Aug 2014 09:20:56 -0700 (PDT) (envelope-from david) Date: Mon, 4 Aug 2014 09:20:56 -0700 From: David Wolfskill To: Stefan Parvu Subject: Re: cpu utilization break down via sysctl Message-ID: <20140804162056.GP1228@albert.catwhisker.org> Mail-Followup-To: David Wolfskill , Stefan Parvu , freebsd-hackers@freebsd.org References: <20140804190923.95fec6a00d175ffee89c4af5@systemdatarecorder.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="eAnxKwVhzStH6fSc" Content-Disposition: inline In-Reply-To: <20140804190923.95fec6a00d175ffee89c4af5@systemdatarecorder.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Aug 2014 16:21:05 -0000 --eAnxKwVhzStH6fSc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 04, 2014 at 07:09:23PM +0300, Stefan Parvu wrote: > Hi, >=20 > Im trying to understand if there is a simple way, without writing C code,= to consume > sysctl interface via BSD::Sysctl or using sysctl(8) and output user, syst= em and idle=20 > across all CPUs from a running system ? Sure; I've done the data acquisition with sysctl & awk, then post-processed that with a bit of Perl. I wrote some code in R to generate graphs.... I did some similar stuff using RRDTool a whlie back. > Im trying to port sysrec [1] to FreeBSD and it seems a bit harder to find= the correct > approach. >=20 > Pointers, comments ? >=20 > [1] - http://www.systemdatarecorder.org/recording/sysrec.html > ... kern.cp_time output is an ordered quintuple showing (aggregate) CPU counters for: * user * nice * system * interrupt * idle CPU states. kern.cp_times output is the same information, but repeated for each core on the system. For each core (or the aggregate), you need to look at an interval. Get the differences for each of the 5 possible CPU states; the sum of those differences is the total of CPU resources available during that interval. It's then a fairly straightforward application of arithmetic to determine what proportion of that total is ascribable to each of the states. The only part I think of where things could get "interesting" is if you have one or more counters wrap around. Peace, david --=20 David H. Wolfskill david@catwhisker.org Taliban: Evil cowards with guns afraid of truth from a 14-year old girl. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --eAnxKwVhzStH6fSc Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJT37LnXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ4RThEMDY4QTIxMjc1MDZFRDIzODYzRTc4 QTY3RjlDOERFRjQxOTNCAAoJEIpn+cje9Bk7T9wP/jsS72wvAIR/mGJ5C+i5cn1O 2O/zv8gwS0nItPU/yHlUmfhriBqJKF7SPNCRTRulm4BDanVEUKkRyOi5FPdi8jbm SmT5w3EL2tA0elnPsjpAHn7X1OrE/DJPOt5ycnVc75QZ/xdmGqUATlr0LEcCk5F8 QZYUmhn56SiOcv7dWleVOXkKE7g8nHINqwjOYj3bbmjaNvDAdOwpruqxV8aZ+p4B S0nzEt2Qu8mKU2VWpbDCemT7J3rn4MYau1VdCBZZgKepu9ZVTqYYKPo+/dGVWXQU STbm7NL8KiHhrF+dbtSfnjQE45HoFXi0Q09wGoRYMZzFC0xahw1lb6gYVagHiAAD VE7EGjL1UXa4COYEks/t6C55JcemSGAFYbZMEZDdVRcSOSxcUur6oiI3mEXXKn/n HTgzbmb0glQjQzkClq/we4ZenlbPO2Hv3dmnO35aazGuyhJcd2gwszhIIWQfCqH/ 6n10FacacVllSWud0QxrmXdYiXXMDu47IYUKK+jMucJl8dI4XUv9hRQQOT+PTCCQ pVhVezPczIhE1LlHEdIjAZdgWtl1ofciEBjGwGSdxmltqpvTDgmU7sq1sZBwh8ys Uy1qhAngnfNXairu8tV0sefN6BEubkynpvzMoYJzoaxXZHY3zI3t6llcTdF9hA2a SF5/2CkPmR+kebIe/DMq =lVye -----END PGP SIGNATURE----- --eAnxKwVhzStH6fSc--