Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jan 2008 12:07:39 -0600
From:      Brooks Davis <brooks@freebsd.org>
To:        Fernando Apestegu?a <fernando.apesteguia@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Porting from Linux to FreeBSD (procfs question)
Message-ID:  <20080103180739.GA30164@lor.one-eyed-alien.net>
In-Reply-To: <1bd550a00801030926h7b3f0aaayfd04244a3305619c@mail.gmail.com>
References:  <1bd550a00801030926h7b3f0aaayfd04244a3305619c@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080103180739.GA30164>