Re: gstat shows > 100% busy

From: Ivan Voras <ivoras_at_fer.hr>
Date: Sun, 17 Apr 2005 01:02:02 +0200
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?



--- gstat_ori.c	Sun Apr 17 00:45:32 2005
+++ gstat.c	Sun Apr 17 00:59:44 2005
_at__at_ -51,6 +51,7 _at__at_
 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)
_at__at_ -209,7 +210,7 _at__at_
 			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) {
_at__at_ -264,3 +265,18 _at__at_
         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;
+}
+
Received on Sat Apr 16 2005 - 21:02:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:32 UTC