Re: Porting from Linux to FreeBSD (procfs question)



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@xxxxxxxxxxx)
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

Attachment: pgpOYryI9D02W.pgp
Description: PGP signature



Relevant Pages

  • Re: X performance
    ... >> under my linux X. ... But saving memory or CPU cycles are ... The memory it nominally consumes will be reclaimed pretty soon as it ... Red Hat 8or 9 may have increased memory needs. ...
    (comp.os.linux.misc)
  • Re: Much Anticipated?
    ... And, Windoze gets bigger, slower, and buggier at every ... I've seen performance for CPU, memory, and disk access go like ... Sorry, but for me, Linux is still not ready for prime time on ...
    (microsoft.public.windowsxp.general)
  • Re: [FC4] System locks up when booting installation DVD
    ... be of help if you'd describe your system (motherboard make, hard drives, ... Doesn't matter whether I boot 'linux' or 'linux text'. ... CPU: Athlon XP ... Memory: 256 MB ...
    (Fedora)
  • Re: RosAsm Bliss, and NASM Bliss
    ... The memorymanager contains only 2 calls to the API. ... You have to roll your own memory management under Linux. ... So the port should be not that hard for someone who knows Linux. ...
    (alt.lang.asm)
  • Re: How analyze the system bottleneck using shell tools
    ... Linux Debian system in which there is a bbs system running there. ... You have to determine if it's I/O, memory, network or CPU. ... Look at the CPU, and see if the CPU is busy with system, user or idle. ...
    (comp.unix.shell)