Commit 3399615a authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Start interactive varnishstat with relevant verbosity

Where relevant means the highest verbosity when fields are filtered with
-f on the command line. There is still a caveat that this only applies
for the first iteration, and some parameters may conditionally appear
and not be visible when that event occurs (for example, when the child
process starts).

The rebuild variable was used as a bitmap but did not make use of
individual bits. This is now the case, but only for the two actionable
rebuild conditions.

Closes #2990
parent f4d726d9
......@@ -54,6 +54,7 @@
#include "varnishstat.h"
static struct VUT *vut;
int has_f = 0;
/*--------------------------------------------------------------------*/
......@@ -278,7 +279,6 @@ main(int argc, char * const *argv)
int once = 0, xml = 0, json = 0, f_list = 0, curses = 0;
signed char opt;
int i;
int has_f = 0;
struct vsc *vsc;
if (argc == 2 && !strcmp(argv[1], "--bindings"))
......
......@@ -37,7 +37,12 @@
#include "vas.h"
#include "vcs.h"
/* varnishstat.c */
extern int has_f;
/* varnishstat_curses.c */
void do_curses(struct vsm *, struct vsc *);
/* varnishstat_curses_help.c */
extern const char *const bindings_help[];
extern const int bindings_help_len;
......@@ -64,6 +64,9 @@
#define VALUE_MAX 999999999999
#define REBUILD_NEXT (1u << 0)
#define REBUILD_FIRST (1u << 1)
enum kb_e {
#define BINDING(name, desc) KB_ ## name,
#define BINDING_SIG
......@@ -220,10 +223,15 @@ build_pt_array(void)
VTAILQ_FOREACH(pt, &ptlist, list) {
CHECK_OBJ_NOTNULL(pt, PT_MAGIC);
if (pt->vpt->level > verbosity) {
if (has_f && (rebuild & REBUILD_FIRST))
verbosity = VSC_ChangeLevel(verbosity,
pt->vpt->level - verbosity);
else
continue;
}
if (!pt->seen && hide_unseen)
continue;
if (pt->vpt->level > verbosity)
continue;
assert(n_ptarray < n_ptlist);
ptarray[n_ptarray++] = pt;
}
......@@ -254,7 +262,7 @@ sample_points(void)
continue;
if (!pt->seen) {
pt->seen = 1;
rebuild = 1;
rebuild = REBUILD_NEXT;
}
pt->last = pt->cur;
pt->cur = v;
......@@ -964,11 +972,11 @@ handle_points_keypress(enum kb_e kb)
break;
case KB_UNSEEN:
hide_unseen = 1 - hide_unseen;
rebuild = 1;
rebuild = REBUILD_NEXT;
break;
case KB_SCALE:
scale = 1 - scale;
rebuild = 1;
rebuild = REBUILD_NEXT;
break;
case KB_ACCEL:
interval += 0.1;
......@@ -988,11 +996,11 @@ handle_points_keypress(enum kb_e kb)
break;
case KB_VERBOSE:
verbosity = VSC_ChangeLevel(verbosity, 1);
rebuild = 1;
rebuild = REBUILD_NEXT;
break;
case KB_QUIET:
verbosity = VSC_ChangeLevel(verbosity, -1);
rebuild = 1;
rebuild = REBUILD_NEXT;
break;
case KB_SAMPLE:
sample = 1;
......@@ -1094,7 +1102,7 @@ newpt(void *priv, const struct VSC_point *const vpt)
AZ(priv);
ALLOC_OBJ(pt, PT_MAGIC);
rebuild |= 1;
rebuild |= REBUILD_NEXT;
AN(pt);
pt->vpt = vpt;
pt->last = *pt->vpt->ptr;
......@@ -1125,7 +1133,7 @@ delpt(void *priv, const struct VSC_point *const vpt)
AZ(priv);
CAST_OBJ_NOTNULL(pt, vpt->priv, PT_MAGIC);
rebuild |= 2;
rebuild |= REBUILD_NEXT;
VTAILQ_REMOVE(&ptlist, pt, list);
n_ptlist--;
FREE_OBJ(pt);
......@@ -1159,6 +1167,7 @@ do_curses(struct vsm *vsm, struct vsc *vsc)
VSC_State(vsc, newpt, delpt, NULL);
rebuild |= REBUILD_FIRST;
(void)VSC_Iter(vsc, vsm, NULL, NULL);
build_pt_array();
init_hitrate();
......
varnishtest "Initial varnishstat verbosity"
varnish v1 -vcl {backend be none;} -start
process p1 -dump {varnishstat -n ${v1_name}} -start
process p2 -dump {varnishstat -n ${v1_name} -f MGT.child_start} -start
process p1 -expect-text 0 0 INFO
process p1 -screen_dump
process p2 -expect-text 0 0 MGT.child_start
process p2 -expect-text 0 0 DIAG
process p2 -screen_dump
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