@cryptotaxi247 / netdata-1 / commits / 23561d1dd

Add CLI command to schedule update information (#20558)

Add cli command to schedule localhost update node information to Netdata Cloud

Stelios Fragkakis committed Jun 24, 2025 at 20:29 UTC 23561d1ddcbf883cfd7a2383586efb8dd55e4031
2 files changed +16
src/daemon/commands.c
+15
@@ -49,6 +49,7 @@ static cmd_status_t cmd_version(char *args, char **message);
49 static cmd_status_t cmd_dumpconfig(char *args, char **message);
50 static cmd_status_t cmd_remove_stale_node(char *args, char **message);
51 static cmd_status_t cmd_mark_stale_nodes_ephemeral(char *args, char **message);
52 +static cmd_status_t cmd_update_node_info(char *args, char **message);
53
54 static command_info_t command_info_array[] = {
55 {"help", "", "Show this help menu.", cmd_help_execute, CMD_TYPE_HIGH_PRIORITY}, // show help menu
@@ -68,6 +69,7 @@ static command_info_t command_info_array[] = {
69 "Marks one or all disconnected nodes as ephemeral, while keeping their retention\n available for queries on both this Netdata Agent dashboard and Netdata Cloud", cmd_mark_stale_nodes_ephemeral, CMD_TYPE_ORTHOGONAL},
70 {"remove-stale-node", "<node_id | machine_guid | hostname | ALL_NODES>",
71 "Marks one or all disconnected nodes as ephemeral, and removes them\n so that they are no longer available for queries, from both this\n Netdata Agent dashboard and Netdata Cloud.", cmd_remove_stale_node, CMD_TYPE_ORTHOGONAL},
72 + {"update-node-info", "", "Schedules an node update message for localhost to Netdata Cloud.", cmd_update_node_info, CMD_TYPE_ORTHOGONAL},
73 };
74
75 /* Mutexes for commands of type CMD_TYPE_ORTHOGONAL */
@@ -456,6 +458,19 @@ done:
458 return CMD_STATUS_SUCCESS;
459 }
460
461 +static cmd_status_t cmd_update_node_info(char *args, char **message)
462 +{
463 + if (aclk_online()) {
464 + schedule_node_state_update(localhost, 1000);
465 + CLEAN_BUFFER *wb = buffer_create(1024, NULL);
466 + buffer_sprintf(wb, "Node info update scheduled for \"%s\"", rrdhost_hostname(localhost));
467 + *message = strdupz(buffer_tostring(wb));
468 + }
469 + else
470 + *message = strdupz("Agent is not connected to Netdata Cloud");
471 + return CMD_STATUS_SUCCESS;
472 +}
473 +
474 static cmd_status_t cmd_remove_stale_node(char *args, char **message)
475 {
476 return cmd_remove_stale_node_internal(args, message, true);
src/daemon/commands.h
+1
@@ -22,6 +22,7 @@ typedef enum cmd {
22 CMD_DUMPCONFIG,
23 CMD_REMOVE_NODE,
24 CMD_MARK_NODE,
25 + CMD_UPDATE_NODE_INFO,
26 CMD_TOTAL_COMMANDS
27 } cmd_t;
28