summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorAustin S. Hemmelgarn <austin@netdata.cloud>2020-05-28 04:29:56 -0400
committerGitHub <noreply@github.com>2020-05-28 18:29:56 +1000
commited8a6bea174bc4c52d4af4f4b138b5fe98003b49 (patch)
tree3b641745d9494fd62480a181b205dd93a4f3559f /daemon
parenta68436be6f2553284e4cf0471e39cbb215e12b34 (diff)
Added health check functionality to our Docker images. (#9172)
* Add a `ping` command to netdatacli to check if agent is alive. This provides a way to trivially check if the agent itself appears to be running (namely, the command parser for netdatacli in the agent itself is working and responding), allowing users to check this without having to rely on us continuing to have `help` be a command sent to the agent instead of executing locally. * Add a basic health check to our docke rimages. This adds a relatively basic health checker script to our Docker images. By default it verifies that the `/api/v1/info` endpoint returns a 200 status code. It also supports checking different endpoints or using `netdatacli ping` to check that Netdata is running, all controlled by a new Docker environment variable: `NETDATA_HEALTH_CHECK`. * Avoid unnessecary `chmod` in Dockerfile. Suggested by @prologic. * Fix typo in docs. * Update environment variable name to be more clear. Also add `-L` to `curl` command in health check to follow redirects.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/commands.c17
-rw-r--r--daemon/commands.h1
2 files changed, 16 insertions, 2 deletions
diff --git a/daemon/commands.c b/daemon/commands.c
index 3f4df4bd9f..8ea868fee1 100644
--- a/daemon/commands.c
+++ b/daemon/commands.c
@@ -45,6 +45,7 @@ static cmd_status_t cmd_reload_claiming_state_execute(char *args, char **message
static cmd_status_t cmd_reload_labels_execute(char *args, char **message);
static cmd_status_t cmd_read_config_execute(char *args, char **message);
static cmd_status_t cmd_write_config_execute(char *args, char **message);
+static cmd_status_t cmd_ping_execute(char *args, char **message);
static command_info_t command_info_array[] = {
{"help", cmd_help_execute, CMD_TYPE_HIGH_PRIORITY}, // show help menu
@@ -56,7 +57,8 @@ static command_info_t command_info_array[] = {
{"reload-claiming-state", cmd_reload_claiming_state_execute, CMD_TYPE_ORTHOGONAL}, // reload claiming state
{"reload-labels", cmd_reload_labels_execute, CMD_TYPE_ORTHOGONAL}, // reload the labels
{"read-config", cmd_read_config_execute, CMD_TYPE_CONCURRENT},
- {"write-config", cmd_write_config_execute, CMD_TYPE_ORTHOGONAL}
+ {"write-config", cmd_write_config_execute, CMD_TYPE_ORTHOGONAL},
+ {"ping", cmd_ping_execute, CMD_TYPE_ORTHOGONAL}
};
/* Mutexes for commands of type CMD_TYPE_ORTHOGONAL */
@@ -117,7 +119,9 @@ static cmd_status_t cmd_help_execute(char *args, char **message)
"fatal-agent\n"
" Log the state and halt the netdata agent.\n"
"reload-claiming-state\n"
- " Reload agent claiming state from disk.\n",
+ " Reload agent claiming state from disk.\n"
+ "ping\n"
+ " Return with 'pong' if agent is alive.\n",
MAX_COMMAND_LENGTH - 1);
return CMD_STATUS_SUCCESS;
}
@@ -296,6 +300,15 @@ static cmd_status_t cmd_write_config_execute(char *args, char **message)
return CMD_STATUS_SUCCESS;
}
+static cmd_status_t cmd_ping_execute(char *args, char **message)
+{
+ (void)args;
+
+ *message = strdupz("pong");
+
+ return CMD_STATUS_SUCCESS;
+}
+
static void cmd_lock_exclusive(unsigned index)
{
(void)index;
diff --git a/daemon/commands.h b/daemon/commands.h
index 3b2a1ca9a1..bd4aabfe1c 100644
--- a/daemon/commands.h
+++ b/daemon/commands.h
@@ -23,6 +23,7 @@ typedef enum cmd {
CMD_RELOAD_LABELS,
CMD_READ_CONFIG,
CMD_WRITE_CONFIG,
+ CMD_PING,
CMD_TOTAL_COMMANDS
} cmd_t;