From 70d4dba55acef896126d109051d71a103a4ffdf6 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 5 Jul 2006 08:08:46 +0000 Subject: [PATCH] Show also rate in curses display git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@309 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishstat/varnishstat.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishstat/varnishstat.c b/varnish-cache/bin/varnishstat/varnishstat.c index 9d7b253b..d752667b 100644 --- a/varnish-cache/bin/varnishstat/varnishstat.c +++ b/varnish-cache/bin/varnishstat/varnishstat.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "shmlog.h" #include "varnishapi.h" @@ -19,8 +20,11 @@ main(int argc, char **argv) { int c; struct shmloghead *lh; - struct varnish_stats *VSL_stats; + struct varnish_stats *VSL_stats, copy; int c_flag = 0; + uintmax_t ju; + struct timespec ts; + double tt, lt; lh = VSL_OpenLog(); @@ -38,15 +42,22 @@ main(int argc, char **argv) } if (c_flag) { + memset(©, 0, sizeof copy); initscr(); erase(); while (1) { move(0,0); + clock_gettime(CLOCK_MONOTONIC, &ts); + tt = ts.tv_nsec * 1e-9 + ts.tv_sec; + lt = tt - lt; #define MAC_STAT(n,t,f,d) \ - printw("%12ju " d "\n", (VSL_stats->n)); + ju = VSL_stats->n; \ + printw("%12ju %10.2f " d "\n", ju, (ju - copy.n)/lt); \ + copy.n = ju; #include "stat_field.h" #undef MAC_STAT + lt = tt; refresh(); sleep(1); } -- 2.39.5