DragonFly kernel List (threaded) for 2004-10
Re: trouble getting memory and swap info
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?
kvm_open/kvm_getswapinfo have been fixed/changed in fbsd5.
On fbsd4 and probably dragonfly a program needs
setgid kmem for certain memory statistics, which is
why top works and gkrellm doesn't.
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 :)
"There is a crack in everything, that's how the light gets in."
Leonard Cohen - Anthem