summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorcube <cube@pkgsrc.org>2004-06-07 17:01:49 +0000
committercube <cube@pkgsrc.org>2004-06-07 17:01:49 +0000
commit8f1a13cda2b7f03eef2506329ae2e6724371a696 (patch)
treeba5116b9c95ab547d71cb9bc426d9e5935d43705 /sysutils
parentbdc9447037b94a2304b96c566583f581287d98da (diff)
downloadpkgsrc-8f1a13cda2b7f03eef2506329ae2e6724371a696.tar.gz
Make a few krells use sysctl() instead of grovelling kernel memory.
Mem and Proc krells by Simon Burge, Disks by myself. Restore setgid kmem for gkrellm and gkrellmd because of 'Internet' krell, which is now the only one needing libkvm on NetBSD. Bump PKGREVISION for both package.
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/gkrellm-server/Makefile6
-rw-r--r--sysutils/gkrellm/Makefile6
-rw-r--r--sysutils/gkrellm/distinfo8
-rw-r--r--sysutils/gkrellm/patches/patch-aa8
-rw-r--r--sysutils/gkrellm/patches/patch-ab235
-rw-r--r--sysutils/gkrellm/patches/patch-ac205
-rw-r--r--sysutils/gkrellm/patches/patch-ad209
7 files changed, 663 insertions, 14 deletions
diff --git a/sysutils/gkrellm-server/Makefile b/sysutils/gkrellm-server/Makefile
index a6e5096cbec..338eb6ad25e 100644
--- a/sysutils/gkrellm-server/Makefile
+++ b/sysutils/gkrellm-server/Makefile
@@ -1,6 +1,8 @@
-# $NetBSD: Makefile,v 1.5 2004/05/09 20:47:04 fredb Exp $
+# $NetBSD: Makefile,v 1.6 2004/06/07 17:01:50 cube Exp $
.include "../../sysutils/gkrellm/Makefile.common"
+PKGREVISION= 1
+
GKRELLM_PKGBASE= gkrellm-server
COMMENT= Monitoring daemon remotely accessible by a GKrellM client
DEPENDS+= gkrellm-share-${GKRELLM_VERSION}:../../sysutils/gkrellm-share
@@ -13,7 +15,7 @@ CONF_FILES= ${PREFIX}/share/examples/gkrellm-server/gkrellmd.conf ${PREFIX}/etc
.include "../../mk/bsd.prefs.mk"
-.if (${OPSYS} == "FreeBSD" || ${OPSYS} == "OpenBSD")
+.if (${OPSYS} == "FreeBSD" || ${OPSYS} == "OpenBSD" || ${OPSYS} == "NetBSD")
SPECIAL_PERMS+= ${PREFIX}/bin/gkrellmd ${ROOT_USER} kmem 2711
.endif
diff --git a/sysutils/gkrellm/Makefile b/sysutils/gkrellm/Makefile
index ce7b5291992..37ad0ff5003 100644
--- a/sysutils/gkrellm/Makefile
+++ b/sysutils/gkrellm/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.35 2004/05/09 20:47:04 fredb Exp $
+# $NetBSD: Makefile,v 1.36 2004/06/07 17:01:50 cube Exp $
.include "Makefile.common"
-PKGREVISION= # defined
+PKGREVISION= 1
GKRELLM_PKGBASE= gkrellm
WRKSRC= ${GKRELLM_SRCDIR}
@@ -16,7 +16,7 @@ USE_PKGINSTALL= YES
.include "../../mk/bsd.prefs.mk"
-.if (${OPSYS} == "FreeBSD" || ${OPSYS} == "OpenBSD")
+.if (${OPSYS} == "FreeBSD" || ${OPSYS} == "OpenBSD" || ${OPSYS} == "NetBSD")
SPECIAL_PERMS+= ${PREFIX}/bin/gkrellm ${ROOT_USER} kmem 2711
.endif
diff --git a/sysutils/gkrellm/distinfo b/sysutils/gkrellm/distinfo
index f4c862d727c..9e7e352fadd 100644
--- a/sysutils/gkrellm/distinfo
+++ b/sysutils/gkrellm/distinfo
@@ -1,6 +1,8 @@
-$NetBSD: distinfo,v 1.24 2004/06/05 18:57:37 cube Exp $
+$NetBSD: distinfo,v 1.25 2004/06/07 17:01:50 cube Exp $
SHA1 (gkrellm-2.2.1.tar.bz2) = 4a4d296a61307b3a0b93da035c07e301ed474dbc
Size (gkrellm-2.2.1.tar.bz2) = 663952 bytes
-SHA1 (patch-aa) = 6335a5cb00a535c34c35fad47db077cb8db51dfe
-SHA1 (patch-ab) = 000f1c383c6fa7d010cb22c8481130800d4375c6
+SHA1 (patch-aa) = e7d7dc8f3189632a8a0855c3fc39479482407cc4
+SHA1 (patch-ab) = 90359656530804804bf231cbde3d1c38dab559a7
+SHA1 (patch-ac) = 8890d5a5e8eaf21508a1bf91de788183fd6f7a75
+SHA1 (patch-ad) = c33319783a40ad64f43015200047656efc1bcdb3
diff --git a/sysutils/gkrellm/patches/patch-aa b/sysutils/gkrellm/patches/patch-aa
index a22d2788017..1bea27ef41b 100644
--- a/sysutils/gkrellm/patches/patch-aa
+++ b/sysutils/gkrellm/patches/patch-aa
@@ -1,8 +1,8 @@
-$NetBSD: patch-aa,v 1.13 2004/05/09 22:04:30 fredb Exp $
+$NetBSD: patch-aa,v 1.14 2004/06/07 17:01:50 cube Exp $
---- src/sysdeps/bsd-common.c.orig 2004-01-13 13:32:34.000000000 -0600
+--- src/sysdeps/bsd-common.c.orig 2004-05-01 19:46:38.000000000 +0200
+++ src/sysdeps/bsd-common.c
-@@ -255,7 +255,11 @@
+@@ -255,7 +255,11 @@ void
gkrellm_sys_fs_get_mounts_list(void)
{
gchar *s, *dev, *dir, *type;
@@ -14,7 +14,7 @@ $NetBSD: patch-aa,v 1.13 2004/05/09 22:04:30 fredb Exp $
gint mntsize, i;
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
-@@ -281,12 +285,24 @@
+@@ -281,12 +285,24 @@ gkrellm_sys_fs_get_mounts_list(void)
void
gkrellm_sys_fs_get_fsusage(gpointer fs, gchar *dir)
{
diff --git a/sysutils/gkrellm/patches/patch-ab b/sysutils/gkrellm/patches/patch-ab
index b8eedc42737..88933de7ded 100644
--- a/sysutils/gkrellm/patches/patch-ab
+++ b/sysutils/gkrellm/patches/patch-ab
@@ -1,8 +1,168 @@
-$NetBSD: patch-ab,v 1.10 2004/06/05 18:57:37 cube Exp $
+$NetBSD: patch-ab,v 1.11 2004/06/07 17:01:50 cube Exp $
--- src/sysdeps/netbsd.c.orig 2004-05-01 19:46:38.000000000 +0200
+++ src/sysdeps/netbsd.c
-@@ -295,7 +295,7 @@ gkrellm_sys_sensors_init(void)
+@@ -109,41 +109,35 @@ get_ncpus(void)
+ #include <sys/proc.h>
+ #include <sys/sysctl.h>
+ #include <uvm/uvm_extern.h>
+-#include <kvm.h>
+
+ #include <utmp.h>
+
+-static struct nlist nl[] = {
+-#define X_UVM_EXP 0
+- { "_uvmexp" },
+- { NULL }
+-};
+-
+-extern kvm_t *kvmd;
+-
+ void
+ gkrellm_sys_proc_read_data(void)
+ {
+- static int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL };
++ int mib[6];
+ double avenrun;
+- guint n_forks = 0, n_processes = 0;
+- struct uvmexp *uvmexp;
+- int len, i;
+-
+- if (sysctl(mib, 3, NULL, &len, NULL, 0) >= 0) {
+- n_processes = len / sizeof(struct kinfo_proc);
+- }
+-
+- /* get name list if it is not done yet */
+- if (kvmd == NULL) return;
+- if (nl[0].n_type == 0) kvm_nlist(kvmd, nl);
+-
+- if (nl[0].n_type != 0) {
+- uvmexp = (struct uvmexp *)nl[X_UVM_EXP].n_value;
+- if (kvm_read(kvmd, (u_long)&uvmexp->forks, &i, sizeof(i)) == sizeof(i))
+- n_forks = i;
++ guint n_forks = 0, n_processes = 0;
++ struct uvmexp_sysctl uvmexp;
++ size_t size;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC2;
++ mib[2] = KERN_PROC_ALL;
++ mib[3] = 0;
++ mib[4] = sizeof(struct kinfo_proc2);
++ mib[5] = 0;
++ if (sysctl(mib, 6, NULL, &size, NULL, 0) >= 0) {
++ n_processes = size / sizeof(struct kinfo_proc2);
+ }
+
++ mib[0] = CTL_VM;
++ mib[1] = VM_UVMEXP2;
++ size = sizeof(uvmexp);
++ if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) >= 0) {
++ n_forks = uvmexp.forks;
++ }
++
+ if (getloadavg(&avenrun, 1) <= 0)
+ avenrun = 0;
+ gkrellm_proc_assign_data(n_processes, 0, n_forks, avenrun);
+@@ -183,6 +177,97 @@ gkrellm_sys_proc_init(void)
+
+
+ /* ===================================================================== */
++/* Memory/Swap monitor interface */
++
++#include <sys/vmmeter.h>
++#include <sys/sysctl.h>
++#include <uvm/uvm_extern.h>
++#include <kvm.h>
++
++
++void
++gkrellm_sys_mem_read_data(void)
++{
++ int mib[2];
++ guint64 total, used, free, shared, buffers, cached;
++ struct vmtotal vmt;
++ struct uvmexp_sysctl uvmexp;
++ size_t len;
++
++ mib[0] = CTL_VM;
++ mib[1] = VM_METER;
++ len = sizeof(vmt);
++ if (sysctl(mib, 2, &vmt, &len, NULL, 0) < 0)
++ memset(&vmt, 0, sizeof(vmt));
++
++ mib[0] = CTL_VM;
++ mib[1] = VM_UVMEXP2;
++ len = sizeof(uvmexp);
++ if (sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0)
++ memset(&uvmexp, 0, sizeof(uvmexp));
++
++ total = uvmexp.npages << uvmexp.pageshift;
++
++ /* not sure of what must be computed */
++ free = (uvmexp.inactive + uvmexp.free) << uvmexp.pageshift;
++ shared = vmt.t_rmshr << uvmexp.pageshift;
++
++ /* can't use "uvmexp.active << uvmexp.pageshift" here because the
++ * display for "free" uses "total - used" which is very wrong. */
++ used = total - free;
++
++ /* don't know how to get those values */
++ buffers = 0;
++ cached = 0;
++
++ gkrellm_mem_assign_data(total, used, free, shared, buffers, cached);
++
++}
++
++void
++gkrellm_sys_swap_read_data(void)
++{
++ static int pgout, pgin;
++ int mib[2];
++ struct uvmexp_sysctl uvmexp;
++ size_t len;
++ static gulong swapin = 0, swapout = 0;
++ guint64 swap_total, swap_used;
++
++ mib[0] = CTL_VM;
++ mib[1] = VM_UVMEXP2;
++ len = sizeof(uvmexp);
++ if (sysctl(mib, 2, &uvmexp, &len, NULL, 0) < 0)
++ memset(&uvmexp, 0, sizeof(uvmexp));
++
++ /* show only the pages located on the disk and not in memory */
++ swap_total = (guint64) (uvmexp.swpages << uvmexp.pageshift);
++ swap_used = (guint64) (uvmexp.swpgonly << uvmexp.pageshift);
++
++ /* For page in/out operations, uvmexp struct doesn't seem to be reliable */
++
++ /* if the number of swapped pages that are in memory (inuse - only) is
++ * greater that the previous value (pgin), we count this a "page in" */
++ if (uvmexp.swpginuse - uvmexp.swpgonly > pgin)
++ swapin += uvmexp.swpginuse - uvmexp.swpgonly - pgin;
++ pgin = uvmexp.swpginuse - uvmexp.swpgonly;
++
++ /* same for page out */
++ if (uvmexp.swpgonly > pgout)
++ swapout += uvmexp.swpgonly - pgout;
++ pgout = uvmexp.swpgonly;
++
++ gkrellm_swap_assign_data(swap_total, swap_used, swapin, swapout);
++}
++
++gboolean
++gkrellm_sys_mem_init(void)
++ {
++ return TRUE;
++ }
++
++
++/* ===================================================================== */
+ /* Sensor monitor interface */
+
+ /* Tables of voltage correction factors and offsets derived from the
+@@ -295,7 +380,7 @@ gkrellm_sys_sensors_init(void)
int fd; /* file desc. for /dev/sysmon */
int id = 0; /* incremented for each sensor */
int type;
@@ -11,3 +171,74 @@ $NetBSD: patch-ab,v 1.10 2004/06/05 18:57:37 cube Exp $
gboolean found_sensors = FALSE;
/* check if some sensor is configured */
+@@ -336,3 +421,70 @@ gkrellm_sys_sensors_init(void)
+ return found_sensors;
+ }
+
++
++/* ===================================================================== */
++/* Disk monitor interface */
++
++#include <sys/dkstat.h>
++#include <sys/disk.h>
++
++gboolean
++gkrellm_sys_disk_init(void)
++{
++ int mib[3] = { CTL_HW, HW_DISKSTATS, sizeof(struct disk_sysctl) };
++ size_t size;
++
++ /* Just test if the sysctl call works */
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1)
++ return (FALSE);
++
++ return (TRUE);
++}
++
++void
++gkrellm_sys_disk_read_data(void)
++{
++ int i, n_disks, mib[3] = { CTL_HW, HW_DISKSTATS, sizeof(struct disk_sysctl) };
++ size_t size;
++ char buf[20];
++ guint64 rbytes, wbytes;
++ struct disk_sysctl *dk_drives;
++
++ if (sysctl(mib, 3, NULL, &size, NULL, 0) == -1)
++ return;
++ dk_drives = malloc(size);
++ if (dk_drives == NULL)
++ return;
++ n_disks = size / sizeof(struct disk_sysctl);
++
++ if (sysctl(mib, 3, dk_drives, &size, NULL, 0) == -1)
++ return;
++
++ for (i = 0; i < n_disks; i++) {
++#if __NetBSD_Version__ >= 106110000
++ rbytes = dk_drives[i].dk_rbytes;
++ wbytes = dk_drives[i].dk_wbytes;
++#else
++ rbytes = dk_drives[i].dk_bytes;
++ wbytes = 0;
++#endif
++
++ snprintf(buf, sizeof(buf), "%s%c", _("Disk"), 'A' + i);
++ gkrellm_disk_assign_data_by_name(buf, rbytes, wbytes);
++ }
++
++ free(dk_drives);
++}
++
++gchar *
++gkrellm_sys_disk_name_from_device(gint device_number, gint unit_number,
++ gint *order)
++ {
++ return NULL; /* disk data by device not implemented */
++ }
++
++gint
++gkrellm_sys_disk_order_from_name(gchar *name)
++ {
++ return -1; /* append disk charts as added */
++ }
diff --git a/sysutils/gkrellm/patches/patch-ac b/sysutils/gkrellm/patches/patch-ac
new file mode 100644
index 00000000000..889e211df78
--- /dev/null
+++ b/sysutils/gkrellm/patches/patch-ac
@@ -0,0 +1,205 @@
+$NetBSD: patch-ac,v 1.6 2004/06/07 17:01:50 cube Exp $
+
+--- src/sysdeps/openbsd.c.orig 2004-05-01 19:46:38.000000000 +0200
++++ src/sysdeps/openbsd.c
+@@ -170,6 +170,95 @@ gkrellm_sys_proc_init(void)
+
+
+ /* ===================================================================== */
++/* Memory/Swap monitor interface */
++
++#include <sys/vmmeter.h>
++#include <sys/sysctl.h>
++#include <uvm/uvm_extern.h>
++#include <kvm.h>
++
++static gulong swapin,
++ swapout;
++static guint64 swap_total,
++ swap_used;
++
++void
++gkrellm_sys_mem_read_data(void)
++{
++ static int mib[] = { CTL_VM, VM_METER };
++ static int pgout, pgin;
++ unsigned long total, used, x_used, free, shared, buffers, cached;
++ struct vmtotal vmt;
++ struct uvmexp uvmexp;
++ size_t len;
++ static struct nlist nl[] = {
++#define X_UVM_EXP 0
++ { "_uvmexp" },
++ { NULL }
++};
++
++
++ if (kvmd == NULL) return;
++
++ /* get the name list if it's not done yet */
++ if (nl[0].n_type == 0) kvm_nlist(kvmd, nl);
++
++ if (nl[0].n_type != 0)
++ if (kvm_read(kvmd, nl[X_UVM_EXP].n_value,
++ &uvmexp, sizeof(uvmexp)) != sizeof(uvmexp))
++ memset(&uvmexp, 0, sizeof(uvmexp));
++
++ if (sysctl(mib, 2, &vmt, &len, NULL, 0) < 0)
++ memset(&vmt, 0, sizeof(vmt));
++
++ total = (uvmexp.npages - uvmexp.wired) << uvmexp.pageshift;
++
++ /* not sure of what must be computed */
++ x_used = (uvmexp.active + uvmexp.inactive) << uvmexp.pageshift;
++ free = uvmexp.free << uvmexp.pageshift;
++ shared = vmt.t_rmshr << uvmexp.pageshift;
++
++ /* want to see only this in the chat. this could be changed */
++ used = uvmexp.active << uvmexp.pageshift;
++
++ /* don't know how to get those values */
++ buffers = 0;
++ cached = 0;
++
++ gkrellm_mem_assign_data(total, used, free, shared, buffers, cached);
++
++ /* show only the pages located on the disk and not in memory */
++ swap_total = (guint64) (uvmexp.swpages << uvmexp.pageshift);
++ swap_used = (guint64) (uvmexp.swpgonly << uvmexp.pageshift);
++
++ /* For page in/out operations, uvmexp struct doesn't seem to be reliable */
++
++ /* if the number of swapped pages that are in memory (inuse - only) is
++ * greater that the previous value (pgin), we count this a "page in" */
++ if (uvmexp.swpginuse - uvmexp.swpgonly > pgin)
++ swapin += uvmexp.swpginuse - uvmexp.swpgonly - pgin;
++ pgin = uvmexp.swpginuse - uvmexp.swpgonly;
++
++ /* same for page out */
++ if (uvmexp.swpgonly > pgout)
++ swapout += uvmexp.swpgonly - pgout;
++ pgout = uvmexp.swpgonly;
++}
++
++void
++gkrellm_sys_swap_read_data(void)
++ {
++ gkrellm_swap_assign_data(swap_total, swap_used, swapin, swapout);
++ }
++
++gboolean
++gkrellm_sys_mem_init(void)
++ {
++ return TRUE;
++ }
++
++
++/* ===================================================================== */
+ /* Sensor monitor interface - not implemented */
+
+ gboolean
+@@ -199,3 +288,104 @@ gkrellm_sys_sensors_init(void)
+ return FALSE;
+ }
+
++
++/* ===================================================================== */
++/* Disk monitor interface */
++
++#include <sys/dkstat.h>
++#include <sys/disk.h>
++#include <kvm.h>
++
++static struct nlist nl_disk[] = {
++#define X_DISK_COUNT 0
++ { "_disk_count" }, /* number of disks */
++#define X_DISKLIST 1
++ { "_disklist" }, /* TAILQ of disks */
++ { NULL },
++};
++
++static struct disk *dkdisks; /* kernel disk list head */
++
++extern kvm_t *kvmd;
++
++static gint n_disks;
++
++gchar *
++gkrellm_sys_disk_name_from_device(gint device_number, gint unit_number,
++ gint *order)
++ {
++ return NULL; /* disk data by device not implemented */
++ }
++
++gint
++gkrellm_sys_disk_order_from_name(gchar *name)
++ {
++ return -1; /* append disk charts as added */
++ }
++
++
++void
++gkrellm_sys_disk_read_data(void)
++{
++ struct disk d, *p;
++ gint i;
++ char buf[20];
++ guint64 rbytes, wbytes;
++
++ if (kvmd == NULL) return;
++ if (n_disks <= 0) return; /* computed by register_disks() */
++ if (nl_disk[0].n_type == 0) return; /* ditto. */
++
++ for (i = 0, p = dkdisks; i < n_disks; p = d.dk_link.tqe_next, ++i)
++ {
++ if (kvm_read(kvmd, (u_long)p, &d, sizeof(d)) == sizeof(d))
++ {
++ if (kvm_read(kvmd, (u_long)d.dk_name, buf, sizeof(buf)) != sizeof(buf))
++ /* fallback to default name if kvm_read failed */
++ sprintf(buf, "%s%c", _("Disk"), 'A' + i);
++
++ /* It seems impossible to get the read and write transfers
++ * separately. Its just a matter of choice to put the total in
++ * the rbytes member but I like the blue color so much.
++ */
++
++ /* Separate read/write stats were implemented in NetBSD 1.6K.
++ */
++
++#if __NetBSD_Version__ >= 106110000
++ rbytes = d.dk_rbytes;
++ wbytes = d.dk_wbytes;
++#else
++ rbytes = d.dk_bytes;
++ wbytes = 0;
++#endif
++
++ gkrellm_disk_assign_data_by_name(buf, rbytes, wbytes);
++ }
++ }
++}
++
++gboolean
++gkrellm_sys_disk_init(void)
++{
++ struct disklist_head head;
++
++
++ if (kvmd == NULL) return FALSE;
++
++ /* get disk count */
++ if (kvm_nlist(kvmd, nl_disk) >= 0 && nl_disk[0].n_type != 0)
++ if (kvm_read(kvmd, nl_disk[X_DISK_COUNT].n_value,
++ (char *)&n_disks, sizeof(n_disks)) != sizeof(n_disks))
++ n_disks = 0;
++
++ /* get first disk */
++ if (n_disks > 0) {
++ if (kvm_read(kvmd, nl_disk[X_DISKLIST].n_value,
++ &head, sizeof(head)) != sizeof(head))
++ n_disks = 0;
++
++ dkdisks = head.tqh_first;
++ }
++ return TRUE;
++}
diff --git a/sysutils/gkrellm/patches/patch-ad b/sysutils/gkrellm/patches/patch-ad
new file mode 100644
index 00000000000..ec50bbd1ec1
--- /dev/null
+++ b/sysutils/gkrellm/patches/patch-ad
@@ -0,0 +1,209 @@
+$NetBSD: patch-ad,v 1.1 2004/06/07 17:01:50 cube Exp $
+
+--- src/sysdeps/bsd-net-open.c.orig 2004-05-01 19:46:38.000000000 +0200
++++ src/sysdeps/bsd-net-open.c
+@@ -23,108 +23,6 @@
+
+
+ /* ===================================================================== */
+-/* Disk monitor interface */
+-
+-#include <sys/dkstat.h>
+-#include <sys/disk.h>
+-#include <kvm.h>
+-
+-static struct nlist nl_disk[] = {
+-#define X_DISK_COUNT 0
+- { "_disk_count" }, /* number of disks */
+-#define X_DISKLIST 1
+- { "_disklist" }, /* TAILQ of disks */
+- { NULL },
+-};
+-
+-static struct disk *dkdisks; /* kernel disk list head */
+-
+-extern kvm_t *kvmd;
+-
+-static gint n_disks;
+-
+-gchar *
+-gkrellm_sys_disk_name_from_device(gint device_number, gint unit_number,
+- gint *order)
+- {
+- return NULL; /* disk data by device not implemented */
+- }
+-
+-gint
+-gkrellm_sys_disk_order_from_name(gchar *name)
+- {
+- return -1; /* append disk charts as added */
+- }
+-
+-
+-void
+-gkrellm_sys_disk_read_data(void)
+-{
+- struct disk d, *p;
+- gint i;
+- char buf[20];
+- guint64 rbytes, wbytes;
+-
+- if (kvmd == NULL) return;
+- if (n_disks <= 0) return; /* computed by register_disks() */
+- if (nl_disk[0].n_type == 0) return; /* ditto. */
+-
+- for (i = 0, p = dkdisks; i < n_disks; p = d.dk_link.tqe_next, ++i)
+- {
+- if (kvm_read(kvmd, (u_long)p, &d, sizeof(d)) == sizeof(d))
+- {
+- if (kvm_read(kvmd, (u_long)d.dk_name, buf, sizeof(buf)) != sizeof(buf))
+- /* fallback to default name if kvm_read failed */
+- sprintf(buf, "%s%c", _("Disk"), 'A' + i);
+-
+- /* It seems impossible to get the read and write transfers
+- * separately. Its just a matter of choice to put the total in
+- * the rbytes member but I like the blue color so much.
+- */
+-
+- /* Separate read/write stats were implemented in NetBSD 1.6K.
+- */
+-
+-#if __NetBSD_Version__ >= 106110000
+- rbytes = d.dk_rbytes;
+- wbytes = d.dk_wbytes;
+-#else
+- rbytes = d.dk_bytes;
+- wbytes = 0;
+-#endif
+-
+- gkrellm_disk_assign_data_by_name(buf, rbytes, wbytes);
+- }
+- }
+-}
+-
+-gboolean
+-gkrellm_sys_disk_init(void)
+-{
+- struct disklist_head head;
+-
+-
+- if (kvmd == NULL) return FALSE;
+-
+- /* get disk count */
+- if (kvm_nlist(kvmd, nl_disk) >= 0 && nl_disk[0].n_type != 0)
+- if (kvm_read(kvmd, nl_disk[X_DISK_COUNT].n_value,
+- (char *)&n_disks, sizeof(n_disks)) != sizeof(n_disks))
+- n_disks = 0;
+-
+- /* get first disk */
+- if (n_disks > 0) {
+- if (kvm_read(kvmd, nl_disk[X_DISKLIST].n_value,
+- &head, sizeof(head)) != sizeof(head))
+- n_disks = 0;
+-
+- dkdisks = head.tqh_first;
+- }
+- return TRUE;
+-}
+-
+-
+-/* ===================================================================== */
+ /* Inet monitor interface */
+
+ #include "../inet.h"
+@@ -199,95 +97,6 @@ gkrellm_sys_inet_init(void)
+ }
+
+ /* ===================================================================== */
+-/* Memory/Swap monitor interface */
+-
+-#include <sys/vmmeter.h>
+-#include <sys/sysctl.h>
+-#include <uvm/uvm_extern.h>
+-#include <kvm.h>
+-
+-static gulong swapin,
+- swapout;
+-static guint64 swap_total,
+- swap_used;
+-
+-void
+-gkrellm_sys_mem_read_data(void)
+-{
+- static int mib[] = { CTL_VM, VM_METER };
+- static int pgout, pgin;
+- unsigned long total, used, x_used, free, shared, buffers, cached;
+- struct vmtotal vmt;
+- struct uvmexp uvmexp;
+- size_t len;
+- static struct nlist nl[] = {
+-#define X_UVM_EXP 0
+- { "_uvmexp" },
+- { NULL }
+-};
+-
+-
+- if (kvmd == NULL) return;
+-
+- /* get the name list if it's not done yet */
+- if (nl[0].n_type == 0) kvm_nlist(kvmd, nl);
+-
+- if (nl[0].n_type != 0)
+- if (kvm_read(kvmd, nl[X_UVM_EXP].n_value,
+- &uvmexp, sizeof(uvmexp)) != sizeof(uvmexp))
+- memset(&uvmexp, 0, sizeof(uvmexp));
+-
+- if (sysctl(mib, 2, &vmt, &len, NULL, 0) < 0)
+- memset(&vmt, 0, sizeof(vmt));
+-
+- total = (uvmexp.npages - uvmexp.wired) << uvmexp.pageshift;
+-
+- /* not sure of what must be computed */
+- x_used = (uvmexp.active + uvmexp.inactive) << uvmexp.pageshift;
+- free = uvmexp.free << uvmexp.pageshift;
+- shared = vmt.t_rmshr << uvmexp.pageshift;
+-
+- /* want to see only this in the chat. this could be changed */
+- used = uvmexp.active << uvmexp.pageshift;
+-
+- /* don't know how to get those values */
+- buffers = 0;
+- cached = 0;
+-
+- gkrellm_mem_assign_data(total, used, free, shared, buffers, cached);
+-
+- /* show only the pages located on the disk and not in memory */
+- swap_total = (guint64) (uvmexp.swpages << uvmexp.pageshift);
+- swap_used = (guint64) (uvmexp.swpgonly << uvmexp.pageshift);
+-
+- /* For page in/out operations, uvmexp struct doesn't seem to be reliable */
+-
+- /* if the number of swapped pages that are in memory (inuse - only) is
+- * greater that the previous value (pgin), we count this a "page in" */
+- if (uvmexp.swpginuse - uvmexp.swpgonly > pgin)
+- swapin += uvmexp.swpginuse - uvmexp.swpgonly - pgin;
+- pgin = uvmexp.swpginuse - uvmexp.swpgonly;
+-
+- /* same for page out */
+- if (uvmexp.swpgonly > pgout)
+- swapout += uvmexp.swpgonly - pgout;
+- pgout = uvmexp.swpgonly;
+-}
+-
+-void
+-gkrellm_sys_swap_read_data(void)
+- {
+- gkrellm_swap_assign_data(swap_total, swap_used, swapin, swapout);
+- }
+-
+-gboolean
+-gkrellm_sys_mem_init(void)
+- {
+- return TRUE;
+- }
+-
+-
+-/* ===================================================================== */
+ /* Battery monitor interface */
+ #include <sys/ioctl.h>
+