Commit 39181b71 authored by Nils Goroll's avatar Nils Goroll

Let varnishhist see the backend side and add some profiles ...

... for the standard backend timestamps and size.
parent 149b6287
...@@ -105,6 +105,7 @@ static int scales[] = { ...@@ -105,6 +105,7 @@ static int scales[] = {
struct profile { struct profile {
const char *name; const char *name;
char VSL_arg;
enum VSL_tag_e tag; enum VSL_tag_e tag;
const char *prefix; const char *prefix;
int field; int field;
...@@ -112,22 +113,64 @@ struct profile { ...@@ -112,22 +113,64 @@ struct profile {
int hist_high; int hist_high;
} }
profiles[] = { profiles[] = {
// client
{ {
.name = "responsetime", .name = "responsetime",
.VSL_arg = 'c',
.tag = SLT_Timestamp, .tag = SLT_Timestamp,
.prefix = "Process:", .prefix = "Process:",
.field = 3, .field = 3,
.hist_low = -6, .hist_low = -6,
.hist_high = 3 .hist_high = 3
}, { },
{
.name = "size", .name = "size",
.VSL_arg = 'c',
.tag = SLT_ReqAcct, .tag = SLT_ReqAcct,
.prefix = NULL, .prefix = NULL,
.field = 5, .field = 5,
.hist_low = 1, .hist_low = 1,
.hist_high = 8 .hist_high = 8
}, { },
.name = 0, // backend
{
.name = "Bereqtime",
.VSL_arg = 'b',
.tag = SLT_Timestamp,
.prefix = "Bereq:",
.field = 3,
.hist_low = -6,
.hist_high = 3
},
{
.name = "Beresptime",
.VSL_arg = 'b',
.tag = SLT_Timestamp,
.prefix = "Beresp:",
.field = 3,
.hist_low = -6,
.hist_high = 3
},
{
.name = "BerespBodytime",
.VSL_arg = 'b',
.tag = SLT_Timestamp,
.prefix = "BerespBody:",
.field = 3,
.hist_low = -6,
.hist_high = 3
},
{
.name = "Besize",
.VSL_arg = 'b',
.tag = SLT_BereqAcct,
.prefix = NULL,
.field = 5,
.hist_low = 1,
.hist_high = 8
},
{
.name = NULL
} }
}; };
...@@ -203,9 +246,6 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], ...@@ -203,9 +246,6 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
(void)priv; (void)priv;
for (tr = pt[0]; tr != NULL; tr = *++pt) { for (tr = pt[0]; tr != NULL; tr = *++pt) {
if (tr->type != VSL_t_req)
/* Only look at client requests */
continue;
if (tr->reason == VSL_r_esi) if (tr->reason == VSL_r_esi)
/* Skip ESI requests */ /* Skip ESI requests */
continue; continue;
...@@ -223,7 +263,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], ...@@ -223,7 +263,9 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
break; break;
case SLT_VCL_return: case SLT_VCL_return:
if (!strcasecmp(VSL_CDATA(tr->c->rec.ptr), if (!strcasecmp(VSL_CDATA(tr->c->rec.ptr),
"restart")) "restart") ||
!strcasecmp(VSL_CDATA(tr->c->rec.ptr),
"retry"))
skip = 1; skip = 1;
break; break;
default: default:
...@@ -374,11 +416,19 @@ usage(int status) ...@@ -374,11 +416,19 @@ usage(int status)
exit(status); exit(status);
} }
static void
profile_error(const char *s)
{
fprintf(stderr, "-P: '%s' is not a valid"
" profile name or definition\n", s);
exit(1);
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int i; int i;
char *colon; const char *colon, *ptag;
const char *profile = "responsetime"; const char *profile = "responsetime";
pthread_t thr; pthread_t thr;
int fnum = -1; int fnum = -1;
...@@ -387,8 +437,6 @@ main(int argc, char **argv) ...@@ -387,8 +437,6 @@ main(int argc, char **argv)
VUT_Init(progname, argc, argv, &vopt_spec); VUT_Init(progname, argc, argv, &vopt_spec);
/* only client requests */
assert(VUT_Arg('c', NULL));
while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) {
switch (i) { switch (i) {
case 'h': case 'h':
...@@ -402,14 +450,25 @@ main(int argc, char **argv) ...@@ -402,14 +450,25 @@ main(int argc, char **argv)
break; break;
} }
/* else it's a definition, we hope */ /* else it's a definition, we hope */
if (colon == optarg + 1 &&
(*optarg == 'b' || *optarg == 'c')) {
cli_p.VSL_arg = *optarg;
ptag = colon + 1;
colon = strchr(colon + 1, ':');
if (colon == NULL)
profile_error(optarg);
} else {
ptag = optarg;
cli_p.VSL_arg = 'c';
}
assert(colon);
if (sscanf(colon+1, "%d:%d:%d", &cli_p.field, if (sscanf(colon+1, "%d:%d:%d", &cli_p.field,
&cli_p.hist_low, &cli_p.hist_high) != 3) { &cli_p.hist_low, &cli_p.hist_high) != 3) {
fprintf(stderr, "-P: '%s' is not a valid" profile_error(optarg);
" profile name or definition\n", optarg);
exit(1);
} }
match_tag = VSL_Name2Tag(optarg, colon - optarg); match_tag = VSL_Name2Tag(ptag, colon - ptag);
if (match_tag < 0) { if (match_tag < 0) {
fprintf(stderr, fprintf(stderr,
"-P: '%s' is not a valid tag name\n", "-P: '%s' is not a valid tag name\n",
...@@ -450,6 +509,8 @@ main(int argc, char **argv) ...@@ -450,6 +509,8 @@ main(int argc, char **argv)
fprintf(stderr, "-P: No such profile '%s'\n", profile); fprintf(stderr, "-P: No such profile '%s'\n", profile);
exit(1); exit(1);
} }
assert(VUT_Arg(active_profile->VSL_arg, NULL));
match_tag = active_profile->tag; match_tag = active_profile->tag;
fnum = active_profile->field; fnum = active_profile->field;
hist_low = active_profile->hist_low; hist_low = active_profile->hist_low;
......
...@@ -45,13 +45,18 @@ ...@@ -45,13 +45,18 @@
) )
#define HIS_OPT_P \ #define HIS_OPT_P \
VOPT("P:", "[-P <size|responsetime|tag:field_num:min:max>]", \ VOPT("P:", "[-P <profile|[[cb:]tag:field_num:min:max>]", \
"Profile definition", \ "Profile definition", \
"Either specify \"size\" or \"responsetime\" profile or" \ "Either a predefined profile or a custom definition. " \
" create a new one. Define the tag we'll look for, and the" \ " Predefined profiles for the client side are" \
" field number of the value we are interested in. min and" \ " \"responsetime \" and \"size\". For the backend side:" \
" max are the boundaries of the graph (these are power of" \ " \"Bereqtime\", \"Beresptime\", \"BerespBodytime\"," \
" tens)." \ " and \"Besize\"." \
" custom definitions include an optional (c)lient or" \
" (b)backend filter (defaults to client), the tag we'll" \
" look for, and the field number of the value we are" \
" interested in. min and max are the boundaries of the" \
" graph (these are power of ten)." \
) )
VSL_OPT_C VSL_OPT_C
......
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