[master] ee8f4f489 Add JSON support for the CLI "status" command.
Geoff Simmons
geoff at uplex.de
Mon Oct 8 11:28:11 UTC 2018
commit ee8f4f4892d25c6df505aca899f7af464607dee6
Author: Geoff Simmons <geoff at uplex.de>
Date: Fri Sep 21 17:25:19 2018 +0200
Add JSON support for the CLI "status" command.
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index d03ff2106..026bdd8e8 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -679,8 +679,19 @@ mch_cli_server_status(struct cli *cli, const char * const *av, void *priv)
VCLI_Out(cli, "Child in state %s", ch_state[child_state]);
}
+static void v_matchproto_(cli_func_t)
+mch_cli_server_status_json(struct cli *cli, const char * const *av, void *priv)
+{
+ (void)priv;
+ VCLI_JSON_begin(cli, 2, av);
+ VCLI_Out(cli, ", ");
+ VCLI_JSON_str(cli, ch_state[child_state]);
+ VCLI_JSON_end(cli);
+}
+
static struct cli_proto cli_mch[] = {
- { CLICMD_SERVER_STATUS, "", mch_cli_server_status },
+ { CLICMD_SERVER_STATUS, "", mch_cli_server_status,
+ mch_cli_server_status_json },
{ CLICMD_SERVER_START, "", mch_cli_server_start },
{ CLICMD_SERVER_STOP, "", mch_cli_server_stop },
{ CLICMD_PANIC_SHOW, "", mch_cli_panic_show },
diff --git a/bin/varnishtest/tests/b00004.vtc b/bin/varnishtest/tests/b00004.vtc
index ec5cf7661..2ed2c10ff 100644
--- a/bin/varnishtest/tests/b00004.vtc
+++ b/bin/varnishtest/tests/b00004.vtc
@@ -7,7 +7,11 @@ server s1 {
varnish v1 -vcl+backend { }
varnish v1 -start
+varnish v1 -cliexpect "running" status
+varnish v1 -clijson "status -j"
varnish v1 -stop
+varnish v1 -cliexpect "stopped" status
+varnish v1 -clijson "status -j"
varnish v1 -start
varnish v1 -stop
More information about the varnish-commit
mailing list