[master] 4b4411d2e [vstat] new json schema
Nils Goroll
nils.goroll at uplex.de
Wed Apr 1 08:33:07 UTC 2020
commit 4b4411d2e877ceb2d5b1fdae9a7481b075153a73
Author: Guillaume Quintard <guillaume at varnish-software.com>
Date: Tue Feb 4 16:46:45 2020 -0800
[vstat] new json schema
diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c
index df654b008..00548320e 100644
--- a/bin/varnishstat/varnishstat.c
+++ b/bin/varnishstat/varnishstat.c
@@ -114,15 +114,13 @@ do_json_cb(void *priv, const struct VSC_point * const pt)
else
printf(",\n");
- printf(" \"");
- /* build the JSON key name. */
- printf("%s\": {\n", pt->name);
- printf(" \"description\": \"%s\",\n", pt->sdesc);
+ printf(" \"%s\": {\n", pt->name);
+ printf(" \"description\": \"%s\",\n", pt->sdesc);
- printf(" \"flag\": \"%c\", ", pt->semantics);
+ printf(" \"flag\": \"%c\", ", pt->semantics);
printf("\"format\": \"%c\",\n", pt->format);
- printf(" \"value\": %ju", (uintmax_t)val);
- printf("\n }");
+ printf(" \"value\": %ju", (uintmax_t)val);
+ printf("\n }");
return (0);
}
@@ -137,9 +135,12 @@ do_json(struct vsm *vsm, struct vsc *vsc)
now = time(NULL);
(void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now));
- printf("{\n \"timestamp\": \"%s\",\n", time_stamp);
+ printf("{\n"
+ " \"version\": 1,\n"
+ " \"timestamp\": \"%s\",\n"
+ " \"counters\": {\n", time_stamp);
(void)VSC_Iter(vsc, vsm, do_json_cb, &jp);
- printf("\n}\n");
+ printf("\n }\n}\n");
}
More information about the varnish-commit
mailing list