cpu utilization break down via sysctl
David Wolfskill
david at catwhisker.org
Mon Aug 4 16:21:05 UTC 2014
On Mon, Aug 04, 2014 at 07:09:23PM +0300, Stefan Parvu wrote:
> Hi,
>
> 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, system and idle
> 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.
>
> Pointers, comments ?
>
> [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
--
David H. Wolfskill david at 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 949 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20140804/c7dd4e51/attachment.sig>
More information about the freebsd-hackers
mailing list