@cryptotaxi247 / netdata-1 / commits / 7c4a3c392

Add version to netdatacli (#14094)

add version to netdatacli

Emmanuel Vasilakis committed Dec 6, 2022 at 20:54 UTC 7c4a3c392b6d17c3e02b65b41761addb73c08d6e
2 files changed +19 -2
daemon/commands.c
+18 -2
@@ -46,6 +46,7 @@ static cmd_status_t cmd_read_config_execute(char *args, char **message);
46 static cmd_status_t cmd_write_config_execute(char *args, char **message);
47 static cmd_status_t cmd_ping_execute(char *args, char **message);
48 static cmd_status_t cmd_aclk_state(char *args, char **message);
49 +static cmd_status_t cmd_version(char *args, char **message);
50
51 static command_info_t command_info_array[] = {
52 {"help", cmd_help_execute, CMD_TYPE_HIGH_PRIORITY}, // show help menu
@@ -59,7 +60,8 @@ static command_info_t command_info_array[] = {
60 {"read-config", cmd_read_config_execute, CMD_TYPE_CONCURRENT},
61 {"write-config", cmd_write_config_execute, CMD_TYPE_ORTHOGONAL},
62 {"ping", cmd_ping_execute, CMD_TYPE_ORTHOGONAL},
62 - {"aclk-state", cmd_aclk_state, CMD_TYPE_ORTHOGONAL}
63 + {"aclk-state", cmd_aclk_state, CMD_TYPE_ORTHOGONAL},
64 + {"version", cmd_version, CMD_TYPE_ORTHOGONAL}
65 };
66
67 /* Mutexes for commands of type CMD_TYPE_ORTHOGONAL */
@@ -124,7 +126,9 @@ static cmd_status_t cmd_help_execute(char *args, char **message)
126 "ping\n"
127 " Return with 'pong' if agent is alive.\n"
128 "aclk-state [json]\n"
127 - " Returns current state of ACLK and Cloud connection. (optionally in json)\n",
129 + " Returns current state of ACLK and Cloud connection. (optionally in json).\n"
130 + "version\n"
131 + " Returns the netdata version.\n",
132 MAX_COMMAND_LENGTH - 1);
133 return CMD_STATUS_SUCCESS;
134 }
@@ -314,6 +318,18 @@ static cmd_status_t cmd_aclk_state(char *args, char **message)
318 return CMD_STATUS_SUCCESS;
319 }
320
321 +static cmd_status_t cmd_version(char *args, char **message)
322 +{
323 + (void)args;
324 +
325 + char version[MAX_COMMAND_LENGTH];
326 + snprintfz(version, MAX_COMMAND_LENGTH -1, "%s %s", program_name, program_version);
327 +
328 + *message = strdupz(version);
329 +
330 + return CMD_STATUS_SUCCESS;
331 +}
332 +
333 static void cmd_lock_exclusive(unsigned index)
334 {
335 (void)index;
daemon/commands.h
+1
@@ -25,6 +25,7 @@ typedef enum cmd {
25 CMD_WRITE_CONFIG,
26 CMD_PING,
27 CMD_ACLK_STATE,
28 + CMD_VERSION,
29 CMD_TOTAL_COMMANDS
30 } cmd_t;
31