Commit 63a05fef authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Some of the statistics we gather are accumulated totals, while others are

instantaneous measurements.  For instance, we report the total number of
allocator requests made over the child's lifetime, but we also report the
amount of storage in use at any particular moment.

The difference is important, because accumulated totals can be averaged
over the program's lifetime (or over the last N seconds), but instantaneous
measurements can't.

Recycle the format field in MAC_STAT() (it was never used anyway) into a
single-character flag indicating whether each item is an accumulated total
('a') or an instantaneous measure ('i').  Use this in varnishstat to skip
averaging non-averageable numbers.

Also rework varnishstat's "once" mode to show 1) each statistic's symbolic
name, 2) its current value, 3) if appropriate, its value averaged over the
process lifetime, and 4) its description.

The reason for displaying the symbolic name is to simplify scripting, and
to serve as a reference for looking up symbolic names to pass to e.g. the
upcoming Nagios plugin.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1587 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 059e1bdf
......@@ -68,8 +68,8 @@ mcf_stats(struct cli *cli, char **av, void *priv)
(void)priv;
AN(VSL_stats);
#define MAC_STAT(n,t,f,d) \
cli_out(cli, "%12ju " d "\n", (VSL_stats->n));
#define MAC_STAT(n, t, f, d) \
cli_out(cli, "%12ju %s\n", (VSL_stats->n), d);
#include "stat_field.h"
#undef MAC_STAT
}
......
......@@ -115,11 +115,17 @@ do_curses(struct varnish_stats *VSL_stats, int delay)
printw("Hitrate avg: %8.4f %8.4f %8.4f\n", a1, a2, a3);
printw("\n");
#define MAC_STAT(n,t,f,d) \
#define MAC_STAT(n, t, f, d) \
do { \
ju = VSL_stats->n; \
printw("%12ju %12.2f %12.2f " d "\n", \
ju, (ju - (intmax_t)copy.n)/lt, ju / up); \
copy.n = ju;
if (f == 'a') { \
printw("%12ju %12.2f %12.2f %s\n", \
ju, (ju - (intmax_t)copy.n)/lt, ju / up, d); \
copy.n = ju; \
} else { \
printw("%12ju %12s %12s %s\n", ju, ". ", ". ", d); \
} \
} while (0);
#include "stat_field.h"
#undef MAC_STAT
lt = tt;
......@@ -128,6 +134,27 @@ do_curses(struct varnish_stats *VSL_stats, int delay)
}
}
static void
do_once(struct varnish_stats *VSL_stats)
{
struct timespec ts;
double up;
clock_gettime(CLOCK_REALTIME, &ts);
up = ts.tv_sec - VSL_stats->start_time;
#define MAC_STAT(n, t, f, d) \
do { \
intmax_t ju = VSL_stats->n; \
if (f == 'a') \
printf("%-16s %12ju %12.2f %s\n", #n, ju, ju / up, d); \
else \
printf("%-16s %12ju %12s %s\n", #n, ju, ". ", d); \
} while (0);
#include "stat_field.h"
#undef MAC_STAT
}
static void
usage(void)
{
......@@ -165,15 +192,10 @@ main(int argc, char **argv)
if ((VSL_stats = VSL_OpenStats(n_arg)) == NULL)
exit(1);
if (!once) {
if (once)
do_once(VSL_stats);
else
do_curses(VSL_stats, delay);
} else {
#define MAC_STAT(n,t,f,d) \
printf("%12ju " d "\n", (VSL_stats->n));
#include "stat_field.h"
#undef MAC_STAT
}
exit(0);
}
......@@ -29,63 +29,63 @@
* $Id$
*/
MAC_STAT(client_conn, uint64_t, "u", "Client connections accepted")
MAC_STAT(client_req, uint64_t, "u", "Client requests received")
MAC_STAT(client_conn, uint64_t, 'a', "Client connections accepted")
MAC_STAT(client_req, uint64_t, 'a', "Client requests received")
MAC_STAT(cache_hit, uint64_t, "u", "Cache hits")
MAC_STAT(cache_hitpass, uint64_t, "u", "Cache hits for pass")
MAC_STAT(cache_miss, uint64_t, "u", "Cache misses")
MAC_STAT(cache_hit, uint64_t, 'a', "Cache hits")
MAC_STAT(cache_hitpass, uint64_t, 'a', "Cache hits for pass")
MAC_STAT(cache_miss, uint64_t, 'a', "Cache misses")
MAC_STAT(backend_conn, uint64_t, "u", "Backend connections success")
MAC_STAT(backend_fail, uint64_t, "u", "Backend connections failures")
MAC_STAT(backend_reuse, uint64_t, "u", "Backend connections reuses")
MAC_STAT(backend_recycle, uint64_t, "u", "Backend connections recycles")
MAC_STAT(backend_unused, uint64_t, "u", "Backend connections unused")
MAC_STAT(backend_conn, uint64_t, 'a', "Backend connections success")
MAC_STAT(backend_fail, uint64_t, 'a', "Backend connections failures")
MAC_STAT(backend_reuse, uint64_t, 'a', "Backend connections reuses")
MAC_STAT(backend_recycle, uint64_t, 'a', "Backend connections recycles")
MAC_STAT(backend_unused, uint64_t, 'a', "Backend connections unused")
MAC_STAT(n_srcaddr, uint64_t, "u", "N struct srcaddr")
MAC_STAT(n_srcaddr_act, uint64_t, "u", "N active struct srcaddr")
MAC_STAT(n_sess_mem, uint64_t, "u", "N struct sess_mem")
MAC_STAT(n_sess, uint64_t, "u", "N struct sess")
MAC_STAT(n_object, uint64_t, "u", "N struct object")
MAC_STAT(n_objecthead, uint64_t, "u", "N struct objecthead")
MAC_STAT(n_smf, uint64_t, "u", "N struct smf")
MAC_STAT(n_smf_frag, uint64_t, "u", "N small free smf")
MAC_STAT(n_smf_large, uint64_t, "u", "N large free smf")
MAC_STAT(n_vbe_conn, uint64_t, "u", "N struct vbe_conn")
MAC_STAT(n_wrk, uint64_t, "u", "N worker threads")
MAC_STAT(n_wrk_create, uint64_t, "u", "N worker threads created")
MAC_STAT(n_wrk_failed, uint64_t, "u", "N worker threads not created")
MAC_STAT(n_wrk_max, uint64_t, "u", "N worker threads limited")
MAC_STAT(n_wrk_queue, uint64_t, "u", "N queued work requests")
MAC_STAT(n_wrk_overflow, uint64_t, "u", "N overflowed work requests")
MAC_STAT(n_wrk_drop, uint64_t, "u", "N dropped work requests")
MAC_STAT(n_srcaddr, uint64_t, 'i', "N struct srcaddr")
MAC_STAT(n_srcaddr_act, uint64_t, 'i', "N active struct srcaddr")
MAC_STAT(n_sess_mem, uint64_t, 'i', "N struct sess_mem")
MAC_STAT(n_sess, uint64_t, 'i', "N struct sess")
MAC_STAT(n_object, uint64_t, 'i', "N struct object")
MAC_STAT(n_objecthead, uint64_t, 'i', "N struct objecthead")
MAC_STAT(n_smf, uint64_t, 'i', "N struct smf")
MAC_STAT(n_smf_frag, uint64_t, 'i', "N small free smf")
MAC_STAT(n_smf_large, uint64_t, 'i', "N large free smf")
MAC_STAT(n_vbe_conn, uint64_t, 'i', "N struct vbe_conn")
MAC_STAT(n_wrk, uint64_t, 'i', "N worker threads")
MAC_STAT(n_wrk_create, uint64_t, 'a', "N worker threads created")
MAC_STAT(n_wrk_failed, uint64_t, 'a', "N worker threads not created")
MAC_STAT(n_wrk_max, uint64_t, 'a', "N worker threads limited")
MAC_STAT(n_wrk_queue, uint64_t, 'a', "N queued work requests")
MAC_STAT(n_wrk_overflow, uint64_t, 'a', "N overflowed work requests")
MAC_STAT(n_wrk_drop, uint64_t, 'a', "N dropped work requests")
MAC_STAT(n_expired, uint64_t, "u", "N expired objects")
MAC_STAT(n_deathrow, uint64_t, "u", "N objects on deathrow")
MAC_STAT(n_expired, uint64_t, 'i', "N expired objects")
MAC_STAT(n_deathrow, uint64_t, 'i', "N objects on deathrow")
MAC_STAT(losthdr, uint64_t, "u", "HTTP header overflows")
MAC_STAT(losthdr, uint64_t, 'a', "HTTP header overflows")
MAC_STAT(n_objsendfile, uint64_t, "u", "Objects sent with sendfile")
MAC_STAT(n_objwrite, uint64_t, "u", "Objects sent with write")
MAC_STAT(n_objsendfile, uint64_t, 'a', "Objects sent with sendfile")
MAC_STAT(n_objwrite, uint64_t, 'a', "Objects sent with write")
MAC_STAT(s_sess, uint64_t, "u", "Total Sessions")
MAC_STAT(s_req, uint64_t, "u", "Total Requests")
MAC_STAT(s_pipe, uint64_t, "u", "Total pipe")
MAC_STAT(s_pass, uint64_t, "u", "Total pass")
MAC_STAT(s_fetch, uint64_t, "u", "Total fetch")
MAC_STAT(s_hdrbytes, uint64_t, "u", "Total header bytes")
MAC_STAT(s_bodybytes, uint64_t, "u", "Total body bytes")
MAC_STAT(s_sess, uint64_t, 'a', "Total Sessions")
MAC_STAT(s_req, uint64_t, 'a', "Total Requests")
MAC_STAT(s_pipe, uint64_t, 'a', "Total pipe")
MAC_STAT(s_pass, uint64_t, 'a', "Total pass")
MAC_STAT(s_fetch, uint64_t, 'a', "Total fetch")
MAC_STAT(s_hdrbytes, uint64_t, 'a', "Total header bytes")
MAC_STAT(s_bodybytes, uint64_t, 'a', "Total body bytes")
MAC_STAT(sess_closed, uint64_t, "u", "Session Closed")
MAC_STAT(sess_pipeline, uint64_t, "u", "Session Pipeline")
MAC_STAT(sess_readahead, uint64_t, "u", "Session Read Ahead")
MAC_STAT(sess_herd, uint64_t, "u", "Session herd")
MAC_STAT(sess_closed, uint64_t, 'a', "Session Closed")
MAC_STAT(sess_pipeline, uint64_t, 'a', "Session Pipeline")
MAC_STAT(sess_readahead, uint64_t, 'a', "Session Read Ahead")
MAC_STAT(sess_herd, uint64_t, 'a', "Session herd")
MAC_STAT(shm_records, uint64_t, "u", "SHM records")
MAC_STAT(shm_writes, uint64_t, "u", "SHM writes")
MAC_STAT(shm_cont, uint64_t, "u", "SHM MTX contention")
MAC_STAT(shm_records, uint64_t, 'a', "SHM records")
MAC_STAT(shm_writes, uint64_t, 'a', "SHM writes")
MAC_STAT(shm_cont, uint64_t, 'a', "SHM MTX contention")
MAC_STAT(sm_nreq, uint64_t, "u", "allocator requests")
MAC_STAT(sm_nobj, uint64_t, "u", "outstanding allocations")
MAC_STAT(sm_balloc, uint64_t, "u", "bytes allocated")
MAC_STAT(sm_bfree, uint64_t, "u", "bytes free")
MAC_STAT(sm_nreq, uint64_t, 'a', "allocator requests")
MAC_STAT(sm_nobj, uint64_t, 'i', "outstanding allocations")
MAC_STAT(sm_balloc, uint64_t, 'i', "bytes allocated")
MAC_STAT(sm_bfree, uint64_t, 'i', "bytes free")
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