pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc Make a few krells use sysctl() instead of grovelling k...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/6d6c0ba13126
branches:  trunk
changeset: 476361:6d6c0ba13126
user:      cube <cube%pkgsrc.org@localhost>
date:      Mon Jun 07 17:01:49 2004 +0000

description:
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:

 doc/CHANGES                       |    4 +-
 sysutils/gkrellm-server/Makefile  |    6 +-
 sysutils/gkrellm/Makefile         |    6 +-
 sysutils/gkrellm/distinfo         |    8 +-
 sysutils/gkrellm/patches/patch-aa |    8 +-
 sysutils/gkrellm/patches/patch-ab |  235 +++++++++++++++++++++++++++++++++++++-
 sysutils/gkrellm/patches/patch-ac |  205 +++++++++++++++++++++++++++++++++
 sysutils/gkrellm/patches/patch-ad |  209 +++++++++++++++++++++++++++++++++
 8 files changed, 666 insertions(+), 15 deletions(-)

diffs (truncated from 769 to 300 lines):

diff -r eca7e3a90db9 -r 6d6c0ba13126 doc/CHANGES
--- a/doc/CHANGES       Mon Jun 07 14:47:34 2004 +0000
+++ b/doc/CHANGES       Mon Jun 07 17:01:49 2004 +0000
@@ -1,4 +1,4 @@
-$NetBSD: CHANGES,v 1.6181 2004/06/07 14:47:34 minskim Exp $
+$NetBSD: CHANGES,v 1.6182 2004/06/07 17:01:49 cube Exp $
 
 Changes to the packages collection and infrastructure in 2004:
 
@@ -2841,3 +2841,5 @@
        Updated xchat-systray-integration to 2.4.5 [minskim 2004-06-07]
        Updated gnumeric to 1.2.12nb1 [jmmv 2004-06-07]
        Updated xisp to 2.7p1 [minskim 2004-06-07]
+       Updated gkrellm to 2.2.1nb1 [cube 2004-06-07]
+       Updated gkrellm-server to 2.2.1nb1 [cube 2004-06-07]
diff -r eca7e3a90db9 -r 6d6c0ba13126 sysutils/gkrellm-server/Makefile
--- a/sysutils/gkrellm-server/Makefile  Mon Jun 07 14:47:34 2004 +0000
+++ b/sysutils/gkrellm-server/Makefile  Mon Jun 07 17:01:49 2004 +0000
@@ -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 @@
 
 .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 -r eca7e3a90db9 -r 6d6c0ba13126 sysutils/gkrellm/Makefile
--- a/sysutils/gkrellm/Makefile Mon Jun 07 14:47:34 2004 +0000
+++ b/sysutils/gkrellm/Makefile Mon Jun 07 17:01:49 2004 +0000
@@ -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 @@
 
 .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 -r eca7e3a90db9 -r 6d6c0ba13126 sysutils/gkrellm/distinfo
--- a/sysutils/gkrellm/distinfo Mon Jun 07 14:47:34 2004 +0000
+++ b/sysutils/gkrellm/distinfo Mon Jun 07 17:01:49 2004 +0000
@@ -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 -r eca7e3a90db9 -r 6d6c0ba13126 sysutils/gkrellm/patches/patch-aa
--- a/sysutils/gkrellm/patches/patch-aa Mon Jun 07 14:47:34 2004 +0000
+++ b/sysutils/gkrellm/patches/patch-aa Mon Jun 07 17:01:49 2004 +0000
@@ -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 @@
        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 -r eca7e3a90db9 -r 6d6c0ba13126 sysutils/gkrellm/patches/patch-ab
--- a/sysutils/gkrellm/patches/patch-ab Mon Jun 07 14:47:34 2004 +0000
+++ b/sysutils/gkrellm/patches/patch-ab Mon Jun 07 17:01:49 2004 +0000
@@ -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 @@
     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);
++}
++



Home | Main Index | Thread Index | Old Index