From aa64ab936a09e71f8dbec7c9ead3373f873e831a Mon Sep 17 00:00:00 2001 From: des Date: Mon, 18 Sep 2006 09:22:56 +0000 Subject: [PATCH] Add a -w option to set the delay between updates. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1065 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishstat/varnishstat.1 | 8 +++++++- varnish-cache/bin/varnishstat/varnishstat.c | 15 +++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/varnish-cache/bin/varnishstat/varnishstat.1 b/varnish-cache/bin/varnishstat/varnishstat.1 index 07c5ae55..f58d4003 100644 --- a/varnish-cache/bin/varnishstat/varnishstat.1 +++ b/varnish-cache/bin/varnishstat/varnishstat.1 @@ -11,6 +11,7 @@ .Nm .Op Fl 1 .Op Fl V +.Op Fl w Ar delay .Sh DESCRIPTION The .Nm @@ -25,6 +26,11 @@ Instead of presenting of a continuously updated display, print the 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 @@ The columns in the main display are, from left to right: .It Total since startup .It -Delta since last update (normally the last second) +Delta since last update .It Average over process lifetime .It diff --git a/varnish-cache/bin/varnishstat/varnishstat.c b/varnish-cache/bin/varnishstat/varnishstat.c index d327ca8d..2e2bdf76 100644 --- a/varnish-cache/bin/varnishstat/varnishstat.c +++ b/varnish-cache/bin/varnishstat/varnishstat.c @@ -26,7 +26,7 @@ myexp(double *acc, double val, unsigned *n, unsigned nmax) } 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 @@ do_curses(struct varnish_stats *VSL_stats) #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 @@ main(int argc, char **argv) { 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 @@ main(int argc, char **argv) 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) \ -- 2.39.5