From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 2 13:52:02 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 68AB916A4CE for ; Fri, 2 Apr 2004 13:52:02 -0800 (PST) Received: from paris.ensmp.fr (paris.ensmp.fr [194.214.158.200]) by mx1.FreeBSD.org (Postfix) with ESMTP id CCD7B43D49 for ; Fri, 2 Apr 2004 13:52:01 -0800 (PST) (envelope-from martins@saci.ensmp.fr) Received: from saci.ensmp.fr (saci [194.214.158.176]) by paris.ensmp.fr (8.12.10/8.12.9/JMMC) with ESMTP id i32LpIT1005676; Fri, 2 Apr 2004 23:51:18 +0200 (MEST) Received: (from martins@localhost) by saci.ensmp.fr (8.12.11/8.12.10/Submit) id i32LpIw5009567; Fri, 2 Apr 2004 23:51:18 +0200 (CEST) From: Jose Marcio Martins da Cruz Message-Id: <200404022151.i32LpIw5009567@saci.ensmp.fr> To: dnelson@allantgroup.com (Dan Nelson) Date: Fri, 2 Apr 2004 23:51:18 +0200 (CEST) In-Reply-To: <20040402214012.GA49311@dan.emsphone.com> from "Dan Nelson" at Apr 02, 2004 03:40:12 PM X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at paris with ID 406DE056.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Mailman-Approved-At: Sat, 03 Apr 2004 05:14:09 -0800 cc: Dag-Erling Smorgrav cc: Mark cc: Jose Marcio Martins da Cruz cc: freebsd-hackers@freebsd.org Subject: Re: Pointers about CPU load measuring X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Apr 2004 21:52:02 -0000 > > In the last episode (Apr 02), Mark said: > > Dan Nelson wrote: > > >>> Someone can send some pointers on how to measure global CPU load > > >>> under FreeBSD from a C program ? I'm looking for values for > > >>> idle/kernel/user, in a similar way as does top. Is there any > > >>> pointer or doc ?. I'd like to avoir browsing top code. > > >> > > >> Use sysctlbyname(3) to retrieve vm.loadavg, which is a struct > > >> loadavg (defined in ) > > > > > > Actually the kern.cp_time variable might be better if you want > > > idle/kernel/user values. > > > > I current let snmpd do the job. Is that as accurate as manually > > reading the kern.cp_time variable? > > If you're talking about enterprises.ucdavis.systemStats, then yes. > Snmpd digs directly into /dev/kmem instead of using sysctl (so it can > run on older kernels that didn't provide the sysctl variable), but the > values are the same. enterprises.ucdavis.laTable is populated from the > vm.loadavg sysctl variable. If I'm not wrong, loadavg gives the mean number of processes in the run queue averaged on 1, 5 and 15 minutes. This gives an idea of system load but lacks precision. It seems to me that kern.cp_time counters is a better metrics of CPU load. > > -- > Dan Nelson > dnelson@allantgroup.com >