DragonFly BSD
DragonFly kernel List (threaded) for 2004-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: trouble getting memory and swap info

From: Sten Spans <sten@xxxxxxxxxxxxxxxx>
Date: Thu, 28 Oct 2004 02:17:03 +0200 (CEST)

On Wed, 27 Oct 2004, Glenn Johnson wrote:

I am trying to get gkrellm2 working on DragonFlyBSD.  I got it to
compile and run but it does not report the memory or swap.  Well,
actually, it does report them, its just that the values are 0.  I used
the src/usr.bin/top/machine.c and the xsysinfo dfport as a guide.  I am
not at my DragonFly system at the moment but basically what I did was to
set the vmmeter and vmstats structures as defined in vmmeter.h and used
in top/machine.c, using sysctlbyname to get the information.  Is there
something else I need to do?

On fbsd4 and probably dragonfly a program needs setgid kmem for certain memory statistics, which is why top works and gkrellm doesn't.

kvm_open/kvm_getswapinfo have been fixed/changed in fbsd5.

#if FBSD4
	kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
	kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open");

Memory statistics should be available in sysctl,
hw.availpages and vm.stats.vm.v_*, no perms needed.

I wouldn't use a "/proc" filesystems to "fix" this,
they may be great for shell, but C code gets quite messy
dealing with them. The fact that every "/proc" filesystem
in existence has had serious root holes doesn't help

( /proc/meminfo has changed between linux 2.4 and 2.6,
  make sure you support each version :)

Sten Spans

"There is a crack in everything, that's how the light gets in."
Leonard Cohen - Anthem

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]