Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 2014 09:20:56 -0700
From:      David Wolfskill <david@catwhisker.org>
To:        Stefan Parvu <sparvu@systemdatarecorder.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: cpu utilization break down via sysctl
Message-ID:  <20140804162056.GP1228@albert.catwhisker.org>
In-Reply-To: <20140804190923.95fec6a00d175ffee89c4af5@systemdatarecorder.org>
References:  <20140804190923.95fec6a00d175ffee89c4af5@systemdatarecorder.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



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