summaryrefslogtreecommitdiff
path: root/devel
diff options
context:
space:
mode:
authorJoe Marcus Clarke <marcus@FreeBSD.org>2009-04-12 05:47:11 +0000
committerJoe Marcus Clarke <marcus@FreeBSD.org>2009-04-12 05:47:11 +0000
commit7120934130f30e64a1371cfff5844f184fda8264 (patch)
treef5b24d0208d9a99d5976c10db877287a23f3db49 /devel
parent- USE_APACHE=yes is deprecated (diff)
Add support for per-CPU utilization stats.
Notes
Notes: svn path=/head/; revision=232181
Diffstat (limited to 'devel')
-rw-r--r--devel/libgtop/Makefile1
-rw-r--r--devel/libgtop/files/patch-sysdeps_freebsd_cpu.c66
2 files changed, 67 insertions, 0 deletions
diff --git a/devel/libgtop/Makefile b/devel/libgtop/Makefile
index c10af654cf46..829b0c930f31 100644
--- a/devel/libgtop/Makefile
+++ b/devel/libgtop/Makefile
@@ -8,6 +8,7 @@
PORTNAME= libgtop
PORTVERSION= 2.26.0
+PORTREVISION= 1
CATEGORIES= devel gnome
MASTER_SITES= GNOME
DIST_SUBDIR= gnome2
diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_cpu.c b/devel/libgtop/files/patch-sysdeps_freebsd_cpu.c
new file mode 100644
index 000000000000..1aa7021dbb0b
--- /dev/null
+++ b/devel/libgtop/files/patch-sysdeps_freebsd_cpu.c
@@ -0,0 +1,66 @@
+--- sysdeps/freebsd/cpu.c.orig 2009-04-12 01:45:28.000000000 -0400
++++ sysdeps/freebsd/cpu.c 2009-04-12 01:45:29.000000000 -0400
+@@ -54,6 +54,7 @@ void
+ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
+ {
+ long cpts [CPUSTATES];
++ long *cp_times;
+ struct clockinfo ci;
+ size_t length;
+ int ncpu, i;
+@@ -75,6 +76,16 @@ glibtop_get_cpu_s (glibtop *server, glib
+ return;
+ }
+
++ length = 0;
++ if (sysctlbyname ("kern.cp_times", NULL, &length, NULL, 0) == 0) {
++ cp_times = g_malloc (length);
++ length = sizeof(long) * CPUSTATES * (length / (sizeof(long) * CPUSTATES));
++ if (sysctlbyname ("kern.cp_times", &cp_times, &length, NULL, 0)) {
++ g_free (cp_times);
++ cp_times = NULL;
++ }
++ }
++
+ /* set user time */
+ buf->user = cpts [CP_USER];
+ /* set nice time */
+@@ -89,22 +100,32 @@ glibtop_get_cpu_s (glibtop *server, glib
+ /* set frequency */
+ buf->frequency = (ci.stathz ? ci.stathz : ci.hz);
+ /* set total */
+- buf->total = cpts [CP_USER] + cpts [CP_NICE]
++ buf->total = cpts [CP_USER] + cpts [CP_NICE] \
+ + cpts [CP_SYS] + cpts [CP_IDLE] + cpts [CP_INTR];
+
+ ncpu = server->ncpu + 1;
+
+ for (i = 0; i < ncpu; i++) {
+- 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;
++ if (cp_times) {
++ buf->xcpu_user[i] = cp_times[i * CPUSTATES + CP_USER];
++ buf->xcpu_nice[i] = cp_times[i * CPUSTATES + CP_NICE];
++ buf->xcpu_sys[i] = cp_times[i * CPUSTATES + CP_SYS];
++ buf->xcpu_idle[i] = cp_times[i * CPUSTATES + CP_IDLE];
++ buf->xcpu_irq[i] = cp_times[i * CPUSTATES + 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;
+