|
|
|
|
@ -140,12 +140,15 @@ static uint64_t percentile(const struct lab_stream *stream, unsigned percent) {
|
|
|
|
|
return LAB_HISTOGRAM - 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void statistics(struct lab *lab, uint64_t id) { |
|
|
|
|
static void statistics(struct lab *lab, uint64_t id, int loads) { |
|
|
|
|
struct TOPO_GROUP *group = topo_groups_find(lab->inst->topo_groups, lab->group); |
|
|
|
|
printf("{\"id\":%" PRIu64 ",\"rc\":0,\"node\":\"%" PRIu64 "\",\"group\":\"%" PRIu64 |
|
|
|
|
"\",\"errors\":%d,\"online\":[", id, lab->inst->node_id, lab->group, lab->errors); |
|
|
|
|
int separator = 0; |
|
|
|
|
for (struct ll_entry *e = group ? group->nodes->head : NULL; e; e = e->next) { |
|
|
|
|
if (stream_member_online(lab->inst, lab->group, lab->inst->node_id)) { |
|
|
|
|
printf("\"%" PRIu64 "\"", lab->inst->node_id); separator = 1; |
|
|
|
|
} |
|
|
|
|
for (struct ll_entry *e = loads && group ? group->nodes->head : NULL; e; e = e->next) { |
|
|
|
|
struct TOPO_GROUP_NODE *node = (struct TOPO_GROUP_NODE *)e; |
|
|
|
|
if (stream_member_online(lab->inst, lab->group, node->node_id)) { |
|
|
|
|
printf("%s\"%" PRIu64 "\"", separator++ ? "," : "", node->node_id); |
|
|
|
|
@ -220,7 +223,7 @@ static void command(struct lab *lab, const char *json) {
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "lab: invalid RPC"); reply(id, -1); return; |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "lab: RPC id=%" PRIu64 " op=%s", id, operation); |
|
|
|
|
if (!strcmp(operation, "stats")) { statistics(lab, id); return; } |
|
|
|
|
if (!strcmp(operation, "stats")) { number(json, "loads", &value); statistics(lab, id, value != 0); return; } |
|
|
|
|
if (!strcmp(operation, "quit")) { stopping = 1; reply(id, 0); return; } |
|
|
|
|
if (!strcmp(operation, "create")) { |
|
|
|
|
if (lab->group) { reply(id, -1); return; } |
|
|
|
|
|