Commit 86cc2d66 authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Add a -w option to set the delay between updates.

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1065 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 37863a95
......@@ -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
......
......@@ -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) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment