33
unsigned command_string_size;
34
};
35
36
+static inline char command_reply_prefix(const struct command_context *cmd_ctx, cmd_status_t status)
37
+{
38
+ if (cmd_ctx->idx == CMD_PING)
39
+ return CMD_PREFIX_INFO;
40
+
41
+ return cmd_prefix_by_status[status];
42
+}
43
+
44
/* Forward declarations */
45
static cmd_status_t cmd_help_execute(char *args, char **message);
46
static cmd_status_t cmd_reload_health_execute(char *args, char **message);
69
{"reload-labels", "", "Reload all localhost labels.", cmd_reload_labels_execute, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_FULL}, // reload the labels
70
{"read-config", "", "", cmd_read_config_execute, CMD_TYPE_CONCURRENT, CMD_INIT_STATUS_FULL},
71
{"write-config", "", "", cmd_write_config_execute, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_FULL},
64
- {"ping", "", "Return with 'pong' if agent is alive.", cmd_ping_execute, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_INIT}, // ping command
72
+ {"ping", "", "Return with 'pong'; exit 0 when ready, 1 while initializing, 255 if the agent cannot be contacted.", cmd_ping_execute, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_INIT}, // ping command
73
{"aclk-state", "[json]", "Returns current state of ACLK and Netdata Cloud connection. (optionally in json).", cmd_aclk_state, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_FULL},
74
{"version", "", "Returns the netdata version.", cmd_version, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_INIT},
75
{"dumpconfig", "", "Returns the current netdata.conf on stdout.", cmd_dumpconfig, CMD_TYPE_ORTHOGONAL, CMD_INIT_STATUS_FULL},
317
318
*message = strdupz("pong");
319
312
- return CMD_STATUS_SUCCESS;
320
+ return netdata_ready_load() ? CMD_STATUS_SUCCESS : CMD_STATUS_FAILURE;
321
}
322
323
static cmd_status_t cmd_aclk_state(char *args, char **message)
593
add_char_to_command_reply(reply_string, &reply_string_size, '\0');
594
595
if (message) {
588
- add_char_to_command_reply(reply_string, &reply_string_size, cmd_prefix_by_status[status]);
596
+ add_char_to_command_reply(reply_string, &reply_string_size, command_reply_prefix(cmd_ctx, status));
597
add_string_to_command_reply(reply_string, &reply_string_size, message);
598
}
599
735
736
/* combined allocation of client pipe and command context */
737
cmd_ctx = mallocz(sizeof(*cmd_ctx));
738
+ cmd_ctx->idx = CMD_HELP;
739
client = (uv_pipe_t *)cmd_ctx;
740
ret = uv_pipe_init(server->loop, client, 1);
741
if (ret) {