Skip to content

Commit

Permalink
Updating the info endpoint for cloud notifications (netdata#8519)
Browse files Browse the repository at this point in the history
  • Loading branch information
amoss authored Mar 30, 2020
1 parent 71e1ef8 commit d6f0703
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aclk/agent_cloud_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static char *aclk_password = NULL;

static char *global_base_topic = NULL;
static int aclk_connecting = 0;
static int aclk_connected = 0;
int aclk_connected = 0; // Exposed in the web-api

static netdata_mutex_t aclk_mutex = NETDATA_MUTEX_INITIALIZER;
static netdata_mutex_t query_mutex = NETDATA_MUTEX_INITIALIZER;
Expand Down
11 changes: 9 additions & 2 deletions web/api/web_api_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ inline void host_labels2json(RRDHOST *host, BUFFER *wb, size_t indentation) {
rrdhost_unlock(host);
}

extern int aclk_connected;
inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
{
buffer_strcat(wb, "{\n");
Expand Down Expand Up @@ -872,9 +873,15 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
buffer_strcat(wb, "\t\"cloud-available\": false,\n");
#endif
if (is_agent_claimed() == NULL)
buffer_strcat(wb, "\t\"agent-claimed\": false\n");
buffer_strcat(wb, "\t\"agent-claimed\": false,\n");
else
buffer_strcat(wb, "\t\"agent-claimed\": true\n");
buffer_strcat(wb, "\t\"agent-claimed\": true,\n");
#ifdef ENABLE_ACLK
if (aclk_connected)
buffer_strcat(wb, "\t\"aclk-available\": true\n");
else
#endif
buffer_strcat(wb, "\t\"aclk-available\": false\n"); // Intentionally valid with/without #ifdef above

buffer_strcat(wb, "}");
return 0;
Expand Down

0 comments on commit d6f0703

Please sign in to comment.