Porting from Linux to FreeBSD (procfs question)

Brooks Davis brooks at freebsd.org
Thu Jan 3 10:07:41 PST 2008


On Thu, Jan 03, 2008 at 06:26:21PM +0100, Fernando Apestegu?a wrote:
> Hi all,
> 
> I post my question in this list cause Ivan Voras (ivoras at freebsd.org)
> suggested that here I could find more help.
> 
> 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).
> 
> 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.
> 
> 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...).
> 
> How can I get all that information? Could you point me to some source
> I can look at?
> 
> Is this information (that I suppose it is known by the kernel) somehow
> exported to userland?
> 
> Here is a small list of the information the Linux application is
> available to show:
> 
> - 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...)

see kldstat(8)

> - Some kernel parameters (max files per process, semaphores, etc...)
> I've seen this is fully covered with sysctl.

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080103/f4f333c1/attachment.pgp


More information about the freebsd-hackers mailing list