@cryptotaxi247 / netdata-1 / commits / d6f0703a0

Updating the info endpoint for cloud notifications (#8519)

Andrew Moss committed Mar 30, 2020 at 15:03 UTC d6f0703a09e33aa6fdafe51026953be30cdaa03e
2 files changed +10 -3
aclk/agent_cloud_link.c
+1 -1
@@ -22,7 +22,7 @@ static char *aclk_password = NULL;
22
23 static char *global_base_topic = NULL;
24 static int aclk_connecting = 0;
25 -static int aclk_connected = 0;
25 +int aclk_connected = 0; // Exposed in the web-api
26
27 static netdata_mutex_t aclk_mutex = NETDATA_MUTEX_INITIALIZER;
28 static netdata_mutex_t query_mutex = NETDATA_MUTEX_INITIALIZER;
web/api/web_api_v1.c
+9 -2
@@ -807,6 +807,7 @@ inline void host_labels2json(RRDHOST *host, BUFFER *wb, size_t indentation) {
807 rrdhost_unlock(host);
808 }
809
810 +extern int aclk_connected;
811 inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
812 {
813 buffer_strcat(wb, "{\n");
@@ -872,9 +873,15 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
873 buffer_strcat(wb, "\t\"cloud-available\": false,\n");
874 #endif
875 if (is_agent_claimed() == NULL)
875 - buffer_strcat(wb, "\t\"agent-claimed\": false\n");
876 + buffer_strcat(wb, "\t\"agent-claimed\": false,\n");
877 else
877 - buffer_strcat(wb, "\t\"agent-claimed\": true\n");
878 + buffer_strcat(wb, "\t\"agent-claimed\": true,\n");
879 +#ifdef ENABLE_ACLK
880 + if (aclk_connected)
881 + buffer_strcat(wb, "\t\"aclk-available\": true\n");
882 + else
883 +#endif
884 + buffer_strcat(wb, "\t\"aclk-available\": false\n"); // Intentionally valid with/without #ifdef above
885
886 buffer_strcat(wb, "}");
887 return 0;