Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Apr 2005 01:02:02 +0200
From:      Ivan Voras <ivoras@fer.hr>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>, current@freebsd.org
Subject:   Re: gstat shows > 100% busy
Message-ID:  <4261996A.2030204@fer.hr>
In-Reply-To: <3703.1113680811@critter.freebsd.dk>
References:  <42616975.9060303@centtech.com> <3703.1113680811@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------020703080201030807020200
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit

Poul-Henning Kamp wrote:

> The reason gstat shows >100% busy is that there are some outstanding
> requests. (the 2 in the left hand column).
> 
> I tried to make the statistics collection as cheap as possible, and
> as a side effect some of the columns can be somewhat misleading.

Could it be (for reasons of prettyfication) clipped to [0-100] range? 
Something like in the attached?



--------------020703080201030807020200
Content-Type: text/plain;
 name="patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch"

--- gstat_ori.c	Sun Apr 17 00:45:32 2005
+++ gstat.c	Sun Apr 17 00:59:44 2005
@@ -51,6 +51,7 @@
 static int flag_I = 500000;
 
 static void usage(void);
+static double clip_double(double x, double min, double max);
 
 int
 main(int argc, char **argv)
@@ -209,7 +210,7 @@
 			else 
 				i = 1;
 			attron(COLOR_PAIR(i));
-			printw(" %6.1lf", (double)ld[7]);
+			printw(" %6.1lf", clip_double((double)ld[7], 0, 100));
 			attroff(COLOR_PAIR(i));
 			printw("|");
 			if (gid == NULL) {
@@ -264,3 +265,18 @@
         exit(1);
         /* NOTREACHED */
 }
+
+
+/*
+ * Clip a double value to [min..max]
+ */
+static double
+clip_double(double x, double min, double max)
+{
+	if (x > max)
+		return max;
+	if (x < min)
+		return min;
+	return x;
+}
+

--------------020703080201030807020200--


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4261996A.2030204>