r3447 - trunk/varnish-cache/bin/varnishstat

phk at projects.linpro.no phk at projects.linpro.no
Mon Dec 1 15:13:49 CET 2008


Author: phk
Date: 2008-12-01 15:13:49 +0100 (Mon, 01 Dec 2008)
New Revision: 3447

Modified:
   trunk/varnish-cache/bin/varnishstat/varnishstat.c
Log:
Supress stats in the curses mode until we have see a non-zero value.



Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c	2008-11-26 16:10:19 UTC (rev 3446)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c	2008-12-01 14:13:49 UTC (rev 3447)
@@ -52,6 +52,7 @@
 
 #define FIELD_EXCLUSION_CHARACTER '^'
 
+
 static void
 myexp(double *acc, double val, unsigned *n, unsigned nmax)
 {
@@ -95,6 +96,7 @@
 do_curses(struct varnish_stats *VSL_stats, int delay, const char *fields)
 {
 	struct varnish_stats copy;
+	struct varnish_stats seen;
 	intmax_t ju;
 	struct timeval tv;
 	double tt, lt, hit, miss, ratio, up;
@@ -104,6 +106,7 @@
 	int ch, line;
 
 	memset(&copy, 0, sizeof copy);
+	memset(&seen, 0, sizeof seen);
 
 	a1 = a2 = a3 = 0.0;
 	n1 = n2 = n3 = 0;
@@ -144,13 +147,18 @@
 
 		line = 3;
 #define MAC_STAT(n, t, f, d) \
-	if ((fields == NULL || show_field( #n, fields )) && ++line < LINES) { \
+	if ((fields == NULL || show_field( #n, fields )) && line < LINES) { \
 		ju = VSL_stats->n; \
-		if (f == 'a') { \
+		if (ju == 0 && !seen.n) { \
+		} else if (f == 'a') { \
+			seen.n = 1; \
+			line++; \
 			mvprintw(line, 0, "%12ju %12.2f %12.2f %s\n", \
 			    ju, (ju - (intmax_t)copy.n)/lt, ju / up, d); \
 			copy.n = ju; \
 		} else { \
+			seen.n = 1; \
+			line++; \
 			mvprintw(line, 0, "%12ju %12s %12s %s\n", \
 			    ju, ".  ", ".  ", d); \
 		} \



More information about the varnish-commit mailing list