[libgtop] Make CPU load retrieval work.



commit 49641cc3639909e76b6798041aa31d0169aea654
Author: Jasper Lievisse Adriaanse <jasper humppa nl>
Date:   Thu Jun 16 12:57:43 2011 +0200

    Make CPU load retrieval work.
    
    It would sort of work on 64 bits arches, and not work at all no 32 bit arches.
    Now works on both, and take CP_INTR correctly into account.

 sysdeps/openbsd/cpu.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)
---
diff --git a/sysdeps/openbsd/cpu.c b/sysdeps/openbsd/cpu.c
index a018b72..81b4cac 100644
--- a/sysdeps/openbsd/cpu.c
+++ b/sysdeps/openbsd/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.4 2011/05/24 12:37:15 jasper Exp $	*/
+/* $OpenBSD: cpu.c,v 1.6 2011/05/31 14:19:18 jasper Exp $	*/
 
 /* Copyright (C) 1998 Joshua Sled
    This file is part of LibGTop 1.0.
@@ -34,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_cpu =
 (1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
 (1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) +
 (1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY) +
-(1L << GLIBTOP_CPU_IOWAIT);
+(1L << GLIBTOP_CPU_IRQ);
 
 /* MIB array for sysctl */
 static int mib_length=2;
@@ -54,7 +54,7 @@ _glibtop_init_cpu_p (glibtop *server)
 void
 glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
 {
-	guint64 cpts [CPUSTATES];
+	gulong cpts [CPUSTATES];
 
 	/* sysctl vars*/
 	struct clockinfo ci;
@@ -89,20 +89,14 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
 	buf->sys = cpts [CP_SYS];
 	/* set idle time */
 	buf->idle = cpts [CP_IDLE];
-	/* set iowait (really just interrupt) time */
-	buf->iowait = cpts [CP_INTR];
+	/* set interrupt time */
+	buf->irq = 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];
+		+ cpts [CP_SYS] + cpts [CP_IDLE] + cpts [CP_INTR];
 
 	/* Set the flags last. */
 	buf->flags = _glibtop_sysdeps_cpu;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]