summaryrefslogtreecommitdiffstats
path: root/daemon/commands.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--daemon/commands.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/daemon/commands.c b/daemon/commands.c
index eac392e33..18468183f 100644
--- a/daemon/commands.c
+++ b/daemon/commands.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "common.h"
-#include "../database/engine/rrdenginelib.h"
+#include "database/engine/rrdenginelib.h"
static uv_thread_t thread;
static uv_loop_t* loop;
@@ -46,6 +46,7 @@ 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 cmd_status_t cmd_aclk_state(char *args, char **message);
static command_info_t command_info_array[] = {
{"help", cmd_help_execute, CMD_TYPE_HIGH_PRIORITY}, // show help menu
@@ -58,7 +59,8 @@ static command_info_t command_info_array[] = {
{"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},
- {"ping", cmd_ping_execute, CMD_TYPE_ORTHOGONAL}
+ {"ping", cmd_ping_execute, CMD_TYPE_ORTHOGONAL},
+ {"aclk-state", cmd_aclk_state, CMD_TYPE_ORTHOGONAL}
};
/* Mutexes for commands of type CMD_TYPE_ORTHOGONAL */
@@ -121,7 +123,9 @@ static cmd_status_t cmd_help_execute(char *args, char **message)
"reload-claiming-state\n"
" Reload agent claiming state from disk.\n"
"ping\n"
- " Return with 'pong' if agent is alive.\n",
+ " Return with 'pong' if agent is alive.\n"
+ "aclk-state [json]\n"
+ " Returns current state of ACLK and Cloud connection. (optionally in json)\n",
MAX_COMMAND_LENGTH - 1);
return CMD_STATUS_SUCCESS;
}
@@ -310,6 +314,17 @@ static cmd_status_t cmd_ping_execute(char *args, char **message)
return CMD_STATUS_SUCCESS;
}
+static cmd_status_t cmd_aclk_state(char *args, char **message)
+{
+ info("COMMAND: Reopening aclk/cloud state.");
+ if (strstr(args, "json"))
+ *message = aclk_state_json();
+ else
+ *message = aclk_state();
+
+ return CMD_STATUS_SUCCESS;
+}
+
static void cmd_lock_exclusive(unsigned index)
{
(void)index;