Mailing List Archive

r1065 - trunk/varnish-cache/bin/varnishstat
Author: des
Date: 2006-09-18 11:22:56 +0200 (Mon, 18 Sep 2006)
New Revision: 1065

Modified:
trunk/varnish-cache/bin/varnishstat/varnishstat.1
trunk/varnish-cache/bin/varnishstat/varnishstat.c
Log:
Add a -w option to set the delay between updates.

Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.1
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.1 2006-09-18 09:00:36 UTC (rev 1064)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.1 2006-09-18 09:22:56 UTC (rev 1065)
@@ -11,6 +11,7 @@
.Nm
.Op Fl 1
.Op Fl V
+.Op Fl w Ar delay
.Sh DESCRIPTION
The
.Nm
@@ -25,6 +26,11 @@
statistics once and exit.
.It Fl V
Display the version number and exit.
+.It Fl w Ar delay
+Wait
+.Ar delay
+seconds between updates.
+The default is 1.
.El
.Pp
The columns in the main display are, from left to right:
@@ -32,7 +38,7 @@
.It
Total since startup
.It
-Delta since last update (normally the last second)
+Delta since last update
.It
Average over process lifetime
.It

Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2006-09-18 09:00:36 UTC (rev 1064)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2006-09-18 09:22:56 UTC (rev 1065)
@@ -26,7 +26,7 @@
}

static void
-do_curses(struct varnish_stats *VSL_stats)
+do_curses(struct varnish_stats *VSL_stats, int delay)
{
struct varnish_stats copy;
intmax_t ju;
@@ -92,14 +92,14 @@
#undef MAC_STAT
lt = tt;
refresh();
- sleep(1);
+ sleep(delay);
}
}

static void
usage(void)
{
- fprintf(stderr, "usage: varnishstat [-1V]\n");
+ fprintf(stderr, "usage: varnishstat [-1V] [-w delay]\n");
exit(1);
}

@@ -108,11 +108,11 @@
{
int c;
struct varnish_stats *VSL_stats;
- int once = 0;
+ int delay = 1, once = 0;

VSL_stats = VSL_OpenStats();

- while ((c = getopt(argc, argv, "1V")) != -1) {
+ while ((c = getopt(argc, argv, "1Vw:")) != -1) {
switch (c) {
case '1':
once = 1;
@@ -120,13 +120,16 @@
case 'V':
varnish_version("varnishstat");
exit(0);
+ case 'w':
+ delay = atoi(optarg);
+ break;
default:
usage();
}
}

if (!once) {
- do_curses(VSL_stats);
+ do_curses(VSL_stats, delay);
} else {

#define MAC_STAT(n,t,f,d) \