summaryrefslogtreecommitdiff
path: root/sysutils/libgtop
diff options
context:
space:
mode:
authoryouri <youri@pkgsrc.org>2019-01-21 03:31:05 +0000
committeryouri <youri@pkgsrc.org>2019-01-21 03:31:05 +0000
commit6f74d42092cd946b2a8345632276df9b2ac608d6 (patch)
treec43c0f0ca1f68828aa411ae1b4b6aac8c8d92950 /sysutils/libgtop
parent0bca03e40cf985a712c9f8e74fbcaa31fbe2e199 (diff)
downloadpkgsrc-6f74d42092cd946b2a8345632276df9b2ac608d6.tar.gz
Implement multi-processor load calculations for NetBSD,
this fills the graphs in mate and gnome system monitors.
Diffstat (limited to 'sysutils/libgtop')
-rw-r--r--sysutils/libgtop/Makefile4
-rw-r--r--sysutils/libgtop/distinfo3
-rw-r--r--sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c85
3 files changed, 89 insertions, 3 deletions
diff --git a/sysutils/libgtop/Makefile b/sysutils/libgtop/Makefile
index b77ae079103..c2d2216c910 100644
--- a/sysutils/libgtop/Makefile
+++ b/sysutils/libgtop/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.57 2018/08/22 09:46:35 wiz Exp $
+# $NetBSD: Makefile,v 1.58 2019/01/21 03:31:05 youri Exp $
DISTNAME= libgtop-2.28.4
-PKGREVISION= 13
+PKGREVISION= 14
CATEGORIES= sysutils gnome
MASTER_SITES= ${MASTER_SITE_GNOME:=sources/libgtop/2.28/}
EXTRACT_SUFX= .tar.bz2
diff --git a/sysutils/libgtop/distinfo b/sysutils/libgtop/distinfo
index 9dd02f0e432..7cad3873669 100644
--- a/sysutils/libgtop/distinfo
+++ b/sysutils/libgtop/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.34 2018/05/28 15:16:39 youri Exp $
+$NetBSD: distinfo,v 1.35 2019/01/21 03:31:05 youri Exp $
SHA1 (libgtop-2.28.4.tar.bz2) = b6f002cc80a61dc0908dd96e0b543113a46bc4b7
RMD160 (libgtop-2.28.4.tar.bz2) = 96ac76aa409bbd202bedacd94df14cd549e10d6b
@@ -36,6 +36,7 @@ SHA1 (patch-dk) = c95e5aa709dff7685af03f19e830d15fd17c0315
SHA1 (patch-dl) = 9d6a44be02ec21d195076125c0cdfe5b51a0ab0a
SHA1 (patch-dm) = ef08973aecacb1fb69f258632dd36edfdafd8c50
SHA1 (patch-dn) = 66f66731a3abd1290f67d62f9ef654f68756bccb
+SHA1 (patch-sysdeps_bsd_cpu.c) = e6b2b1e90385340128505fcab1c5c4aa510e165a
SHA1 (patch-sysdeps_bsd_glibtop__machine.h) = 1682156e3cb21d335499e38b6b91b8c315f1b962
SHA1 (patch-sysdeps_bsd_netload.c) = d143e392982afdd095fd052f857bfca2319ac7e7
SHA1 (patch-sysdeps_bsd_procmap.c) = 8b65993423099040f20256ea8b3f797ecbca21b0
diff --git a/sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c b/sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c
new file mode 100644
index 00000000000..f6ca112c280
--- /dev/null
+++ b/sysutils/libgtop/patches/patch-sysdeps_bsd_cpu.c
@@ -0,0 +1,85 @@
+$NetBSD: patch-sysdeps_bsd_cpu.c,v 1.1 2019/01/21 03:31:06 youri Exp $
+
+Fix multi-processor cpu load calculations
+
+--- sysdeps/bsd/cpu.c.orig 2011-06-01 15:40:47.000000000 +0000
++++ sysdeps/bsd/cpu.c
+@@ -24,6 +24,8 @@
+ #include <glibtop/error.h>
+ #include <glibtop/cpu.h>
+
++#include <err.h>
++
+ #include <glibtop_suid.h>
+
+ #ifdef __NetBSD__
+@@ -84,6 +86,7 @@ glibtop_get_cpu_p (glibtop *server, glib
+ /* sysctl vars*/
+ struct clockinfo ci;
+ size_t length;
++ int ncpu, i = 0;
+
+ glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0);
+
+@@ -93,6 +96,10 @@ glibtop_get_cpu_p (glibtop *server, glib
+ if (server->sysdeps.cpu == 0)
+ return;
+
++ size_t len = sizeof(ncpu);
++ if (sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) < 0)
++ errx(1, "Failed to get hw.cpu\n");
++
+ #ifdef KERN_CP_TIME
+ length = sizeof (cpts);
+ if (sysctl (mib2, mib_length, cpts, &length, NULL, 0)) {
+@@ -125,18 +132,43 @@ glibtop_get_cpu_p (glibtop *server, glib
+ /* set iowait (really just interrupt) time */
+ buf->iowait = cpts [CP_INTR];
+
+- /* set frequency */
+- /*
+- FIXME -- is hz, tick, profhz or stathz wanted?
+- buf->frequency = sysctl("kern.clockrate", ...);
+-
+- struct clockinfo
+- */
+ buf->frequency = ci.hz;
++
+ /* set total */
+ buf->total = cpts [CP_USER] + cpts [CP_NICE]
+ + cpts [CP_SYS] + cpts [CP_IDLE];
+
++
++ u_int64_t *cp_times;
++ length = sizeof(cp_times[0]) * CPUSTATES * ncpu;
++ cp_times = g_malloc(length);
++ int mib[] = { CTL_KERN, KERN_CP_TIME };
++ if (sysctl (mib, 2, cp_times, &length, NULL, 0) < 0) {
++ g_free(cp_times);
++ errx(1,"Failed to get kern.cp_time\n");
++ }
++ for (i = 0; i < ncpu; i++) {
++ if (cp_times) {
++ int offset = i * CPUSTATES;
++ buf->xcpu_user[i] = cp_times[offset + CP_USER];
++ buf->xcpu_nice[i] = cp_times[offset + CP_NICE];
++ buf->xcpu_sys[i] = cp_times[offset + CP_SYS];
++ buf->xcpu_idle[i] = cp_times[offset + CP_IDLE];
++ buf->xcpu_irq[i] = cp_times[offset + CP_INTR];
++ } else {
++ buf->xcpu_user[i] = cpts[CP_USER] / ncpu;
++ buf->xcpu_nice[i] = cpts[CP_NICE] / ncpu;
++ buf->xcpu_sys[i] = cpts[CP_SYS] / ncpu;
++ buf->xcpu_idle[i] = cpts[CP_IDLE] / ncpu;
++ buf->xcpu_irq[i] = cpts[CP_INTR] / ncpu;
++ }
++ buf->xcpu_total[i] = buf->xcpu_user[i] + buf->xcpu_nice[i] \
++ + buf->xcpu_sys[i] + buf->xcpu_idle[i] \
++ + buf->xcpu_irq[i];
++ }
++
++ g_free(cp_times);
++
+ /* Set the flags last. */
+ buf->flags = _glibtop_sysdeps_cpu;
+ }