From owner-freebsd-hackers Sat Mar 11 9:26:29 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from grande.dcc.unicamp.br (grande.dcc.unicamp.br [143.106.7.8]) by hub.freebsd.org (Postfix) with ESMTP id 6E12737BC93; Sat, 11 Mar 2000 09:26:17 -0800 (PST) (envelope-from guazzibe@dcc.unicamp.br) Received: from amazonas.dcc.unicamp.br (amazonas.dcc.unicamp.br [143.106.7.11]) by grande.dcc.unicamp.br (8.9.3/8.9.3) with ESMTP id OAA07403; Sat, 11 Mar 2000 14:26:06 -0300 (EST) Received: from xingu.dcc.unicamp.br (xingu.dcc.unicamp.br [143.106.7.7]) by amazonas.dcc.unicamp.br (8.8.5/8.8.5) with ESMTP id OAA27391; Sat, 11 Mar 2000 14:26:03 -0300 (EST) Received: from localhost (guazzibe@localhost) by xingu.dcc.unicamp.br (8.8.5/8.8.5) with ESMTP id OAA06597; Sat, 11 Mar 2000 14:26:02 -0300 (EST) Date: Sat, 11 Mar 2000 14:26:02 -0300 (EST) From: Felipe Paulo Guazzi Bergo To: hackers@freebsd.org Cc: freebsd-hackers@freebsd.org Subject: Getting CPU usage in FreeBSD Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, I am the author of gPS (http://gps.seul.org) and I'm trying to finish the FreeBSD native poller. All I need now is a routine to get the CPU usage. My program needs it every quarter of second, so the loadavg value is not enough accurate for me. (the objective is the CPU/memory history window shown in the third screenshot at the website) I've already looked at the source of top but couldn't get much from there. On Linux this is what I do to get this value: Measure the number of scheduled jiffies (hundreths of second), measure elapsed time since last measurement, divide. What I need is a scheduler-oriented cpu usage poller. I have already found some symbols in the kernel that may provide this value, but I couldn't get them to scale in a closed range (when I though I got the correct factor, I got CPU usages of 1280 % and the like). I am using FreeBSD-3.4-RELEASE/i386 for development, and would like to code to be portable for the widest range of FreeBSD versions possible. Can someone help me with code or good reference ? Thanks, ......................................................................... Felipe Paulo Guazzi Bergo, undergradute in Computer Engineering guazzibe@dcc.unicamp.br || bergo@seul.org || bergo@linuxstart.com Unicamp - Campinas - SP - Brazil - Earth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message