From owner-freebsd-questions@FreeBSD.ORG Fri Mar 5 22:58:24 2010 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 82099106564A for ; Fri, 5 Mar 2010 22:58:24 +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 47E398FC2B for ; Fri, 5 Mar 2010 22:58:23 +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 o25MwL59072800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 5 Mar 2010 16:58:22 -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.4/8.14.3) with ESMTP id o25MwLc5075457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 5 Mar 2010 16:58:21 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.4/8.14.3/Submit) id o25MwLYZ075454; Fri, 5 Mar 2010 16:58:21 -0600 (CST) (envelope-from dan) Date: Fri, 5 Mar 2010 16:58:20 -0600 From: Dan Nelson To: Peter Steele Message-ID: <20100305225818.GA12122@dan.emsphone.com> References: <7B9397B189EB6E46A5EE7B4C8A4BB7CB3A1A640C@MBX03.exg5.exghost.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7B9397B189EB6E46A5EE7B4C8A4BB7CB3A1A640C@MBX03.exg5.exghost.com> X-OS: FreeBSD 7.2-STABLE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: clamav-milter 0.95.3 at 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]); Fri, 05 Mar 2010 16:58:22 -0600 (CST) X-Scanned-By: MIMEDefang 2.45 Cc: "freebsd-questions@freebsd.org" Subject: Re: Calculating kernel/user/idle time 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: Fri, 05 Mar 2010 22:58:24 -0000 In the last episode (Mar 05), Peter Steele said: > What's the proper way to calculate kernel/user/idle time? I know the raw > values come from sysctl kern.cp_time, but these values need to be > "massaged" based on the number of CPUs and so on. Can someone explain > briefly what the algorithm is calculating the final percentages > representing these times. They shouldn't need to be massaged. Just sample the values at two intervals, and your percentages can be calculated by dividing each delta by the sum of the deltas (since the sum equals the total CPU usage over the interval, by definition). If you want to calculate per-cpu usage, use the kern.cp_times sysctl instead. -- Dan Nelson dnelson@allantgroup.com