diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2022-12-06 20:54:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 20:54:09 +0200 |
commit | 7c4a3c392b6d17c3e02b65b41761addb73c08d6e (patch) | |
tree | f8298bcbc6f7f0b68d49ec6fae1f5531778a3d94 /daemon | |
parent | 93542d1a236ce2576999c73556a03b37c1486391 (diff) |
Add version to netdatacli (#14094)
add version to netdatacli
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/commands.c | 20 | ||||
-rw-r--r-- | daemon/commands.h | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/daemon/commands.c b/daemon/commands.c index 6288ee59bd..fae88dabf9 100644 --- a/daemon/commands.c +++ b/daemon/commands.c @@ -46,6 +46,7 @@ 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 cmd_status_t cmd_version(char *args, char **message); static command_info_t command_info_array[] = { {"help", cmd_help_execute, CMD_TYPE_HIGH_PRIORITY}, // show help menu @@ -59,7 +60,8 @@ static command_info_t command_info_array[] = { {"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}, - {"aclk-state", cmd_aclk_state, CMD_TYPE_ORTHOGONAL} + {"aclk-state", cmd_aclk_state, CMD_TYPE_ORTHOGONAL}, + {"version", cmd_version, CMD_TYPE_ORTHOGONAL} }; /* Mutexes for commands of type CMD_TYPE_ORTHOGONAL */ @@ -124,7 +126,9 @@ static cmd_status_t cmd_help_execute(char *args, char **message) "ping\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", + " Returns current state of ACLK and Cloud connection. (optionally in json).\n" + "version\n" + " Returns the netdata version.\n", MAX_COMMAND_LENGTH - 1); return CMD_STATUS_SUCCESS; } @@ -314,6 +318,18 @@ static cmd_status_t cmd_aclk_state(char *args, char **message) return CMD_STATUS_SUCCESS; } +static cmd_status_t cmd_version(char *args, char **message) +{ + (void)args; + + char version[MAX_COMMAND_LENGTH]; + snprintfz(version, MAX_COMMAND_LENGTH -1, "%s %s", program_name, program_version); + + *message = strdupz(version); + + return CMD_STATUS_SUCCESS; +} + static void cmd_lock_exclusive(unsigned index) { (void)index; diff --git a/daemon/commands.h b/daemon/commands.h index f0e38ce93f..78bdcc779a 100644 --- a/daemon/commands.h +++ b/daemon/commands.h @@ -25,6 +25,7 @@ typedef enum cmd { CMD_WRITE_CONFIG, CMD_PING, CMD_ACLK_STATE, + CMD_VERSION, CMD_TOTAL_COMMANDS } cmd_t; |