Make JSON output valid
This commit is contained in:
@ -304,12 +304,21 @@ dprintAllServersJson(DCB *dcb)
|
|||||||
{
|
{
|
||||||
SERVER *ptr;
|
SERVER *ptr;
|
||||||
char *stat;
|
char *stat;
|
||||||
|
int len = 0;
|
||||||
|
int el = 1;
|
||||||
|
|
||||||
spinlock_acquire(&server_spin);
|
spinlock_acquire(&server_spin);
|
||||||
ptr = allServers;
|
ptr = allServers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
dcb_printf(dcb, "{\n \"server\": \"%s\",\n",
|
ptr = ptr->next;
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
ptr = allServers;
|
||||||
|
dcb_printf(dcb, "[\n");
|
||||||
|
while (ptr)
|
||||||
|
{
|
||||||
|
dcb_printf(dcb, " {\n \"server\": \"%s\",\n",
|
||||||
ptr->name);
|
ptr->name);
|
||||||
stat = server_status(ptr);
|
stat = server_status(ptr);
|
||||||
dcb_printf(dcb, " \"status\": \"%s\",\n",
|
dcb_printf(dcb, " \"status\": \"%s\",\n",
|
||||||
@ -352,11 +361,18 @@ char *stat;
|
|||||||
ptr->stats.n_connections);
|
ptr->stats.n_connections);
|
||||||
dcb_printf(dcb, " \"currentConnections\": \"%d\",\n",
|
dcb_printf(dcb, " \"currentConnections\": \"%d\",\n",
|
||||||
ptr->stats.n_current);
|
ptr->stats.n_current);
|
||||||
dcb_printf(dcb, " \"currentOps\": \"%d\",\n",
|
dcb_printf(dcb, " \"currentOps\": \"%d\"\n",
|
||||||
ptr->stats.n_current_ops);
|
ptr->stats.n_current_ops);
|
||||||
dcb_printf(dcb, "}\n");
|
if (el < len) {
|
||||||
ptr = ptr->next;
|
dcb_printf(dcb, " },\n");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
dcb_printf(dcb, " }\n");
|
||||||
|
}
|
||||||
|
ptr = ptr->next;
|
||||||
|
el++;
|
||||||
|
}
|
||||||
|
dcb_printf(dcb, "]\n");
|
||||||
spinlock_release(&server_spin);
|
spinlock_release(&server_spin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user