From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 4 16:41:11 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 159408B0 for ; Mon, 4 Aug 2014 16:41:11 +0000 (UTC) Received: from systemdatarecorder.org (mail.systemdatarecorder.org [54.246.96.61]) (using TLSv1.1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "localhost" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id A403B2876 for ; Mon, 4 Aug 2014 16:41:09 +0000 (UTC) Received: from nereid (84-253-211-213.bb.dnainternet.fi [84.253.211.213]) (authenticated bits=0) by systemdatarecorder.org (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id s74GcPbg029395 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 4 Aug 2014 16:38:26 GMT Date: Mon, 4 Aug 2014 19:40:36 +0300 From: Stefan Parvu To: David Wolfskill Subject: Re: cpu utilization break down via sysctl Message-Id: <20140804194036.be325ee5822bbcb2623db358@systemdatarecorder.org> In-Reply-To: <20140804162056.GP1228@albert.catwhisker.org> References: <20140804190923.95fec6a00d175ffee89c4af5@systemdatarecorder.org> <20140804162056.GP1228@albert.catwhisker.org> Organization: systemdatarecorder.org X-Mailer: Sylpheed 3.4.2 (GTK+ 2.24.22; amd64-portbld-freebsd11.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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:41:11 -0000 > 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 planning in using BSD::Sysctl to fetch all needed values. > kern.cp_time output is an ordered quintuple showing (aggregate) CPU > counters for: > > * user > * nice > * system > * interrupt > * idle > I see. Cool. If I understood right these will be the break down for 4 vcpu system: $ sysctl kern.cp_times kern.cp_times: 28845 2060 22253 1805 1197920 27677 1477 22399 2109 1199180 32342 1649 19499 894 1198458 29670 1678 20324 1471 1199699 which maps to: time1: cpu0: user_28845: nice_2060: system_22253: intr_1805: idle_1197920 time1: cpu1: user_27677: nice_1477 system_22399 intr_2109: idle_1199180 time1: cpu2: user_32342: nice_1649: system_19499: intr_894: idle_1198458 time1: cpu3 user_29670: nice_1678: system_20324: intr_1471: idle_1199699 > 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. Right I need to do delta between 2 readings to get the correct values. Same as in KSTAT in Solaris perl interface. One more check here: CPU_Utilization = User + System + Nice + Intr ? Many thanks indeed. I need to experiment with these ... -- Stefan Parvu