From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 3 18:07:41 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 116F316A417 for ; Thu, 3 Jan 2008 18:07:41 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (cl-162.ewr-01.us.sixxs.net [IPv6:2001:4830:1200:a1::2]) by mx1.freebsd.org (Postfix) with ESMTP id ADBF913C458 for ; Thu, 3 Jan 2008 18:07:40 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.1/8.13.8) with ESMTP id m03I7dJi030343; Thu, 3 Jan 2008 12:07:39 -0600 (CST) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.1/8.13.8/Submit) id m03I7dJc030342; Thu, 3 Jan 2008 12:07:39 -0600 (CST) (envelope-from brooks) Date: Thu, 3 Jan 2008 12:07:39 -0600 From: Brooks Davis To: Fernando Apestegu?a Message-ID: <20080103180739.GA30164@lor.one-eyed-alien.net> References: <1bd550a00801030926h7b3f0aaayfd04244a3305619c@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline In-Reply-To: <1bd550a00801030926h7b3f0aaayfd04244a3305619c@mail.gmail.com> User-Agent: Mutt/1.5.16 (2007-06-09) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (lor.one-eyed-alien.net [127.0.0.1]); Thu, 03 Jan 2008 12:07:39 -0600 (CST) Cc: freebsd-hackers@freebsd.org Subject: Re: Porting from Linux to FreeBSD (procfs question) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2008 18:07:41 -0000 --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 03, 2008 at 06:26:21PM +0100, Fernando Apestegu?a wrote: > Hi all, >=20 > I post my question in this list cause Ivan Voras (ivoras@freebsd.org) > suggested that here I could find more help. >=20 > I have an application written in C + Gtk + Glib that gathers > information from procfs under Linux. Now, I'm trying to port this > application to FreeBSD (I'm working with 7.0 RC1). >=20 > I've been pointed to get rid of the procfs stuff in the freebsd code > and use sysctl instead. However, I can't find some of the information > that is present under /proc in Linux. >=20 > I can only get for the CPU for instance some small bits of info in > "hw.model" but I can't get the cache size, supported extensions, etc. > I have the same problem with the memory (how much memory is cached, in > buffers, marked as dirty, etc...). >=20 > How can I get all that information? Could you point me to some source > I can look at? >=20 > Is this information (that I suppose it is known by the kernel) somehow > exported to userland? >=20 > Here is a small list of the information the Linux application is > available to show: >=20 > - CPU info: (vendor, model, clock speed, stepping, cache size, > supported extensions) See misc/cpuid for a port that extracts this from the CPU. To some extent it would be better if the kernel did this because it can better know which CPU it's on, but this does most of it. > - Memory: total, free, shared, cached, used in buffers, marked as dirty, = etc.. You can't get a perfect mapping do these because we have different virtual memory systems. The continued delusion that any of this is comparable between OSes is a pet peeve of mine. :) The sysutils/ganglia-monitor-core port does some of this (search for freebsd.c). > - Devices: list of block and char devices ls /dev :-) > - Filesystems loaded in the kernel lsvfs(1) reports this information. > - Network information (bytes sent and received, packets, errors, for each= NIC) See ganglia. > - Loaded modules (sizes of the modules, if they are used by other modules= =2E..) see kldstat(8) > - Some kernel parameters (max files per process, semaphores, etc...) > I've seen this is fully covered with sysctl. -- Brooks --opJtzjQTFsWo+cga Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFHfSRrXY6L6fI4GtQRArTqAKDGT7j6zEXRc/FeVFxDYVvTKmxhfwCglEZ2 rDf5EZP+XrvWgnfzq6C62Ls= =3tyV -----END PGP SIGNATURE----- --opJtzjQTFsWo+cga--