Removes Legacy JSON Cloud Protocol Support In Agent (#13111)
* removes old protocol support (cloud removed support already)
Timotej S committed
Jun 27, 2022 at 16:03 UTC
cb13f0787d77c5e36f79ab18f492a52e0ec11123
38 files changed
+165
-1379
CMakeLists.txt
-6
@@ -787,11 +787,6 @@ set(ACLK_ALWAYS_BUILD
787
aclk/aclk_proxy.h
788
)
789
790
-set(ACLK_COMMON_FILES
791
- aclk/aclk_collector_list.c
792
- aclk/aclk_collector_list.h
793
- )
794
-
790
set(ACLK_FILES
791
aclk/aclk.c
792
aclk/aclk.h
@@ -1172,7 +1167,6 @@ list(APPEND NETDATA_COMMON_CFLAGS ${PROTOBUF_CFLAGS_OTHER})
1167
list(APPEND NETDATA_FILES ${ACLK_ALWAYS_BUILD})
1168
list(APPEND NETDATA_FILES ${TIMEX_PLUGIN_FILES})
1169
list(APPEND NETDATA_FILES ${ACLK_FILES} ${ACLK_PROTO_BUILT_SRCS} ${ACLK_PROTO_BUILT_HDRS})
1175
-list(APPEND NETDATA_FILES ${ACLK_COMMON_FILES})
1170
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/aclk/aclk-schemas)
1171
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/MQTT-C/include)
1172
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include)
Makefile.am
+1
-15
@@ -641,11 +641,7 @@ ACLK_FILES = \
641
mqtt_websockets/c-rbuf/include/ringbuffer.h \
642
mqtt_websockets/c-rbuf/src/ringbuffer_internal.h \
643
mqtt_websockets/MQTT-C/src/mqtt.c \
644
- mqtt_websockets/MQTT-C/include/mqtt.h
645
- $(NULL)
646
-
647
-if ENABLE_NEW_CLOUD_PROTOCOL
648
-ACLK_FILES += \
644
+ mqtt_websockets/MQTT-C/include/mqtt.h \
645
aclk/aclk_charts_api.c \
646
aclk/aclk_charts_api.h \
647
aclk/aclk_alarm_api.c \
@@ -768,17 +764,8 @@ aclk/aclk-schemas/proto/nodeinstance/info/v1/info.pb.cc \
764
aclk/aclk-schemas/proto/nodeinstance/info/v1/info.pb.h: aclk/aclk-schemas/proto/nodeinstance/info/v1/info.proto
765
$(PROTOC) -I=aclk/aclk-schemas --cpp_out=$(builddir)/aclk/aclk-schemas $^
766
771
-endif #ENABLE_NEW_CLOUD_PROTOCOL
772
-
767
endif #ENABLE_ACLK
768
775
-if ENABLE_ACLK
776
-ACLK_COMMON_FILES = \
777
- aclk/aclk_collector_list.c \
778
- aclk/aclk_collector_list.h \
779
- $(NULL)
780
-endif
781
-
769
ACLK_ALWAYS_BUILD_FILES = \
770
aclk/aclk_rrdhost_state.h \
771
aclk/aclk_api.c \
@@ -885,7 +872,6 @@ NETDATA_FILES = \
872
$(CLAIM_FILES) \
873
$(PARSER_FILES) \
874
$(ACLK_ALWAYS_BUILD_FILES) \
888
- $(ACLK_COMMON_FILES) \
875
$(ACLK_FILES) \
876
$(SPAWN_PLUGIN_FILES) \
877
$(TIMEX_PLUGIN_FILES) \
aclk/aclk.c
+26
-398
@@ -10,7 +10,6 @@
10
#include "aclk_query_queue.h"
11
#include "aclk_util.h"
12
#include "aclk_rx_msgs.h"
13
-#include "aclk_collector_list.h"
13
#include "https_client.h"
14
#include "schema-wrappers/schema_wrappers.h"
15
@@ -46,8 +45,6 @@ netdata_mutex_t aclk_shared_state_mutex = NETDATA_MUTEX_INITIALIZER;
45
#define ACLK_SHARED_STATE_UNLOCK netdata_mutex_unlock(&aclk_shared_state_mutex)
46
47
struct aclk_shared_state aclk_shared_state = {
49
- .agent_state = ACLK_HOST_INITIALIZING,
50
- .last_popcorn_interrupt = 0,
48
.mqtt_shutdown_msg_id = -1,
49
.mqtt_shutdown_msg_rcvd = 0
50
};
@@ -188,54 +185,10 @@ void aclk_mqtt_wss_log_cb(mqtt_wss_log_type_t log_type, const char* str)
185
186
//TODO prevent big buffer on stack
187
#define RX_MSGLEN_MAX 4096
191
-static void msg_callback_old_protocol(const char *topic, const void *msg, size_t msglen, int qos)
192
-{
193
- UNUSED(qos);
194
- char cmsg[RX_MSGLEN_MAX];
195
- size_t len = (msglen < RX_MSGLEN_MAX - 1) ? msglen : (RX_MSGLEN_MAX - 1);
196
- const char *cmd_topic = aclk_get_topic(ACLK_TOPICID_COMMAND);
197
- if (!cmd_topic) {
198
- error("Error retrieving command topic");
199
- return;
200
- }
201
-
202
- if (msglen > RX_MSGLEN_MAX - 1)
203
- error("Incoming ACLK message was bigger than MAX of %d and got truncated.", RX_MSGLEN_MAX);
204
-
205
- memcpy(cmsg,
206
- msg,
207
- len);
208
- cmsg[len] = 0;
209
-
210
-#ifdef ACLK_LOG_CONVERSATION_DIR
211
-#define FN_MAX_LEN 512
212
- char filename[FN_MAX_LEN];
213
- int logfd;
214
- snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx.json", ACLK_GET_CONV_LOG_NEXT());
215
- logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
216
- if(logfd < 0)
217
- error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
218
- write(logfd, msg, msglen);
219
- close(logfd);
220
-#endif
221
-
222
- debug(D_ACLK, "Got Message From Broker Topic \"%s\" QoS %d MSG: \"%s\"", topic, qos, cmsg);
223
-
224
- if (strcmp(cmd_topic, topic))
225
- error("Received message on unexpected topic %s", topic);
226
-
227
- if (aclk_shared_state.mqtt_shutdown_msg_id > 0) {
228
- error("Link is shutting down. Ignoring incoming message.");
229
- return;
230
- }
231
-
232
- aclk_handle_cloud_cmd_message(cmsg);
233
-}
234
-
235
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
236
-static void msg_callback_new_protocol(const char *topic, const void *msg, size_t msglen, int qos)
188
+static void msg_callback(const char *topic, const void *msg, size_t msglen, int qos)
189
{
190
UNUSED(qos);
191
+ aclk_rcvd_cloud_msgs++;
192
if (msglen > RX_MSGLEN_MAX)
193
error("Incoming ACLK message was bigger than MAX of %d and got truncated.", RX_MSGLEN_MAX);
194
@@ -272,15 +225,6 @@ static void msg_callback_new_protocol(const char *topic, const void *msg, size_t
225
aclk_handle_new_cloud_msg(msgtype, msg, msglen);
226
}
227
275
-static inline void msg_callback(const char *topic, const void *msg, size_t msglen, int qos) {
276
- aclk_rcvd_cloud_msgs++;
277
- if (aclk_use_new_cloud_arch)
278
- msg_callback_new_protocol(topic, msg, msglen, qos);
279
- else
280
- msg_callback_old_protocol(topic, msg, msglen, qos);
281
-}
282
-#endif /* ENABLE_NEW_CLOUD_PROTOCOL */
283
-
228
static void puback_callback(uint16_t packet_id)
229
{
230
if (++aclk_pubacks_per_conn == ACLK_PUBACKS_CONN_STABLE) {
@@ -356,40 +300,6 @@ static int handle_connection(mqtt_wss_client client)
300
return 0;
301
}
302
359
-inline static int aclk_popcorn_check()
360
-{
361
- ACLK_SHARED_STATE_LOCK;
362
- if (unlikely(aclk_shared_state.agent_state == ACLK_HOST_INITIALIZING)) {
363
- ACLK_SHARED_STATE_UNLOCK;
364
- return 1;
365
- }
366
- ACLK_SHARED_STATE_UNLOCK;
367
- return 0;
368
-}
369
-
370
-inline static int aclk_popcorn_check_bump()
371
-{
372
- ACLK_SHARED_STATE_LOCK;
373
- if (unlikely(aclk_shared_state.agent_state == ACLK_HOST_INITIALIZING)) {
374
- aclk_shared_state.last_popcorn_interrupt = now_realtime_sec();
375
- ACLK_SHARED_STATE_UNLOCK;
376
- return 1;
377
- }
378
- ACLK_SHARED_STATE_UNLOCK;
379
- return 0;
380
-}
381
-
382
-static inline void queue_connect_payloads(void)
383
-{
384
- aclk_query_t query = aclk_query_new(METADATA_INFO);
385
- query->data.metadata_info.host = localhost;
386
- query->data.metadata_info.initial_on_connect = 1;
387
- aclk_queue_query(query);
388
- query = aclk_query_new(METADATA_ALARMS);
389
- query->data.metadata_alarms.initial_on_connect = 1;
390
- aclk_queue_query(query);
391
-}
392
-
303
static inline void mqtt_connected_actions(mqtt_wss_client client)
304
{
305
char *topic = (char*)aclk_get_topic(ACLK_TOPICID_COMMAND);
@@ -399,15 +309,11 @@ static inline void mqtt_connected_actions(mqtt_wss_client client)
309
else
310
mqtt_wss_subscribe(client, topic, 1);
311
402
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
403
- if (aclk_use_new_cloud_arch) {
404
- topic = (char*)aclk_get_topic(ACLK_TOPICID_CMD_NG_V1);
405
- if (!topic)
406
- error("Unable to fetch topic for protobuf COMMAND (to subscribe)");
407
- else
408
- mqtt_wss_subscribe(client, topic, 1);
409
- }
410
-#endif
312
+ topic = (char*)aclk_get_topic(ACLK_TOPICID_CMD_NG_V1);
313
+ if (!topic)
314
+ error("Unable to fetch topic for protobuf COMMAND (to subscribe)");
315
+ else
316
+ mqtt_wss_subscribe(client, topic, 1);
317
318
aclk_stats_upd_online(1);
319
aclk_connected = 1;
@@ -415,55 +321,7 @@ static inline void mqtt_connected_actions(mqtt_wss_client client)
321
aclk_rcvd_cloud_msgs = 0;
322
aclk_connection_counter++;
323
418
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
419
- if (!aclk_use_new_cloud_arch) {
420
-#endif
421
- ACLK_SHARED_STATE_LOCK;
422
- if (aclk_shared_state.agent_state != ACLK_HOST_INITIALIZING) {
423
- error("Sending `connect` payload immediately as popcorning was finished already.");
424
- queue_connect_payloads();
425
- }
426
- ACLK_SHARED_STATE_UNLOCK;
427
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
428
- } else {
429
- aclk_send_agent_connection_update(client, 1);
430
- }
431
-#endif
432
-}
433
-
434
-/* Waits until agent is ready or needs to exit
435
- * @param client instance of mqtt_wss_client
436
- * @param query_threads pointer to aclk_query_threads
437
- * structure where to store data about started query threads
438
- * @return 0 - Popcorning Finished - Agent STABLE,
439
- * !0 - netdata_exit
440
- */
441
-static int wait_popcorning_finishes()
442
-{
443
- time_t elapsed;
444
- int need_wait;
445
- if (aclk_use_new_cloud_arch)
446
- return 0;
447
-
448
- while (!netdata_exit) {
449
- ACLK_SHARED_STATE_LOCK;
450
- if (likely(aclk_shared_state.agent_state != ACLK_HOST_INITIALIZING)) {
451
- ACLK_SHARED_STATE_UNLOCK;
452
- return 0;
453
- }
454
- elapsed = now_realtime_sec() - aclk_shared_state.last_popcorn_interrupt;
455
- if (elapsed >= ACLK_STABLE_TIMEOUT) {
456
- aclk_shared_state.agent_state = ACLK_HOST_STABLE;
457
- ACLK_SHARED_STATE_UNLOCK;
458
- error("ACLK localhost popcorn timer finished");
459
- return 0;
460
- }
461
- ACLK_SHARED_STATE_UNLOCK;
462
- need_wait = ACLK_STABLE_TIMEOUT - elapsed;
463
- error("ACLK localhost popcorn timer - wait %d seconds longer", need_wait);
464
- sleep(need_wait);
465
- }
466
- return 1;
324
+ aclk_send_agent_connection_update(client, 1);
325
}
326
327
void aclk_graceful_disconnect(mqtt_wss_client client)
@@ -471,12 +329,8 @@ void aclk_graceful_disconnect(mqtt_wss_client client)
329
info("Preparing to gracefully shutdown ACLK connection");
330
aclk_queue_lock();
331
aclk_queue_flush();
474
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
475
- if (aclk_use_new_cloud_arch)
476
- aclk_shared_state.mqtt_shutdown_msg_id = aclk_send_agent_connection_update(client, 0);
477
- else
478
-#endif
479
- aclk_shared_state.mqtt_shutdown_msg_id = aclk_send_app_layer_disconnect(client, "graceful");
332
+
333
+ aclk_shared_state.mqtt_shutdown_msg_id = aclk_send_agent_connection_update(client, 0);
334
335
time_t t = now_monotonic_sec();
336
while (!mqtt_wss_service(client, 100)) {
@@ -594,8 +448,6 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
448
url_t mqtt_url;
449
#endif
450
597
- json_object *lwt = NULL;
598
-
451
while (!netdata_exit) {
452
char *cloud_base_url = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "cloud base url", NULL);
453
if (cloud_base_url == NULL) {
@@ -629,8 +481,6 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
481
.drop_on_publish_fail = 1
482
};
483
632
- aclk_use_new_cloud_arch = 0;
633
-
484
#ifndef ACLK_DISABLE_CHALLENGE
485
if (aclk_env) {
486
aclk_env_t_destroy(aclk_env);
@@ -649,19 +499,16 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
499
if (netdata_exit)
500
return 1;
501
652
- if (aclk_env->encoding == ACLK_ENC_PROTO) {
653
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
654
- error("Cloud requested New Cloud Protocol to be used but this agent cannot support it!");
502
+ if (aclk_env->encoding != ACLK_ENC_PROTO) {
503
+ error_report("This agent can only use the new cloud protocol but cloud requested old one.");
504
+ continue;
505
+ }
506
+
507
+ if (!aclk_env_has_capa("proto")) {
508
+ error ("Can't use encoding=proto without at least \"proto\" capability.");
509
continue;
656
-#else
657
- if (!aclk_env_has_capa("proto")) {
658
- error ("Can't encoding=proto without at least \"proto\" capability.");
659
- continue;
660
- }
661
- info("Switching ACLK to new protobuf protocol. Due to /env response.");
662
- aclk_use_new_cloud_arch = 1;
663
-#endif
510
}
511
+ info("New ACLK protobuf protocol negotiated successfully (/env response).");
512
513
memset(&auth_url, 0, sizeof(url_t));
514
if (url_parse(aclk_env->auth_endpoint, &auth_url)) {
@@ -679,10 +526,7 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
526
527
// aclk_get_topic moved here as during OTP we
528
// generate the topic cache
682
- if (aclk_use_new_cloud_arch)
683
- mqtt_conn_params.will_topic = aclk_get_topic(ACLK_TOPICID_AGENT_CONN);
684
- else
685
- mqtt_conn_params.will_topic = aclk_get_topic(ACLK_TOPICID_METADATA);
529
+ mqtt_conn_params.will_topic = aclk_get_topic(ACLK_TOPICID_AGENT_CONN);
530
531
if (!mqtt_conn_params.will_topic) {
532
error("Couldn't get LWT topic. Will not send LWT.");
@@ -708,17 +552,7 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
552
aclk_session_sec = aclk_session_newarch / USEC_PER_SEC;
553
aclk_session_us = aclk_session_newarch % USEC_PER_SEC;
554
711
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
712
- if (aclk_use_new_cloud_arch) {
713
- mqtt_conn_params.will_msg = aclk_generate_lwt(&mqtt_conn_params.will_msg_len);
714
- } else {
715
-#endif
716
- lwt = aclk_generate_disconnect(NULL);
717
- mqtt_conn_params.will_msg = json_object_to_json_string_ext(lwt, JSON_C_TO_STRING_PLAIN);
718
- mqtt_conn_params.will_msg_len = strlen(mqtt_conn_params.will_msg);
719
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
720
- }
721
-#endif
555
+ mqtt_conn_params.will_msg = aclk_generate_lwt(&mqtt_conn_params.will_msg_len);
556
557
#ifdef ACLK_DISABLE_CHALLENGE
558
ret = mqtt_wss_connect(client, base_url.host, base_url.port, &mqtt_conn_params, ACLK_SSL_FLAGS, &proxy_conf);
@@ -732,10 +566,7 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
566
freez((char*)mqtt_conn_params.username);
567
#endif
568
735
- if (aclk_use_new_cloud_arch)
736
- freez((char *)mqtt_conn_params.will_msg);
737
- else
738
- json_object_put(lwt);
569
+ freez((char *)mqtt_conn_params.will_msg);
570
571
if (!ret) {
572
last_conn_time_mqtt = now_realtime_sec();
@@ -778,10 +609,7 @@ void *aclk_main(void *ptr)
609
return NULL;
610
}
611
781
- unsigned int proto_hdl_cnt;
782
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
783
- proto_hdl_cnt = aclk_init_rx_msg_handlers();
784
-#endif
612
+ unsigned int proto_hdl_cnt = aclk_init_rx_msg_handlers();
613
614
// This thread is unusual in that it cannot be cancelled by cancel_main_threads()
615
// as it must notify the far end that it shutdown gracefully and avoid the LWT.
@@ -792,7 +620,6 @@ void *aclk_main(void *ptr)
620
static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
621
return NULL;
622
#endif
795
- aclk_popcorn_check_bump(); // start localhost popcorn timer
623
query_threads.count = read_query_thread_count();
624
625
if (wait_till_cloud_enabled())
@@ -803,11 +630,7 @@ void *aclk_main(void *ptr)
630
631
use_mqtt_5 = config_get_boolean(CONFIG_SECTION_CLOUD, "mqtt5", CONFIG_BOOLEAN_YES);
632
806
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
633
if (!(mqttwss_client = mqtt_wss_new("mqtt_wss", aclk_mqtt_wss_log_cb, msg_callback, puback_callback, use_mqtt_5))) {
808
-#else
809
- if (!(mqttwss_client = mqtt_wss_new("mqtt_wss", aclk_mqtt_wss_log_cb, msg_callback_old_protocol, puback_callback, use_mqtt_5))) {
810
-#endif
634
error("Couldn't initialize MQTT_WSS network library");
635
goto exit;
636
}
@@ -835,28 +658,9 @@ void *aclk_main(void *ptr)
658
if (aclk_attempt_to_connect(mqttwss_client))
659
goto exit_full;
660
838
-#if defined(ENABLE_ACLK) && !defined(ENABLE_NEW_CLOUD_PROTOCOL)
839
- error_report("############################ WARNING ###############################");
840
- error_report("# Your agent is configured to connect to cloud but has #");
841
- error_report("# no protobuf protocol support (uses legacy JSON protocol) #");
842
- error_report("# Legacy protocol will be deprecated soon (planned 1st March 2022) #");
843
- error_report("# Visit following link for more info and instructions how to solve #");
844
- error_report("# https://www.netdata.cloud/blog/netdata-clouds-new-architecture #");
845
- error_report("######################################################################");
846
-#endif
847
-
848
- // warning this assumes the popcorning is relative short (3s)
849
- // if that changes call mqtt_wss_service from within
850
- // to keep OpenSSL, WSS and MQTT connection alive
851
- if (wait_popcorning_finishes())
852
- goto exit_full;
853
-
661
if (unlikely(!query_threads.thread_list))
662
aclk_query_threads_start(&query_threads, mqttwss_client);
663
857
- if (!aclk_use_new_cloud_arch)
858
- queue_connect_payloads();
859
-
664
if (handle_connection(mqttwss_client)) {
665
aclk_stats_upd_online(0);
666
last_disconnect_time = now_realtime_sec();
@@ -890,168 +694,12 @@ exit:
694
return NULL;
695
}
696
893
-// TODO this is taken over as workaround from old ACLK
894
-// fix this in both old and new ACLK
895
-extern void health_alarm_entry2json_nolock(BUFFER *wb, ALARM_ENTRY *ae, RRDHOST *host);
896
-
897
-void aclk_alarm_reload(void)
898
-{
899
- ACLK_SHARED_STATE_LOCK;
900
- if (unlikely(aclk_shared_state.agent_state == ACLK_HOST_INITIALIZING)) {
901
- ACLK_SHARED_STATE_UNLOCK;
902
- return;
903
- }
904
- ACLK_SHARED_STATE_UNLOCK;
905
-
906
- aclk_queue_query(aclk_query_new(METADATA_ALARMS));
907
-}
908
-
909
-int aclk_update_alarm(RRDHOST *host, ALARM_ENTRY *ae)
910
-{
911
- BUFFER *local_buffer;
912
- json_object *msg;
913
-
914
- if (host != localhost)
915
- return 0;
916
-
917
- ACLK_SHARED_STATE_LOCK;
918
- if (unlikely(aclk_shared_state.agent_state == ACLK_HOST_INITIALIZING)) {
919
- ACLK_SHARED_STATE_UNLOCK;
920
- return 0;
921
- }
922
- ACLK_SHARED_STATE_UNLOCK;
923
-
924
- local_buffer = buffer_create(NETDATA_WEB_RESPONSE_HEADER_SIZE);
925
-
926
- netdata_rwlock_rdlock(&host->health_log.alarm_log_rwlock);
927
- health_alarm_entry2json_nolock(local_buffer, ae, host);
928
- netdata_rwlock_unlock(&host->health_log.alarm_log_rwlock);
929
-
930
- msg = json_tokener_parse(local_buffer->buffer);
931
-
932
- struct aclk_query *query = aclk_query_new(ALARM_STATE_UPDATE);
933
- query->data.alarm_update = msg;
934
- aclk_queue_query(query);
935
-
936
- buffer_free(local_buffer);
937
- return 0;
938
-}
939
-
940
-int aclk_update_chart(RRDHOST *host, char *chart_name, int create)
941
-{
942
- struct aclk_query *query;
943
-
944
- if (host == localhost ? aclk_popcorn_check_bump() : aclk_popcorn_check())
945
- return 0;
946
-
947
- query = aclk_query_new(create ? CHART_NEW : CHART_DEL);
948
- if(create) {
949
- query->data.chart_add_del.host = host;
950
- query->data.chart_add_del.chart_name = strdupz(chart_name);
951
- } else {
952
- query->data.metadata_info.host = host;
953
- query->data.metadata_info.initial_on_connect = 0;
954
- }
955
-
956
- aclk_queue_query(query);
957
- return 0;
958
-}
959
-
960
-/*
961
- * Add a new collector to the list
962
- * If it exists, update the chart count
963
- */
964
-void aclk_add_collector(RRDHOST *host, const char *plugin_name, const char *module_name)
965
-{
966
- struct aclk_query *query;
967
- struct _collector *tmp_collector;
968
- if (unlikely(!netdata_ready || aclk_use_new_cloud_arch)) {
969
- return;
970
- }
971
-
972
- COLLECTOR_LOCK;
973
-
974
- tmp_collector = _add_collector(host->machine_guid, plugin_name, module_name);
975
-
976
- if (unlikely(tmp_collector->count != 1)) {
977
- COLLECTOR_UNLOCK;
978
- return;
979
- }
980
-
981
- COLLECTOR_UNLOCK;
982
-
983
- if (aclk_popcorn_check_bump())
984
- return;
985
-
986
- if (host != localhost)
987
- return;
988
-
989
- query = aclk_query_new(METADATA_INFO);
990
- query->data.metadata_info.host = localhost; //TODO
991
- query->data.metadata_info.initial_on_connect = 0;
992
- aclk_queue_query(query);
993
-
994
- query = aclk_query_new(METADATA_ALARMS);
995
- query->data.metadata_alarms.initial_on_connect = 0;
996
- aclk_queue_query(query);
997
-}
998
-
999
-/*
1000
- * Delete a collector from the list
1001
- * If the chart count reaches zero the collector will be removed
1002
- * from the list by calling del_collector.
1003
- *
1004
- * This function will release the memory used and schedule
1005
- * a cloud update
1006
- */
1007
-void aclk_del_collector(RRDHOST *host, const char *plugin_name, const char *module_name)
1008
-{
1009
- struct aclk_query *query;
1010
- struct _collector *tmp_collector;
1011
- if (unlikely(!netdata_ready || aclk_use_new_cloud_arch)) {
1012
- return;
1013
- }
1014
-
1015
- COLLECTOR_LOCK;
1016
-
1017
- tmp_collector = _del_collector(host->machine_guid, plugin_name, module_name);
1018
-
1019
- if (unlikely(!tmp_collector || tmp_collector->count)) {
1020
- COLLECTOR_UNLOCK;
1021
- return;
1022
- }
1023
-
1024
- debug(
1025
- D_ACLK, "DEL COLLECTOR [%s:%s] -- charts %u", plugin_name ? plugin_name : "*", module_name ? module_name : "*",
1026
- tmp_collector->count);
1027
-
1028
- COLLECTOR_UNLOCK;
1029
-
1030
- _free_collector(tmp_collector);
1031
-
1032
- if (aclk_popcorn_check_bump())
1033
- return;
1034
-
1035
- if (host != localhost)
1036
- return;
1037
-
1038
- query = aclk_query_new(METADATA_INFO);
1039
- query->data.metadata_info.host = localhost; //TODO
1040
- query->data.metadata_info.initial_on_connect = 0;
1041
- aclk_queue_query(query);
1042
-
1043
- query = aclk_query_new(METADATA_ALARMS);
1044
- query->data.metadata_alarms.initial_on_connect = 0;
1045
- aclk_queue_query(query);
1046
-}
1047
-
1048
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
697
void aclk_host_state_update(RRDHOST *host, int cmd)
698
{
699
uuid_t node_id;
700
int ret;
701
1054
- if (!aclk_connected || !aclk_use_new_cloud_arch)
702
+ if (!aclk_connected)
703
return;
704
705
ret = get_node_id(&host->host_uuid, &node_id);
@@ -1158,14 +806,12 @@ void aclk_send_node_instances()
806
}
807
freez(list_head);
808
}
1161
-#endif
809
810
void aclk_send_bin_msg(char *msg, size_t msg_len, enum aclk_topics subtopic, const char *msgname)
811
{
812
aclk_send_bin_message_subtopic_pid(mqttwss_client, msg, msg_len, subtopic, msgname);
813
}
814
1168
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
815
static void fill_alert_status_for_host(BUFFER *wb, RRDHOST *host)
816
{
817
struct proto_alert_status status;
@@ -1221,7 +867,6 @@ static void fill_chart_status_for_host(BUFFER *wb, RRDHOST *host)
867
);
868
freez(stats);
869
}
1224
-#endif
870
871
char *ng_aclk_state(void)
872
{
@@ -1232,13 +877,9 @@ char *ng_aclk_state(void)
877
buffer_strcat(wb,
878
"ACLK Available: Yes\n"
879
"ACLK Version: 2\n"
1235
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1236
- "Protocols Supported: Legacy, Protobuf\n"
1237
-#else
1238
- "Protocols Supported: Legacy\n"
1239
-#endif
880
+ "Protocols Supported: Protobuf\n"
881
);
1241
- buffer_sprintf(wb, "Protocol Used: %s\nMQTT Version: %d\nClaimed: ", aclk_use_new_cloud_arch ? "Protobuf" : "Legacy", use_mqtt_5 ? 5 : 3);
882
+ buffer_sprintf(wb, "Protocol Used: Protobuf\nMQTT Version: %d\nClaimed: ", use_mqtt_5 ? 5 : 3);
883
884
char *agent_id = is_agent_claimed();
885
if (agent_id == NULL)
@@ -1274,7 +915,6 @@ char *ng_aclk_state(void)
915
if (aclk_connected) {
916
buffer_sprintf(wb, "Received Cloud MQTT Messages: %d\nMQTT Messages Confirmed by Remote Broker (PUBACKs): %d", aclk_rcvd_cloud_msgs, aclk_pubacks_per_conn);
917
1277
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
918
RRDHOST *host;
919
rrd_rdlock();
920
rrdhost_foreach_read(host) {
@@ -1309,7 +949,6 @@ char *ng_aclk_state(void)
949
fill_chart_status_for_host(wb, host);
950
}
951
rrd_unlock();
1312
-#endif
952
}
953
954
ret = strdupz(buffer_tostring(wb));
@@ -1317,7 +956,6 @@ char *ng_aclk_state(void)
956
return ret;
957
}
958
1320
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
959
static void fill_alert_status_for_host_json(json_object *obj, RRDHOST *host)
960
{
961
struct proto_alert_status status;
@@ -1382,7 +1020,6 @@ static void fill_chart_status_for_host_json(json_object *obj, RRDHOST *host)
1020
1021
freez(stats);
1022
}
1385
-#endif
1023
1024
static json_object *timestamp_to_json(const time_t *t)
1025
{
@@ -1406,15 +1043,8 @@ char *ng_aclk_state_json(void)
1043
json_object_object_add(msg, "aclk-version", tmp);
1044
1045
grp = json_object_new_array();
1409
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1410
- tmp = json_object_new_string("Legacy");
1411
- json_object_array_add(grp, tmp);
1046
tmp = json_object_new_string("Protobuf");
1047
json_object_array_add(grp, tmp);
1414
-#else
1415
- tmp = json_object_new_string("Legacy");
1416
- json_object_array_add(grp, tmp);
1417
-#endif
1048
json_object_object_add(msg, "protocols-supported", grp);
1049
1050
char *agent_id = is_agent_claimed();
@@ -1435,7 +1065,7 @@ char *ng_aclk_state_json(void)
1065
tmp = json_object_new_boolean(aclk_connected);
1066
json_object_object_add(msg, "online", tmp);
1067
1438
- tmp = json_object_new_string(aclk_use_new_cloud_arch ? "Protobuf" : "Legacy");
1068
+ tmp = json_object_new_string("Protobuf");
1069
json_object_object_add(msg, "used-cloud-protocol", tmp);
1070
1071
tmp = json_object_new_int(use_mqtt_5 ? 5 : 3);
@@ -1462,7 +1092,6 @@ char *ng_aclk_state_json(void)
1092
tmp = json_object_new_boolean(aclk_disable_runtime);
1093
json_object_object_add(msg, "banned-by-cloud", tmp);
1094
1465
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1095
grp = json_object_new_array();
1096
1097
RRDHOST *host;
@@ -1514,7 +1143,6 @@ char *ng_aclk_state_json(void)
1143
}
1144
rrd_unlock();
1145
json_object_object_add(msg, "node-instances", grp);
1517
-#endif
1146
1147
char *str = strdupz(json_object_to_json_string_ext(msg, JSON_C_TO_STRING_PLAIN));
1148
json_object_put(msg);
aclk/aclk.h
-16
@@ -21,9 +21,6 @@ extern netdata_mutex_t aclk_shared_state_mutex;
21
#define ACLK_SHARED_STATE_UNLOCK netdata_mutex_unlock(&aclk_shared_state_mutex)
22
23
extern struct aclk_shared_state {
24
- ACLK_AGENT_STATE agent_state;
25
- time_t last_popcorn_interrupt;
26
-
24
// To wait for `disconnect` message PUBACK
25
// when shutting down
26
// at the same time if > 0 we know link is
@@ -32,21 +29,8 @@ extern struct aclk_shared_state {
29
int mqtt_shutdown_msg_rcvd;
30
} aclk_shared_state;
31
35
-void aclk_alarm_reload(void);
36
-int aclk_update_alarm(RRDHOST *host, ALARM_ENTRY *ae);
37
-
38
-/* Informs ACLK about created/deleted chart
39
- * @param create 0 - if chart was deleted, other if chart created
40
- */
41
-int aclk_update_chart(RRDHOST *host, char *chart_name, int create);
42
-
43
-void aclk_add_collector(RRDHOST *host, const char *plugin_name, const char *module_name);
44
-void aclk_del_collector(RRDHOST *host, const char *plugin_name, const char *module_name);
45
-
46
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
32
void aclk_host_state_update(RRDHOST *host, int cmd);
33
void aclk_send_node_instances(void);
49
-#endif
34
35
void aclk_send_bin_msg(char *msg, size_t msg_len, enum aclk_topics subtopic, const char *msgname);
36
aclk/aclk_api.c
+2
-16
@@ -13,7 +13,6 @@ usec_t aclk_session_us = 0;
13
time_t aclk_session_sec = 0;
14
15
int aclk_disable_runtime = 0;
16
-int aclk_disable_single_updates = 0;
16
17
int aclk_stats_enabled;
18
int use_mqtt_5 = 0;
@@ -33,16 +32,6 @@ void *aclk_starter(void *ptr) {
32
}
33
return aclk_main(ptr);
34
}
36
-
37
-void aclk_single_update_disable()
38
-{
39
- aclk_disable_single_updates = 1;
40
-}
41
-
42
-void aclk_single_update_enable()
43
-{
44
- aclk_disable_single_updates = 0;
45
-}
35
#endif /* ENABLE_ACLK */
36
37
void add_aclk_host_labels(void) {
@@ -71,16 +60,13 @@ void add_aclk_host_labels(void) {
60
break;
61
}
62
63
+
64
int mqtt5 = config_get_boolean(CONFIG_SECTION_CLOUD, "mqtt5", CONFIG_BOOLEAN_YES);
65
+
66
rrdlabels_add(labels, "_mqtt_version", mqtt5 ? "5" : "3", RRDLABEL_SRC_AUTO);
67
rrdlabels_add(labels, "_aclk_impl", "Next Generation", RRDLABEL_SRC_AUTO);
68
rrdlabels_add(labels, "_aclk_proxy", proxy_str, RRDLABEL_SRC_AUTO);
78
-
79
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
69
rrdlabels_add(labels, "_aclk_ng_new_cloud_protocol", "true", RRDLABEL_SRC_AUTO|RRDLABEL_SRC_ACLK);
81
-#else
82
- rrdlabels_add(labels, "_aclk_ng_new_cloud_protocol", "false", RRDLABEL_SRC_AUTO|RRDLABEL_SRC_ACLK);
83
-#endif
70
#endif
71
}
72
aclk/aclk_api.h
-15
@@ -15,31 +15,16 @@ extern usec_t aclk_session_us;
15
extern time_t aclk_session_sec;
16
17
extern int aclk_disable_runtime;
18
-extern int aclk_disable_single_updates;
18
19
extern int aclk_stats_enabled;
20
extern int aclk_alert_reloaded;
21
23
-extern int aclk_ng;
22
extern int use_mqtt_5;
23
24
#ifdef ENABLE_ACLK
25
void *aclk_starter(void *ptr);
26
29
-void aclk_single_update_disable();
30
-void aclk_single_update_enable();
31
-
32
-void aclk_alarm_reload(void);
33
-
34
-int aclk_update_chart(RRDHOST *host, char *chart_name, int create);
35
-int aclk_update_alarm(RRDHOST *host, ALARM_ENTRY *ae);
36
-
37
-void aclk_add_collector(RRDHOST *host, const char *plugin_name, const char *module_name);
38
-void aclk_del_collector(RRDHOST *host, const char *plugin_name, const char *module_name);
39
-
40
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
27
void aclk_host_state_update(RRDHOST *host, int connect);
42
-#endif
28
29
#define NETDATA_ACLK_HOOK \
30
{ .name = "ACLK_Main", \
aclk/aclk_collector_list.c
deleted
-193
@@ -1,193 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-// This is copied from Legacy ACLK, Original Author: amoss
3
-
4
-// TODO unmess this
5
-
6
-#include "aclk_collector_list.h"
7
-
8
-netdata_mutex_t collector_mutex = NETDATA_MUTEX_INITIALIZER;
9
-
10
-struct _collector *collector_list = NULL;
11
-
12
-/*
13
- * Free a collector structure
14
- */
15
-void _free_collector(struct _collector *collector)
16
-{
17
- if (likely(collector->plugin_name))
18
- freez(collector->plugin_name);
19
-
20
- if (likely(collector->module_name))
21
- freez(collector->module_name);
22
-
23
- if (likely(collector->hostname))
24
- freez(collector->hostname);
25
-
26
- freez(collector);
27
-}
28
-
29
-/*
30
- * This will report the collector list
31
- *
32
- */
33
-#ifdef ACLK_DEBUG
34
-static void _dump_collector_list()
35
-{
36
- struct _collector *tmp_collector;
37
-
38
- COLLECTOR_LOCK;
39
-
40
- info("DUMPING ALL COLLECTORS");
41
-
42
- if (unlikely(!collector_list || !collector_list->next)) {
43
- COLLECTOR_UNLOCK;
44
- info("DUMPING ALL COLLECTORS -- nothing found");
45
- return;
46
- }
47
-
48
- // Note that the first entry is "dummy"
49
- tmp_collector = collector_list->next;
50
-
51
- while (tmp_collector) {
52
- info(
53
- "COLLECTOR %s : [%s:%s] count = %u", tmp_collector->hostname,
54
- tmp_collector->plugin_name ? tmp_collector->plugin_name : "",
55
- tmp_collector->module_name ? tmp_collector->module_name : "", tmp_collector->count);
56
-
57
- tmp_collector = tmp_collector->next;
58
- }
59
- info("DUMPING ALL COLLECTORS DONE");
60
- COLLECTOR_UNLOCK;
61
-}
62
-#endif
63
-
64
-/*
65
- * This will cleanup the collector list
66
- *
67
- */
68
-void _reset_collector_list()
69
-{
70
- struct _collector *tmp_collector, *next_collector;
71
-
72
- COLLECTOR_LOCK;
73
-
74
- if (unlikely(!collector_list || !collector_list->next)) {
75
- COLLECTOR_UNLOCK;
76
- return;
77
- }
78
-
79
- // Note that the first entry is "dummy"
80
- tmp_collector = collector_list->next;
81
- collector_list->count = 0;
82
- collector_list->next = NULL;
83
-
84
- // We broke the link; we can unlock
85
- COLLECTOR_UNLOCK;
86
-
87
- while (tmp_collector) {
88
- next_collector = tmp_collector->next;
89
- _free_collector(tmp_collector);
90
- tmp_collector = next_collector;
91
- }
92
-}
93
-
94
-/*
95
- * Find a collector (if it exists)
96
- * Must lock before calling this
97
- * If last_collector is not null, it will return the previous collector in the linked
98
- * list (used in collector delete)
99
- */
100
-static struct _collector *_find_collector(
101
- const char *hostname, const char *plugin_name, const char *module_name, struct _collector **last_collector)
102
-{
103
- struct _collector *tmp_collector, *prev_collector;
104
- uint32_t plugin_hash;
105
- uint32_t module_hash;
106
- uint32_t hostname_hash;
107
-
108
- if (unlikely(!collector_list)) {
109
- collector_list = callocz(1, sizeof(struct _collector));
110
- return NULL;
111
- }
112
-
113
- if (unlikely(!collector_list->next))
114
- return NULL;
115
-
116
- plugin_hash = plugin_name ? simple_hash(plugin_name) : 1;
117
- module_hash = module_name ? simple_hash(module_name) : 1;
118
- hostname_hash = simple_hash(hostname);
119
-
120
- // Note that the first entry is "dummy"
121
- tmp_collector = collector_list->next;
122
- prev_collector = collector_list;
123
- while (tmp_collector) {
124
- if (plugin_hash == tmp_collector->plugin_hash && module_hash == tmp_collector->module_hash &&
125
- hostname_hash == tmp_collector->hostname_hash && (!strcmp(hostname, tmp_collector->hostname)) &&
126
- (!plugin_name || !tmp_collector->plugin_name || !strcmp(plugin_name, tmp_collector->plugin_name)) &&
127
- (!module_name || !tmp_collector->module_name || !strcmp(module_name, tmp_collector->module_name))) {
128
- if (unlikely(last_collector))
129
- *last_collector = prev_collector;
130
-
131
- return tmp_collector;
132
- }
133
-
134
- prev_collector = tmp_collector;
135
- tmp_collector = tmp_collector->next;
136
- }
137
-
138
- return tmp_collector;
139
-}
140
-
141
-/*
142
- * Called to delete a collector
143
- * It will reduce the count (chart_count) and will remove it
144
- * from the linked list if the count reaches zero
145
- * The structure will be returned to the caller to free
146
- * the resources
147
- *
148
- */
149
-struct _collector *_del_collector(const char *hostname, const char *plugin_name, const char *module_name)
150
-{
151
- struct _collector *tmp_collector, *prev_collector = NULL;
152
-
153
- tmp_collector = _find_collector(hostname, plugin_name, module_name, &prev_collector);
154
-
155
- if (likely(tmp_collector)) {
156
- --tmp_collector->count;
157
- if (unlikely(!tmp_collector->count))
158
- prev_collector->next = tmp_collector->next;
159
- }
160
- return tmp_collector;
161
-}
162
-
163
-/*
164
- * Add a new collector (plugin / module) to the list
165
- * If it already exists just update the chart count
166
- *
167
- * Lock before calling
168
- */
169
-struct _collector *_add_collector(const char *hostname, const char *plugin_name, const char *module_name)
170
-{
171
- struct _collector *tmp_collector;
172
-
173
- tmp_collector = _find_collector(hostname, plugin_name, module_name, NULL);
174
-
175
- if (unlikely(!tmp_collector)) {
176
- tmp_collector = callocz(1, sizeof(struct _collector));
177
- tmp_collector->hostname_hash = simple_hash(hostname);
178
- tmp_collector->plugin_hash = plugin_name ? simple_hash(plugin_name) : 1;
179
- tmp_collector->module_hash = module_name ? simple_hash(module_name) : 1;
180
-
181
- tmp_collector->hostname = strdupz(hostname);
182
- tmp_collector->plugin_name = plugin_name ? strdupz(plugin_name) : NULL;
183
- tmp_collector->module_name = module_name ? strdupz(module_name) : NULL;
184
-
185
- tmp_collector->next = collector_list->next;
186
- collector_list->next = tmp_collector;
187
- }
188
- tmp_collector->count++;
189
- debug(
190
- D_ACLK, "ADD COLLECTOR %s [%s:%s] -- chart %u", hostname, plugin_name ? plugin_name : "*",
191
- module_name ? module_name : "*", tmp_collector->count);
192
- return tmp_collector;
193
-}
aclk/aclk_collector_list.h
deleted
-41
@@ -1,41 +0,0 @@
1
-// SPDX-License-Identifier: GPL-3.0-or-later
2
-// This is copied from Legacy ACLK, Original Author: amoss
3
-
4
-// TODO unmess this
5
-
6
-#ifndef ACLK_COLLECTOR_LIST_H
7
-#define ACLK_COLLECTOR_LIST_H
8
-
9
-#include "libnetdata/libnetdata.h"
10
-
11
-extern netdata_mutex_t collector_mutex;
12
-
13
-#define COLLECTOR_LOCK netdata_mutex_lock(&collector_mutex)
14
-#define COLLECTOR_UNLOCK netdata_mutex_unlock(&collector_mutex)
15
-
16
-/*
17
- * Maintain a list of collectors and chart count
18
- * If all the charts of a collector are deleted
19
- * then a new metadata dataset must be send to the cloud
20
- *
21
- */
22
-struct _collector {
23
- time_t created;
24
- uint32_t count; //chart count
25
- uint32_t hostname_hash;
26
- uint32_t plugin_hash;
27
- uint32_t module_hash;
28
- char *hostname;
29
- char *plugin_name;
30
- char *module_name;
31
- struct _collector *next;
32
-};
33
-
34
-extern struct _collector *collector_list;
35
-
36
-struct _collector *_add_collector(const char *hostname, const char *plugin_name, const char *module_name);
37
-struct _collector *_del_collector(const char *hostname, const char *plugin_name, const char *module_name);
38
-void _reset_collector_list();
39
-void _free_collector(struct _collector *collector);
40
-
41
-#endif /* ACLK_COLLECTOR_LIST_H */
aclk/aclk_otp.c
+2
-5
@@ -814,11 +814,8 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
814
return 1;
815
}
816
817
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
818
- buffer_sprintf(buf, "/api/v1/env?v=%s&cap=json,proto&claim_id=%s", &(VERSION[1]) /* skip 'v' at beginning */, agent_id);
819
-#else
820
- buffer_sprintf(buf, "/api/v1/env?v=%s&cap=json&claim_id=%s", &(VERSION[1]) /* skip 'v' at beginning */, agent_id);
821
-#endif
817
+ buffer_sprintf(buf, "/api/v1/env?v=%s&cap=proto&claim_id=%s", &(VERSION[1]) /* skip 'v' at beginning */, agent_id);
818
+
819
freez(agent_id);
820
821
req.host = (char*)aclk_hostname;
aclk/aclk_query.c
+42
-86
@@ -13,27 +13,6 @@ pthread_mutex_t query_lock_wait = PTHREAD_MUTEX_INITIALIZER;
13
#define QUERY_THREAD_LOCK pthread_mutex_lock(&query_lock_wait)
14
#define QUERY_THREAD_UNLOCK pthread_mutex_unlock(&query_lock_wait)
15
16
-typedef struct aclk_query_handler {
17
- aclk_query_type_t type;
18
- char *name; // for logging purposes
19
- int(*fnc)(struct aclk_query_thread *query_thr, aclk_query_t query);
20
-} aclk_query_handler;
21
-
22
-static int info_metadata(struct aclk_query_thread *query_thr, aclk_query_t query)
23
-{
24
- aclk_send_info_metadata(query_thr->client,
25
- !query->data.metadata_info.initial_on_connect,
26
- query->data.metadata_info.host);
27
- return 0;
28
-}
29
-
30
-static int alarms_metadata(struct aclk_query_thread *query_thr, aclk_query_t query)
31
-{
32
- aclk_send_alarm_metadata(query_thr->client,
33
- !query->data.metadata_info.initial_on_connect);
34
- return 0;
35
-}
36
-
16
static usec_t aclk_web_api_v1_request(RRDHOST *host, struct web_client *w, char *url)
17
{
18
usec_t t;
@@ -277,84 +256,61 @@ cleanup:
256
return retval;
257
}
258
280
-static int chart_query(struct aclk_query_thread *query_thr, aclk_query_t query)
281
-{
282
- aclk_chart_msg(query_thr->client, query->data.chart_add_del.host, query->data.chart_add_del.chart_name);
283
- return 0;
284
-}
285
-
286
-static int alarm_state_update_query(struct aclk_query_thread *query_thr, aclk_query_t query)
287
-{
288
- aclk_alarm_state_msg(query_thr->client, query->data.alarm_update);
289
- // aclk_alarm_state_msg frees the json object including the header it generates
290
- query->data.alarm_update = NULL;
291
- return 0;
292
-}
293
-
294
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
259
static int send_bin_msg(struct aclk_query_thread *query_thr, aclk_query_t query)
260
{
261
// this will be simplified when legacy support is removed
262
aclk_send_bin_message_subtopic_pid(query_thr->client, query->data.bin_payload.payload, query->data.bin_payload.size, query->data.bin_payload.topic, query->data.bin_payload.msg_name);
263
return 0;
264
}
301
-#endif
302
-
303
-aclk_query_handler aclk_query_handlers[] = {
304
- { .type = HTTP_API_V2, .name = "http_api_request_v2", .fnc = http_api_v2 },
305
- { .type = ALARM_STATE_UPDATE, .name = "alarm_state_update", .fnc = alarm_state_update_query },
306
- { .type = METADATA_INFO, .name = "info_metadata", .fnc = info_metadata },
307
- { .type = METADATA_ALARMS, .name = "alarms_metadata", .fnc = alarms_metadata },
308
- { .type = CHART_NEW, .name = "chart_new", .fnc = chart_query },
309
- { .type = CHART_DEL, .name = "chart_delete", .fnc = info_metadata },
310
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
311
- { .type = REGISTER_NODE, .name = "register_node", .fnc = send_bin_msg },
312
- { .type = NODE_STATE_UPDATE, .name = "node_state_update", .fnc = send_bin_msg },
313
- { .type = CHART_DIMS_UPDATE, .name = "chart_and_dim_update", .fnc = send_bin_msg },
314
- { .type = CHART_CONFIG_UPDATED, .name = "chart_config_updated", .fnc = send_bin_msg },
315
- { .type = CHART_RESET, .name = "reset_chart_messages", .fnc = send_bin_msg },
316
- { .type = RETENTION_UPDATED, .name = "update_retention_info", .fnc = send_bin_msg },
317
- { .type = UPDATE_NODE_INFO, .name = "update_node_info", .fnc = send_bin_msg },
318
- { .type = ALARM_LOG_HEALTH, .name = "alarm_log_health", .fnc = send_bin_msg },
319
- { .type = ALARM_PROVIDE_CFG, .name = "provide_alarm_config", .fnc = send_bin_msg },
320
- { .type = ALARM_SNAPSHOT, .name = "alarm_snapshot", .fnc = send_bin_msg },
321
-#endif
322
- { .type = UNKNOWN, .name = NULL, .fnc = NULL }
323
-};
265
266
const char *aclk_query_get_name(aclk_query_type_t qt)
267
{
327
- aclk_query_handler *ptr = aclk_query_handlers;
328
- while (ptr->type != UNKNOWN) {
329
- if (ptr->type == qt)
330
- return ptr->name;
331
- ptr++;
268
+ switch (qt) {
269
+ case HTTP_API_V2: return "http_api_request_v2";
270
+ case REGISTER_NODE: return "register_node";
271
+ case NODE_STATE_UPDATE: return "node_state_update";
272
+ case CHART_DIMS_UPDATE: return "chart_and_dim_update";
273
+ case CHART_CONFIG_UPDATED: return "chart_config_updated";
274
+ case CHART_RESET: return "reset_chart_messages";
275
+ case RETENTION_UPDATED: return "update_retention_info";
276
+ case UPDATE_NODE_INFO: return "update_node_info";
277
+ case ALARM_LOG_HEALTH: return "alarm_log_health";
278
+ case ALARM_PROVIDE_CFG: return "provide_alarm_config";
279
+ case ALARM_SNAPSHOT: return "alarm_snapshot";
280
+ default:
281
+ error_report("Unknown query type used %d", (int) qt);
282
+ return "unknown";
283
}
333
- return "unknown";
284
}
285
286
static void aclk_query_process_msg(struct aclk_query_thread *query_thr, aclk_query_t query)
337
-{
338
- for (int i = 0; aclk_query_handlers[i].type != UNKNOWN; i++) {
339
- if (aclk_query_handlers[i].type == query->type) {
340
- worker_is_busy(i);
341
-
342
- debug(D_ACLK, "Processing Queued Message of type: \"%s\"", aclk_query_handlers[i].name);
343
- aclk_query_handlers[i].fnc(query_thr, query);
344
- if (aclk_stats_enabled) {
345
- ACLK_STATS_LOCK;
346
- aclk_metrics_per_sample.queries_dispatched++;
347
- aclk_queries_per_thread[query_thr->idx]++;
348
- aclk_metrics_per_sample.queries_per_type[query->type]++;
349
- ACLK_STATS_UNLOCK;
350
- }
351
- aclk_query_free(query);
287
+{
288
+ if (query->type == UNKNOWN || query->type >= ACLK_QUERY_TYPE_COUNT) {
289
+ error_report("Unknown query in query queue. %u", query->type);
290
+ aclk_query_free(query);
291
+ return;
292
+ }
293
353
- worker_is_idle();
354
- return;
355
- }
294
+ worker_is_busy(query->type);
295
+ if (query->type == HTTP_API_V2) {
296
+ debug(D_ACLK, "Processing Queued Message of type: \"http_api_request_v2\"");
297
+ http_api_v2(query_thr, query);
298
+ } else {
299
+ debug(D_ACLK, "Processing Queued Message of type: \"%s\"", query->data.bin_payload.msg_name);
300
+ send_bin_msg(query_thr, query);
301
}
357
- fatal("Unknown query in query queue. %u", query->type);
302
+
303
+ if (aclk_stats_enabled) {
304
+ ACLK_STATS_LOCK;
305
+ aclk_metrics_per_sample.queries_dispatched++;
306
+ aclk_queries_per_thread[query_thr->idx]++;
307
+ aclk_metrics_per_sample.queries_per_type[query->type]++;
308
+ ACLK_STATS_UNLOCK;
309
+ }
310
+
311
+ aclk_query_free(query);
312
+
313
+ worker_is_idle();
314
}
315
316
/* Processes messages from queue. Compete for work with other threads
@@ -370,8 +326,8 @@ int aclk_query_process_msgs(struct aclk_query_thread *query_thr)
326
327
static void worker_aclk_register(void) {
328
worker_register("ACLKQUERY");
373
- for (int i = 0; aclk_query_handlers[i].type != UNKNOWN; i++) {
374
- worker_register_job_name(i, aclk_query_handlers[i].name);
329
+ for (int i = 1; i < ACLK_QUERY_TYPE_COUNT; i++) {
330
+ worker_register_job_name(i, aclk_query_get_name(i));
331
}
332
}
333
aclk/aclk_query_queue.c
-9
@@ -111,15 +111,6 @@ void aclk_query_free(aclk_query_t query)
111
freez(query->data.http_api_v2.query);
112
break;
113
114
- case CHART_NEW:
115
- freez(query->data.chart_add_del.chart_name);
116
- break;
117
-
118
- case ALARM_STATE_UPDATE:
119
- if (query->data.alarm_update)
120
- json_object_put(query->data.alarm_update);
121
- break;
122
-
114
case NODE_STATE_UPDATE:
115
case REGISTER_NODE:
116
case CHART_DIMS_UPDATE:
aclk/aclk_query_queue.h
-19
@@ -11,12 +11,7 @@
11
12
typedef enum {
13
UNKNOWN = 0,
14
- METADATA_INFO,
15
- METADATA_ALARMS,
14
HTTP_API_V2,
17
- CHART_NEW,
18
- CHART_DEL,
19
- ALARM_STATE_UPDATE,
15
REGISTER_NODE,
16
NODE_STATE_UPDATE,
17
CHART_DIMS_UPDATE,
@@ -30,16 +25,6 @@ typedef enum {
25
ACLK_QUERY_TYPE_COUNT // always keep this as last
26
} aclk_query_type_t;
27
33
-struct aclk_query_metadata {
34
- RRDHOST *host;
35
- int initial_on_connect;
36
-};
37
-
38
-struct aclk_query_chart_add_del {
39
- RRDHOST *host;
40
- char* chart_name;
41
-};
42
-
28
struct aclk_query_http_api_v2 {
29
char *payload;
30
char *query;
@@ -73,12 +58,8 @@ struct aclk_query {
58
// TODO maybe remove?
59
int version;
60
union {
76
- struct aclk_query_metadata metadata_info;
77
- struct aclk_query_metadata metadata_alarms;
61
struct aclk_query_http_api_v2 http_api_v2;
79
- struct aclk_query_chart_add_del chart_add_del;
62
struct aclk_bin_payload bin_payload;
81
- json_object *alarm_update;
63
} data;
64
};
65
aclk/aclk_rrdhost_state.h
-34
@@ -3,43 +3,9 @@
3
4
#include "libnetdata/libnetdata.h"
5
6
-#ifdef ACLK_LEGACY
7
-typedef enum aclk_cmd {
8
- ACLK_CMD_CLOUD,
9
- ACLK_CMD_ONCONNECT,
10
- ACLK_CMD_INFO,
11
- ACLK_CMD_CHART,
12
- ACLK_CMD_CHARTDEL,
13
- ACLK_CMD_ALARM,
14
- ACLK_CMD_CLOUD_QUERY_2,
15
- ACLK_CMD_CHILD_CONNECT,
16
- ACLK_CMD_CHILD_DISCONNECT
17
-} ACLK_CMD;
18
-
19
-typedef enum aclk_metadata_state {
20
- ACLK_METADATA_REQUIRED,
21
- ACLK_METADATA_CMD_QUEUED,
22
- ACLK_METADATA_SENT
23
-} ACLK_METADATA_STATE;
24
-#endif
25
-
26
-typedef enum aclk_agent_state {
27
- ACLK_HOST_INITIALIZING,
28
- ACLK_HOST_STABLE
29
-} ACLK_AGENT_STATE;
30
-
6
typedef struct aclk_rrdhost_state {
7
char *claimed_id; // Claimed ID if host has one otherwise NULL
8
char *prev_claimed_id; // Claimed ID if changed (reclaimed) during runtime
34
-
35
-#ifdef ACLK_LEGACY
36
- // per child popcorning
37
- ACLK_AGENT_STATE state;
38
- ACLK_METADATA_STATE metadata;
39
-
40
- time_t timestamp_created;
41
- time_t t_last_popcorn_update;
42
-#endif /* ACLK_LEGACY */
9
} aclk_rrdhost_state;
10
11
#endif /* ACLK_RRDHOST_STATE_H */
aclk/aclk_rx_msgs.c
-14
@@ -116,20 +116,8 @@ static inline int aclk_v2_payload_get_query(const char *payload, char **query_ur
116
return 0;
117
}
118
119
-#define HTTP_CHECK_AGENT_INITIALIZED() ACLK_SHARED_STATE_LOCK;\
120
- if (unlikely(aclk_shared_state.agent_state == ACLK_HOST_INITIALIZING)) {\
121
- debug(D_ACLK, "Ignoring \"http\" cloud request; agent not in stable state");\
122
- ACLK_SHARED_STATE_UNLOCK;\
123
- return 1;\
124
- }\
125
- ACLK_SHARED_STATE_UNLOCK;
126
-
119
static int aclk_handle_cloud_http_request_v2(struct aclk_request *cloud_to_agent, char *raw_payload)
120
{
129
- if (!aclk_use_new_cloud_arch) {
130
- HTTP_CHECK_AGENT_INITIALIZED();
131
- }
132
-
121
aclk_query_t query;
122
123
errno = 0;
@@ -229,7 +217,6 @@ err_cleanup:
217
return 1;
218
}
219
232
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
220
typedef uint32_t simple_hash_t;
221
typedef int(*rx_msg_handler)(const char *msg, size_t msg_len);
222
@@ -524,4 +511,3 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
511
return;
512
}
513
}
527
-#endif
aclk/aclk_rx_msgs.h
-2
@@ -10,10 +10,8 @@
10
11
int aclk_handle_cloud_cmd_message(char *payload);
12
13
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
13
const char *rx_handler_get_name(size_t i);
14
unsigned int aclk_init_rx_msg_handlers(void);
15
void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t msg_len);
17
-#endif
16
17
#endif /* ACLK_RX_MSGS_H */
aclk/aclk_stats.c
+2
-16
@@ -8,11 +8,9 @@ netdata_mutex_t aclk_stats_mutex = NETDATA_MUTEX_INITIALIZER;
8
9
struct {
10
int query_thread_count;
11
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
11
unsigned int proto_hdl_cnt;
12
uint32_t *aclk_proto_rx_msgs_sample;
13
RRDDIM **rx_msg_dims;
15
-#endif
14
} aclk_stats_cfg; // there is only 1 stats thread at a time
15
16
// data ACLK stats need per query thread
@@ -237,7 +235,6 @@ static void aclk_stats_query_time(struct aclk_metrics_per_sample *per_sample)
235
rrdset_done(st);
236
}
237
240
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
238
const char *rx_handler_get_name(size_t i);
239
static void aclk_stats_newproto_rx(uint32_t *rx_msgs_sample)
240
{
@@ -259,7 +256,6 @@ static void aclk_stats_newproto_rx(uint32_t *rx_msgs_sample)
256
257
rrdset_done(st);
258
}
262
-#endif
259
260
static void aclk_stats_mqtt_wss(struct mqtt_wss_stats *stats)
261
{
@@ -290,31 +286,23 @@ static void aclk_stats_mqtt_wss(struct mqtt_wss_stats *stats)
286
287
void aclk_stats_thread_prepare(int query_thread_count, unsigned int proto_hdl_cnt)
288
{
293
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
294
- UNUSED(proto_hdl_cnt);
295
-#endif
296
-
289
aclk_qt_data = callocz(query_thread_count, sizeof(struct aclk_qt_data));
290
aclk_queries_per_thread = callocz(query_thread_count, sizeof(uint32_t));
291
aclk_queries_per_thread_sample = callocz(query_thread_count, sizeof(uint32_t));
292
293
memset(&aclk_metrics_per_sample, 0, sizeof(struct aclk_metrics_per_sample));
294
303
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
295
aclk_stats_cfg.proto_hdl_cnt = proto_hdl_cnt;
296
aclk_stats_cfg.aclk_proto_rx_msgs_sample = callocz(proto_hdl_cnt, sizeof(*aclk_proto_rx_msgs_sample));
297
aclk_proto_rx_msgs_sample = callocz(proto_hdl_cnt, sizeof(*aclk_proto_rx_msgs_sample));
298
aclk_stats_cfg.rx_msg_dims = callocz(proto_hdl_cnt, sizeof(RRDDIM*));
308
-#endif
299
}
300
301
void aclk_stats_thread_cleanup()
302
{
313
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
303
freez(aclk_stats_cfg.rx_msg_dims);
304
freez(aclk_proto_rx_msgs_sample);
305
freez(aclk_stats_cfg.aclk_proto_rx_msgs_sample);
317
-#endif
306
freez(aclk_qt_data);
307
freez(aclk_queries_per_thread);
308
freez(aclk_queries_per_thread_sample);
@@ -345,10 +333,10 @@ void *aclk_stats_main_thread(void *ptr)
333
// to not hold lock longer than necessary, especially not to hold it
334
// during database rrd* operations
335
memcpy(&per_sample, &aclk_metrics_per_sample, sizeof(struct aclk_metrics_per_sample));
348
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
336
+
337
memcpy(aclk_stats_cfg.aclk_proto_rx_msgs_sample, aclk_proto_rx_msgs_sample, sizeof(*aclk_proto_rx_msgs_sample) * aclk_stats_cfg.proto_hdl_cnt);
338
memset(aclk_proto_rx_msgs_sample, 0, sizeof(*aclk_proto_rx_msgs_sample) * aclk_stats_cfg.proto_hdl_cnt);
351
-#endif
339
+
340
memcpy(&permanent, &aclk_metrics, sizeof(struct aclk_metrics));
341
memset(&aclk_metrics_per_sample, 0, sizeof(struct aclk_metrics_per_sample));
342
@@ -373,9 +361,7 @@ void *aclk_stats_main_thread(void *ptr)
361
struct mqtt_wss_stats mqtt_wss_stats = mqtt_wss_get_stats(args->client);
362
aclk_stats_mqtt_wss(&mqtt_wss_stats);
363
376
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
364
aclk_stats_newproto_rx(aclk_stats_cfg.aclk_proto_rx_msgs_sample);
378
-#endif
365
}
366
367
return 0;
aclk/aclk_stats.h
-2
@@ -62,9 +62,7 @@ extern struct aclk_metrics_per_sample {
62
volatile uint32_t cloud_q_process_max;
63
} aclk_metrics_per_sample;
64
65
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
65
extern uint32_t *aclk_proto_rx_msgs_sample;
67
-#endif
66
67
extern uint32_t *aclk_queries_per_thread;
68
aclk/aclk_tx_msgs.c
-217
@@ -13,29 +13,6 @@
13
// version for aclk legacy (old cloud arch)
14
#define ACLK_VERSION 2
15
16
-static void aclk_send_message_subtopic(mqtt_wss_client client, json_object *msg, enum aclk_topics subtopic)
17
-{
18
- uint16_t packet_id;
19
- const char *str = json_object_to_json_string_ext(msg, JSON_C_TO_STRING_PLAIN);
20
- const char *topic = aclk_get_topic(subtopic);
21
-
22
- if (unlikely(!topic)) {
23
- error("Couldn't get topic. Aborting message send");
24
- return;
25
- }
26
-
27
- mqtt_wss_publish_pid(client, topic, str, strlen(str), MQTT_WSS_PUB_QOS1, &packet_id);
28
-#ifdef NETDATA_INTERNAL_CHECKS
29
- aclk_stats_msg_published(packet_id);
30
-#endif
31
-#ifdef ACLK_LOG_CONVERSATION_DIR
32
-#define FN_MAX_LEN 1024
33
- char filename[FN_MAX_LEN];
34
- snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-tx.json", ACLK_GET_CONV_LOG_NEXT());
35
- json_object_to_file_ext(filename, msg, JSON_C_TO_STRING_PRETTY);
36
-#endif
37
-}
38
-
16
uint16_t aclk_send_bin_message_subtopic_pid(mqtt_wss_client client, char *msg, size_t msg_len, enum aclk_topics subtopic, const char *msgname)
17
{
18
#ifndef ACLK_LOG_CONVERSATION_DIR
@@ -71,30 +48,6 @@ uint16_t aclk_send_bin_message_subtopic_pid(mqtt_wss_client client, char *msg, s
48
return packet_id;
49
}
50
74
-static uint16_t aclk_send_message_subtopic_pid(mqtt_wss_client client, json_object *msg, enum aclk_topics subtopic)
75
-{
76
- uint16_t packet_id;
77
- const char *str = json_object_to_json_string_ext(msg, JSON_C_TO_STRING_PLAIN);
78
- const char *topic = aclk_get_topic(subtopic);
79
-
80
- if (unlikely(!topic)) {
81
- error("Couldn't get topic. Aborting message send");
82
- return 0;
83
- }
84
-
85
- mqtt_wss_publish_pid(client, topic, str, strlen(str), MQTT_WSS_PUB_QOS1, &packet_id);
86
-#ifdef NETDATA_INTERNAL_CHECKS
87
- aclk_stats_msg_published(packet_id);
88
-#endif
89
-#ifdef ACLK_LOG_CONVERSATION_DIR
90
-#define FN_MAX_LEN 1024
91
- char filename[FN_MAX_LEN];
92
- snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-tx.json", ACLK_GET_CONV_LOG_NEXT());
93
- json_object_to_file_ext(filename, msg, JSON_C_TO_STRING_PRETTY);
94
-#endif
95
- return packet_id;
96
-}
97
-
51
/* UNUSED now but can be used soon MVP1?
52
static void aclk_send_message_topic(mqtt_wss_client client, json_object *msg, const char *topic)
53
{
@@ -231,17 +184,6 @@ static struct json_object *create_hdr(const char *type, const char *msg_id, time
184
return obj;
185
}
186
234
-static char *create_uuid()
235
-{
236
- uuid_t uuid;
237
- char *uuid_str = mallocz(36 + 1);
238
-
239
- uuid_generate(uuid);
240
- uuid_unparse(uuid, uuid_str);
241
-
242
- return uuid_str;
243
-}
244
-
187
#ifndef __GNUC__
188
#pragma endregion
189
#endif
@@ -250,90 +192,6 @@ static char *create_uuid()
192
#pragma region aclk_tx_msgs message generators
193
#endif
194
253
-/*
254
- * This will send the /api/v1/info
255
- */
256
-#define BUFFER_INITIAL_SIZE (1024 * 16)
257
-void aclk_send_info_metadata(mqtt_wss_client client, int metadata_submitted, RRDHOST *host)
258
-{
259
- BUFFER *local_buffer = buffer_create(BUFFER_INITIAL_SIZE);
260
- json_object *msg, *payload, *tmp;
261
-
262
- char *msg_id = create_uuid();
263
- buffer_flush(local_buffer);
264
- local_buffer->contenttype = CT_APPLICATION_JSON;
265
-
266
- // on_connect messages are sent on a health reload, if the on_connect message is real then we
267
- // use the session time as the fake timestamp to indicate that it starts the session. If it is
268
- // a fake on_connect message then use the real timestamp to indicate it is within the existing
269
- // session.
270
- if (metadata_submitted)
271
- msg = create_hdr("update", msg_id, 0, 0, ACLK_VERSION);
272
- else
273
- msg = create_hdr("connect", msg_id, aclk_session_sec, aclk_session_us, ACLK_VERSION);
274
-
275
- payload = json_object_new_object();
276
- json_object_object_add(msg, "payload", payload);
277
-
278
- web_client_api_request_v1_info_fill_buffer(host, local_buffer);
279
- tmp = json_tokener_parse(local_buffer->buffer);
280
- json_object_object_add(payload, "info", tmp);
281
-
282
- buffer_flush(local_buffer);
283
-
284
- charts2json(host, local_buffer, 1, 0);
285
- tmp = json_tokener_parse(local_buffer->buffer);
286
- json_object_object_add(payload, "charts", tmp);
287
-
288
- aclk_send_message_subtopic(client, msg, ACLK_TOPICID_METADATA);
289
-
290
- json_object_put(msg);
291
- freez(msg_id);
292
- buffer_free(local_buffer);
293
-}
294
-
295
-// TODO should include header instead
296
-void health_active_log_alarms_2json(RRDHOST *host, BUFFER *wb);
297
-
298
-void aclk_send_alarm_metadata(mqtt_wss_client client, int metadata_submitted)
299
-{
300
- BUFFER *local_buffer = buffer_create(BUFFER_INITIAL_SIZE);
301
- json_object *msg, *payload, *tmp;
302
-
303
- char *msg_id = create_uuid();
304
- buffer_flush(local_buffer);
305
- local_buffer->contenttype = CT_APPLICATION_JSON;
306
-
307
- // on_connect messages are sent on a health reload, if the on_connect message is real then we
308
- // use the session time as the fake timestamp to indicate that it starts the session. If it is
309
- // a fake on_connect message then use the real timestamp to indicate it is within the existing
310
- // session.
311
-
312
- if (metadata_submitted)
313
- msg = create_hdr("connect_alarms", msg_id, 0, 0, ACLK_VERSION);
314
- else
315
- msg = create_hdr("connect_alarms", msg_id, aclk_session_sec, aclk_session_us, ACLK_VERSION);
316
-
317
- payload = json_object_new_object();
318
- json_object_object_add(msg, "payload", payload);
319
-
320
- health_alarms2json(localhost, local_buffer, 1);
321
- tmp = json_tokener_parse(local_buffer->buffer);
322
- json_object_object_add(payload, "configured-alarms", tmp);
323
-
324
- buffer_flush(local_buffer);
325
-
326
- health_active_log_alarms_2json(localhost, local_buffer);
327
- tmp = json_tokener_parse(local_buffer->buffer);
328
- json_object_object_add(payload, "alarms-active", tmp);
329
-
330
- aclk_send_message_subtopic(client, msg, ACLK_TOPICID_ALARMS);
331
-
332
- json_object_put(msg);
333
- freez(msg_id);
334
- buffer_free(local_buffer);
335
-}
336
-
195
void aclk_http_msg_v2_err(mqtt_wss_client client, const char *topic, const char *msg_id, int http_code, int ec, const char* emsg, const char *payload, size_t payload_len)
196
{
197
json_object *tmp, *msg;
@@ -384,80 +242,6 @@ void aclk_http_msg_v2(mqtt_wss_client client, const char *topic, const char *msg
242
}
243
}
244
387
-void aclk_chart_msg(mqtt_wss_client client, RRDHOST *host, const char *chart)
388
-{
389
- json_object *msg, *payload;
390
- BUFFER *tmp_buffer;
391
- RRDSET *st;
392
-
393
- st = rrdset_find(host, chart);
394
- if (!st)
395
- st = rrdset_find_byname(host, chart);
396
- if (!st) {
397
- info("FAILED to find chart %s", chart);
398
- return;
399
- }
400
-
401
- tmp_buffer = buffer_create(BUFFER_INITIAL_SIZE);
402
- rrdset2json(st, tmp_buffer, NULL, NULL, 1);
403
- payload = json_tokener_parse(tmp_buffer->buffer);
404
- if (!payload) {
405
- error("Failed to parse JSON from rrdset2json");
406
- buffer_free(tmp_buffer);
407
- return;
408
- }
409
-
410
- msg = create_hdr("chart", NULL, 0, 0, ACLK_VERSION);
411
- json_object_object_add(msg, "payload", payload);
412
-
413
- aclk_send_message_subtopic(client, msg, ACLK_TOPICID_CHART);
414
-
415
- buffer_free(tmp_buffer);
416
- json_object_put(msg);
417
-}
418
-
419
-void aclk_alarm_state_msg(mqtt_wss_client client, json_object *msg)
420
-{
421
- // we create header here on purpose (and not send message with it already as `msg` param)
422
- // timestamps etc. which in ACLK legacy would be wrong (because ACLK legacy
423
- // send message with timestamps already to Query Queue they would be incorrect at time
424
- // when query queue would get to send them)
425
- json_object *obj = create_hdr("status-change", NULL, 0, 0, ACLK_VERSION);
426
- json_object_object_add(obj, "payload", msg);
427
-
428
- aclk_send_message_subtopic(client, obj, ACLK_TOPICID_ALARMS);
429
- json_object_put(obj);
430
-}
431
-
432
-/*
433
- * Will generate disconnect message.
434
- * @param message if NULL it will generate LWT message (unexpected).
435
- * Otherwise string pointed to by this parameter will be used as
436
- * reason.
437
- */
438
-json_object *aclk_generate_disconnect(const char *message)
439
-{
440
- json_object *tmp, *msg;
441
-
442
- msg = create_hdr("disconnect", NULL, 0, 0, 2);
443
-
444
- tmp = json_object_new_string(message ? message : "unexpected");
445
- json_object_object_add(msg, "payload", tmp);
446
-
447
- return msg;
448
-}
449
-
450
-int aclk_send_app_layer_disconnect(mqtt_wss_client client, const char *message)
451
-{
452
- int pid;
453
- json_object *msg = aclk_generate_disconnect(message);
454
- pid = aclk_send_message_subtopic_pid(client, msg, ACLK_TOPICID_METADATA);
455
- json_object_put(msg);
456
- return pid;
457
-}
458
-
459
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
460
-// new protobuf msgs
245
uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable) {
246
size_t len;
247
uint16_t pid;
@@ -532,7 +316,6 @@ char *aclk_generate_lwt(size_t *size) {
316
317
return msg;
318
}
535
-#endif /* ENABLE_NEW_CLOUD_PROTOCOL */
319
320
#ifndef __GNUC__
321
#pragma endregion
aclk/aclk_tx_msgs.h
-13
@@ -11,23 +11,10 @@
11
12
uint16_t aclk_send_bin_message_subtopic_pid(mqtt_wss_client client, char *msg, size_t msg_len, enum aclk_topics subtopic, const char *msgname);
13
14
-void aclk_send_info_metadata(mqtt_wss_client client, int metadata_submitted, RRDHOST *host);
15
-void aclk_send_alarm_metadata(mqtt_wss_client client, int metadata_submitted);
16
-
14
void aclk_http_msg_v2_err(mqtt_wss_client client, const char *topic, const char *msg_id, int http_code, int ec, const char* emsg, const char *payload, size_t payload_len);
15
void aclk_http_msg_v2(mqtt_wss_client client, const char *topic, const char *msg_id, usec_t t_exec, usec_t created, int http_code, const char *payload, size_t payload_len);
16
20
-void aclk_chart_msg(mqtt_wss_client client, RRDHOST *host, const char *chart);
21
-
22
-void aclk_alarm_state_msg(mqtt_wss_client client, json_object *msg);
23
-
24
-json_object *aclk_generate_disconnect(const char *message);
25
-int aclk_send_app_layer_disconnect(mqtt_wss_client client, const char *message);
26
-
27
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
28
-// new protobuf msgs
17
uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable);
18
char *aclk_generate_lwt(size_t *size);
31
-#endif
19
20
#endif
aclk/aclk_util.c
+4
-15
@@ -4,7 +4,6 @@
4
5
#include "daemon/common.h"
6
7
-int aclk_use_new_cloud_arch = 0;
7
usec_t aclk_session_newarch = 0;
8
9
aclk_env_t *aclk_env = NULL;
@@ -127,19 +126,11 @@ struct topic_name {
126
{ .id = ACLK_TOPICID_UNKNOWN, .name = NULL }
127
};
128
130
-enum aclk_topics compulsory_topics_legacy[] = {
131
- ACLK_TOPICID_CHART,
132
- ACLK_TOPICID_ALARMS,
133
- ACLK_TOPICID_METADATA,
134
- ACLK_TOPICID_COMMAND,
135
- ACLK_TOPICID_UNKNOWN
136
-};
137
-
138
-enum aclk_topics compulsory_topics_new_cloud_arch[] = {
129
+enum aclk_topics compulsory_topics[] = {
130
// TODO remove old topics once not needed anymore
140
- ACLK_TOPICID_CHART,
141
- ACLK_TOPICID_ALARMS,
142
- ACLK_TOPICID_METADATA,
131
+ ACLK_TOPICID_CHART, //TODO from legacy
132
+ ACLK_TOPICID_ALARMS, //TODO from legacy
133
+ ACLK_TOPICID_METADATA, //TODO from legacy
134
ACLK_TOPICID_COMMAND,
135
ACLK_TOPICID_AGENT_CONN,
136
ACLK_TOPICID_CMD_NG_V1,
@@ -279,8 +270,6 @@ int aclk_generate_topic_cache(struct json_object *json)
270
}
271
}
272
282
- enum aclk_topics *compulsory_topics = aclk_use_new_cloud_arch ? compulsory_topics_new_cloud_arch : compulsory_topics_legacy;
283
-
273
for (int i = 0; compulsory_topics[i] != ACLK_TOPICID_UNKNOWN; i++) {
274
if (!aclk_get_topic(compulsory_topics[i])) {
275
error("missing compulsory topic \"%s\" in password response from cloud", topic_id_to_name(compulsory_topics[i]));
aclk/aclk_util.h
-1
@@ -20,7 +20,6 @@
20
21
// Helper stuff which should not have any further inside ACLK dependency
22
// and are supposed not to be needed outside of ACLK
23
-extern int aclk_use_new_cloud_arch;
23
extern usec_t aclk_session_newarch;
24
25
extern int chart_batch_id;
configure.ac
+30
-53
@@ -218,14 +218,6 @@ AC_ARG_ENABLE(
218
[ enable_cloud="detect" ]
219
)
220
221
-AC_ARG_WITH(
222
- [new-cloud-protocol],
223
- [AS_HELP_STRING([--with-new-cloud-protocol],
224
- [Requires New Cloud Protocol support to be built])],
225
- [new_cloud_protocol="$withval"],
226
- [new_cloud_protocol="detect"]
227
-)
228
-
221
if test "${enable_cloud}" = "no"; then
222
AC_DEFINE([DISABLE_CLOUD], [1], [disable netdata cloud functionality])
223
fi
@@ -768,16 +760,16 @@ AC_MSG_CHECKING([if Cloud functionality should be enabled])
760
AC_MSG_RESULT([${enable_cloud}])
761
762
if test "$enable_cloud" != "no"; then
771
- AC_MSG_NOTICE([Checking if ACLK Next Generation can be built])
763
+ AC_MSG_NOTICE([Checking if ACLK can be built])
764
can_enable_ng="yes"
773
- AC_MSG_CHECKING([if git submodules present for ACLK Next Generation])
765
+ AC_MSG_CHECKING([if git submodules present for ACLK])
766
if test -f "mqtt_websockets/src/mqtt_wss_client.c"; then
767
AC_MSG_RESULT([yes])
768
else
769
AC_MSG_RESULT([no])
770
can_enable_ng="no"
771
fi
780
- AC_MSG_CHECKING([if SSL available for ACLK Next Generation])
772
+ AC_MSG_CHECKING([if SSL available for ACLK])
773
if test -n "${SSL_LIBS}"; then
774
AC_MSG_RESULT([yes])
775
OPTIONAL_SSL_CFLAGS="${SSL_CFLAGS}"
@@ -785,7 +777,7 @@ if test "$enable_cloud" != "no"; then
777
else
778
AC_MSG_RESULT([no])
779
fi
788
- AC_MSG_CHECKING([if JSON-C available for ACLK Next Generation])
780
+ AC_MSG_CHECKING([if JSON-C available for ACLK])
781
if test "$enable_jsonc" != "yes"; then
782
AC_MSG_RESULT([no])
783
can_enable_ng="no"
@@ -793,6 +785,28 @@ if test "$enable_cloud" != "no"; then
785
AC_MSG_RESULT([yes])
786
fi
787
788
+ AC_MSG_CHECKING([if protobuf available for ACLK New Cloud Protocol])
789
+ if test "${have_libprotobuf}" != "yes"; then
790
+ AC_MSG_RESULT([no])
791
+ can_enable_ng="no"
792
+ else
793
+ AC_MSG_RESULT([yes])
794
+ fi
795
+ AC_MSG_CHECKING([if protoc available for ACLK New Cloud Protocol])
796
+ if test "${have_protoc}" != "yes"; then
797
+ AC_MSG_RESULT([no])
798
+ can_enable_ng="no"
799
+ else
800
+ AC_MSG_RESULT([yes])
801
+ fi
802
+ AC_MSG_CHECKING([if C++ compiler available for ACLK New Cloud Protocol])
803
+ if test "${have_CXX_compiler}" != "yes"; then
804
+ AC_MSG_RESULT([no])
805
+ can_enable_ng="no"
806
+ else
807
+ AC_MSG_RESULT([yes])
808
+ fi
809
+
810
AC_MSG_CHECKING([ACLK Next Generation can be built])
811
AC_MSG_RESULT([${can_enable_ng}])
812
if test "$can_enable_ng" = "no" -a "$enable_cloud" = "yes"; then
@@ -801,46 +815,10 @@ if test "$enable_cloud" != "no"; then
815
if test "$can_enable_ng" = "yes"; then
816
enable_aclk="yes"
817
AC_DEFINE([ENABLE_ACLK], [1], [netdata ACLK])
804
- OPTIONAL_ACLK_CFLAGS="-I \$(abs_top_srcdir)/mqtt_websockets/src/include -I \$(abs_top_srcdir)/mqtt_websockets/c-rbuf/include -I \$(abs_top_srcdir)/mqtt_websockets/MQTT-C/include"
805
- fi
806
-
807
- if test "$new_cloud_protocol" != "no"; then
808
- can_build_new_cloud_protocol="yes"
809
- AC_MSG_CHECKING([if protobuf available for New Cloud Protocol])
810
- if test "${have_libprotobuf}" != "yes"; then
811
- AC_MSG_RESULT([no])
812
- can_build_new_cloud_protocol="no"
813
- else
814
- AC_MSG_RESULT([yes])
815
- fi
816
- AC_MSG_CHECKING([if protoc available for New Cloud Protocol])
817
- if test "${have_protoc}" != "yes"; then
818
- AC_MSG_RESULT([no])
819
- can_build_new_cloud_protocol="no"
820
- else
821
- AC_MSG_RESULT([yes])
822
- fi
823
- AC_MSG_CHECKING([if C++ compiler available for New Cloud Protocol])
824
- if test "${have_CXX_compiler}" != "yes"; then
825
- AC_MSG_RESULT([no])
826
- can_build_new_cloud_protocol="no"
827
- else
828
- AC_MSG_RESULT([yes])
829
- fi
830
-
831
- AC_MSG_CHECKING([ACLK Next Generation can support New Cloud protocol])
832
- AC_MSG_RESULT([${can_build_new_cloud_protocol}])
833
- if test "$new_cloud_protocol" = "yes" -a "$can_build_new_cloud_protocol" != "yes"; then
834
- AC_MSG_ERROR([Requested new cloud protocol support but it can't be build])
835
- fi
836
- if test "$can_build_new_cloud_protocol" = "yes"; then
837
- new_cloud_protocol="yes"
838
- AC_DEFINE([ENABLE_NEW_CLOUD_PROTOCOL], [1], [New protobuf based Netdata Cloud Protocol Support])
839
- OPTIONAL_ACLK_CFLAGS="${OPTIONAL_ACLK_CFLAGS} -I \$(abs_top_srcdir)/aclk/aclk-schemas"
840
- OPTIONAL_PROTOBUF_CFLAGS="${PROTOBUF_CFLAGS}"
841
- CXX11FLAG="-std=c++11"
842
- OPTIONAL_PROTOBUF_LIBS="${PROTOBUF_LIBS}"
843
- fi
818
+ OPTIONAL_ACLK_CFLAGS="-I \$(abs_top_srcdir)/mqtt_websockets/src/include -I \$(abs_top_srcdir)/mqtt_websockets/c-rbuf/include -I \$(abs_top_srcdir)/mqtt_websockets/MQTT-C/include -I \$(abs_top_srcdir)/aclk/aclk-schemas"
819
+ OPTIONAL_PROTOBUF_CFLAGS="${PROTOBUF_CFLAGS}"
820
+ CXX11FLAG="-std=c++11"
821
+ OPTIONAL_PROTOBUF_LIBS="${PROTOBUF_LIBS}"
822
fi
823
fi
824
@@ -851,7 +829,6 @@ fi
829
AC_SUBST([enable_cloud])
830
AC_SUBST([enable_aclk])
831
AM_CONDITIONAL([ENABLE_ACLK], [test "${enable_aclk}" = "yes"])
854
-AM_CONDITIONAL([ENABLE_NEW_CLOUD_PROTOCOL], [test "${can_build_new_cloud_protocol}" = "yes"])
832
833
# -----------------------------------------------------------------------------
834
# apps.plugin
daemon/analytics.c
+2
-7
@@ -7,7 +7,7 @@ struct analytics_data analytics_data;
7
extern void analytics_exporting_connectors (BUFFER *b);
8
extern void analytics_exporting_connectors_ssl (BUFFER *b);
9
extern void analytics_build_info (BUFFER *b);
10
-extern int aclk_connected, aclk_use_new_cloud_arch;
10
+extern int aclk_connected;
11
12
struct collector {
13
char *plugin;
@@ -499,12 +499,7 @@ void analytics_aclk(void)
499
#ifdef ENABLE_ACLK
500
if (aclk_connected) {
501
analytics_set_data(&analytics_data.netdata_host_aclk_available, "true");
502
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
503
- if (aclk_use_new_cloud_arch)
504
- analytics_set_data_str(&analytics_data.netdata_host_aclk_protocol, "New");
505
- else
506
-#endif
507
- analytics_set_data_str(&analytics_data.netdata_host_aclk_protocol, "Legacy");
502
+ analytics_set_data_str(&analytics_data.netdata_host_aclk_protocol, "New");
503
}
504
else
505
#endif
daemon/buildinfo.c
+3
-12
@@ -20,12 +20,6 @@
20
#endif
21
#endif
22
23
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
24
-#define NEW_CLOUD_PROTO 1
25
-#else
26
-#define NEW_CLOUD_PROTO 0
27
-#endif
28
-
23
#ifdef ENABLE_DBENGINE
24
#define FEAT_DBENGINE 1
25
#else
@@ -273,7 +267,7 @@ void print_build_info(void) {
267
printf(" Native HTTPS: %s\n", FEAT_YES_NO(FEAT_NATIVE_HTTPS));
268
printf(" Netdata Cloud: %s %s\n", FEAT_YES_NO(FEAT_CLOUD), FEAT_CLOUD_MSG);
269
printf(" ACLK Next Generation: %s\n", FEAT_YES_NO(FEAT_CLOUD));
276
- printf(" ACLK-NG New Cloud Protocol: %s\n", FEAT_YES_NO(NEW_CLOUD_PROTO));
270
+ printf(" ACLK-NG New Cloud Protocol: %s\n", FEAT_YES_NO(1));
271
printf(" ACLK Legacy: %s\n", FEAT_YES_NO(0));
272
printf(" TLS Host Verification: %s\n", FEAT_YES_NO(FEAT_TLS_HOST_VERIFY));
273
printf(" Machine Learning: %s\n", FEAT_YES_NO(FEAT_ML));
@@ -325,7 +319,7 @@ void print_build_info_json(void) {
319
printf(" \"cloud-disabled\": false,\n");
320
#endif
321
printf(" \"aclk-ng\": %s,\n", FEAT_JSON_BOOL(FEAT_CLOUD));
328
- printf(" \"aclk-ng-new-cloud-proto\": %s,\n", FEAT_JSON_BOOL(NEW_CLOUD_PROTO));
322
+ printf(" \"aclk-ng-new-cloud-proto\": %s,\n", FEAT_JSON_BOOL(1));
323
printf(" \"aclk-legacy\": %s,\n", FEAT_JSON_BOOL(0));
324
325
printf(" \"tls-host-verify\": %s,\n", FEAT_JSON_BOOL(FEAT_TLS_HOST_VERIFY));
@@ -383,10 +377,7 @@ void analytics_build_info(BUFFER *b) {
377
add_to_bi(b, "Native HTTPS");
378
#endif
379
#ifdef ENABLE_ACLK
386
- add_to_bi(b, "Netdata Cloud|ACLK Next Generation");
387
-#endif
388
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
389
- add_to_bi(b, "New Cloud Protocol Support");
380
+ add_to_bi(b, "Netdata Cloud|ACLK Next Generation|New Cloud Protocol Support");
381
#endif
382
#if (FEAT_TLS_HOST_VERIFY!=0)
383
add_to_bi(b, "TLS Host Verification");
daemon/main.c
+1
-1
@@ -47,7 +47,7 @@ void netdata_cleanup_and_exit(int ret) {
47
48
// stop everything
49
info("EXIT: stopping static threads...");
50
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
50
+#ifdef ENABLE_ACLK
51
aclk_sync_exit_all();
52
#endif
53
cancel_main_threads();
daemon/static_threads.c
+1
-1
@@ -123,7 +123,7 @@ const struct netdata_static_thread static_threads_common[] = {
123
.start_routine = socket_listen_main_static_threaded
124
},
125
126
-#if defined(ENABLE_ACLK) || defined(ACLK_NG)
126
+#ifdef ENABLE_ACLK
127
{
128
.name = "ACLK_Main",
129
.config_section = NULL,
database/rrd.h
+2
-7
@@ -724,10 +724,6 @@ struct rrdhost {
724
const char *tags; // tags for this host
725
const char *timezone; // the timezone of the host
726
727
-#ifdef ENABLE_ACLK
728
- long deleted_charts_count;
729
-#endif
730
-
727
const char *abbrev_timezone; // the abbriviated timezone of the host
728
int32_t utc_offset; // the offset in seconds from utc
729
@@ -1263,7 +1259,7 @@ extern void rrddim_isnot_obsolete(RRDSET *st, RRDDIM *rd);
1259
1260
extern collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number value);
1261
extern collected_number rrddim_set(RRDSET *st, const char *id, collected_number value);
1266
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1262
+#ifdef ENABLE_ACLK
1263
extern time_t calc_dimension_liveness(RRDDIM *rd, time_t now);
1264
#endif
1265
extern long align_entries_to_pagesize(RRD_MEMORY_MODE mode, long entries);
@@ -1301,8 +1297,7 @@ extern RRDSET *rrdset_index_del_name(RRDHOST *host, RRDSET *st);
1297
extern void rrdset_free(RRDSET *st);
1298
extern void rrdset_reset(RRDSET *st);
1299
extern void rrdset_save(RRDSET *st);
1304
-#define rrdset_delete(st) rrdset_delete_custom(st, 0)
1305
-extern void rrdset_delete_custom(RRDSET *st, int db_rotated);
1300
+extern void rrdset_delete(RRDSET *st);
1301
extern void rrdset_delete_obsolete_dimensions(RRDSET *st);
1302
1303
extern RRDHOST *rrdhost_create(
database/rrddim.c
+3
-3
@@ -139,7 +139,7 @@ void rrdcalc_link_to_rrddim(RRDDIM *rd, RRDSET *st, RRDHOST *host) {
139
// 0 : Dimension is live
140
// last collected time : Dimension is not live
141
142
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
142
+#ifdef ENABLE_ACLK
143
time_t calc_dimension_liveness(RRDDIM *rd, time_t now)
144
{
145
time_t last_updated = rd->last_collected_time.tv_sec;
@@ -184,7 +184,7 @@ RRDDIM *rrddim_add_custom(RRDSET *st, const char *id, const char *name, collecte
184
debug(D_METADATALOG, "DIMENSION [%s] metadata updated", rd->id);
185
(void)sql_store_dimension(&rd->state->metric_uuid, rd->rrdset->chart_uuid, rd->id, rd->name, rd->multiplier, rd->divisor,
186
rd->algorithm);
187
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
187
+#ifdef ENABLE_ACLK
188
queue_dimension_to_aclk(rd, calc_dimension_liveness(rd, now_realtime_sec()));
189
#endif
190
rrdset_flag_set(st, RRDSET_FLAG_SYNC_CLOCK);
@@ -427,7 +427,7 @@ void rrddim_free(RRDSET *st, RRDDIM *rd)
427
error("RRDDIM: INTERNAL ERROR: attempt to remove from index dimension '%s' on chart '%s', removed a different dimension.", rd->id, st->id);
428
429
// free(rd->annotations);
430
-//#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
430
+//#ifdef ENABLE_ACLK
431
// if (!netdata_exit)
432
// aclk_send_dimension_update(rd);
433
//#endif
database/rrdhost.c
+4
-11
@@ -886,7 +886,7 @@ void rrdhost_free(RRDHOST *host) {
886
887
888
rrdhost_wrlock(host); // lock this RRDHOST
889
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
889
+#ifdef ENABLE_ACLK
890
struct aclk_database_worker_config *wc = host->dbsync_worker;
891
if (wc && !netdata_exit) {
892
struct aclk_database_cmd cmd;
@@ -999,7 +999,7 @@ void rrdhost_free(RRDHOST *host) {
999
freez(host->node_id);
1000
1001
freez(host);
1002
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1002
+#ifdef ENABLE_ACLK
1003
if (wc)
1004
wc->is_orphan = 0;
1005
#endif
@@ -1330,7 +1330,7 @@ restart_after_removal:
1330
}
1331
continue;
1332
}
1333
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1333
+#ifdef ENABLE_ACLK
1334
else
1335
queue_dimension_to_aclk(rd, rd->last_collected_time.tv_sec);
1336
#endif
@@ -1363,7 +1363,7 @@ restart_after_removal:
1363
rrdset_free(st);
1364
goto restart_after_removal;
1365
}
1366
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1366
+#ifdef ENABLE_ACLK
1367
else
1368
sql_check_chart_liveness(st);
1369
#endif
@@ -1391,14 +1391,7 @@ void rrd_cleanup_obsolete_charts()
1391
{
1392
if (host->obsolete_charts_count) {
1393
rrdhost_wrlock(host);
1394
-#ifdef ENABLE_ACLK
1395
- host->deleted_charts_count = 0;
1396
-#endif
1394
rrdhost_cleanup_obsolete_charts(host);
1398
-#ifdef ENABLE_ACLK
1399
- if (host->deleted_charts_count)
1400
- aclk_update_chart(host, "dummy-chart", 0);
1401
-#endif
1395
rrdhost_unlock(host);
1396
}
1397
database/rrdset.c
+5
-35
@@ -441,11 +441,8 @@ void rrdset_save(RRDSET *st) {
441
}
442
}
443
444
-void rrdset_delete_custom(RRDSET *st, int db_rotated) {
444
+void rrdset_delete(RRDSET *st) {
445
RRDDIM *rd;
446
-#ifndef ENABLE_ACLK
447
- UNUSED(db_rotated);
448
-#endif
446
rrdset_check_rdlock(st);
447
448
info("Deleting chart '%s' ('%s') from disk...", st->id, st->name);
@@ -465,13 +462,6 @@ void rrdset_delete_custom(RRDSET *st, int db_rotated) {
462
}
463
464
recursively_delete_dir(st->cache_dir, "left-over chart");
468
-#ifdef ENABLE_ACLK
469
- if ((netdata_cloud_setting) && (db_rotated || RRD_MEMORY_MODE_DBENGINE != st->rrd_memory_mode)) {
470
- aclk_del_collector(st->rrdhost, st->plugin_name, st->module_name);
471
- st->rrdhost->deleted_charts_count++;
472
- }
473
-#endif
474
-
465
}
466
467
void rrdset_delete_obsolete_dimensions(RRDSET *st) {
@@ -659,22 +649,7 @@ RRDSET *rrdset_create_custom(
649
}
650
651
if (mark_rebuild) {
662
-#ifdef ENABLE_ACLK
663
- if (netdata_cloud_setting) {
664
- if (mark_rebuild & META_CHART_ACTIVATED) {
665
- aclk_add_collector(host, st->plugin_name, st->module_name);
666
- }
667
- else {
668
- if (mark_rebuild & (META_PLUGIN_UPDATED | META_MODULE_UPDATED)) {
669
- aclk_del_collector(
670
- host, mark_rebuild & META_PLUGIN_UPDATED ? old_plugin : st->plugin_name,
671
- mark_rebuild & META_MODULE_UPDATED ? old_module : st->module_name);
672
- aclk_add_collector(host, st->plugin_name, st->module_name);
673
- }
674
- }
675
- rrdset_flag_clear(st, RRDSET_FLAG_ACLK);
676
- }
677
-#endif
652
+ rrdset_flag_clear(st, RRDSET_FLAG_ACLK);
653
freez(old_plugin);
654
freez(old_module);
655
freez(old_title);
@@ -929,11 +904,6 @@ RRDSET *rrdset_create_custom(
904
compute_chart_hash(st);
905
906
rrdhost_unlock(host);
932
-#ifdef ENABLE_ACLK
933
- if (netdata_cloud_setting)
934
- aclk_add_collector(host, plugin, module);
935
- rrdset_flag_clear(st, RRDSET_FLAG_ACLK);
936
-#endif
907
return(st);
908
}
909
@@ -1769,14 +1739,14 @@ after_first_database_work:
1739
after_second_database_work:
1740
st->last_collected_total = st->collected_total;
1741
1772
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1742
+#ifdef ENABLE_ACLK
1743
time_t mark = now_realtime_sec();
1744
#endif
1745
rrddim_foreach_read(rd, st) {
1746
if (rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED))
1747
continue;
1748
1779
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1749
+#ifdef ENABLE_ACLK
1750
if (likely(!st->state->is_ar_chart)) {
1751
if (!rrddim_flag_check(rd, RRDDIM_FLAG_HIDDEN) && likely(rrdset_flag_check(st, RRDSET_FLAG_ACLK)))
1752
queue_dimension_to_aclk(rd, calc_dimension_liveness(rd, mark));
@@ -1881,7 +1851,7 @@ after_second_database_work:
1851
delete_dimension_uuid(&rd->state->metric_uuid);
1852
} else {
1853
/* Do not delete this dimension */
1884
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1854
+#ifdef ENABLE_ACLK
1855
queue_dimension_to_aclk(rd, calc_dimension_liveness(rd, mark));
1856
#endif
1857
last = rd;
database/sqlite/sqlite_aclk.c
+11
-13
@@ -6,7 +6,7 @@
6
#include "sqlite_aclk_chart.h"
7
#include "sqlite_aclk_node.h"
8
9
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
9
+#ifdef ENABLE_ACLK
10
#include "../../aclk/aclk.h"
11
#endif
12
@@ -36,7 +36,7 @@ uv_mutex_t aclk_async_lock;
36
struct aclk_database_worker_config *aclk_thread_head = NULL;
37
int retention_running = 0;
38
39
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
39
+#ifdef ENABLE_ACLK
40
static void stop_retention_run()
41
{
42
uv_mutex_lock(&aclk_async_lock);
@@ -276,7 +276,7 @@ int aclk_start_sync_thread(void *data, int argc, char **argv, char **column)
276
277
void sql_aclk_sync_init(void)
278
{
279
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
279
+#ifdef ENABLE_ACLK
280
char *err_msg = NULL;
281
int rc;
282
@@ -323,7 +323,7 @@ static void timer_cb(uv_timer_t* handle)
323
uv_stop(handle->loop);
324
uv_update_time(handle->loop);
325
326
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
326
+#ifdef ENABLE_ACLK
327
struct aclk_database_worker_config *wc = handle->data;
328
struct aclk_database_cmd cmd;
329
memset(&cmd, 0, sizeof(cmd));
@@ -338,7 +338,7 @@ static void timer_cb(uv_timer_t* handle)
338
wc->cleanup_after += ACLK_DATABASE_CLEANUP_INTERVAL;
339
}
340
341
- if (aclk_use_new_cloud_arch && aclk_connected) {
341
+ if (aclk_connected) {
342
if (wc->rotation_after && wc->rotation_after < now) {
343
cmd.opcode = ACLK_DATABASE_UPD_RETENTION;
344
if (!aclk_database_enq_cmd_noblock(wc, &cmd))
@@ -373,7 +373,7 @@ static void timer_cb(uv_timer_t* handle)
373
}
374
375
376
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
376
+#ifdef ENABLE_ACLK
377
void after_send_retention(uv_work_t *req, int status)
378
{
379
struct aclk_database_worker_config *wc = req->data;
@@ -410,7 +410,6 @@ void aclk_database_worker(void *arg)
410
{
411
worker_register("ACLKSYNC");
412
worker_register_job_name(ACLK_DATABASE_NOOP, "noop");
413
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
413
worker_register_job_name(ACLK_DATABASE_ADD_CHART, "chart add");
414
worker_register_job_name(ACLK_DATABASE_ADD_DIMENSION, "dimension add");
415
worker_register_job_name(ACLK_DATABASE_PUSH_CHART, "chart push");
@@ -420,7 +419,6 @@ void aclk_database_worker(void *arg)
419
worker_register_job_name(ACLK_DATABASE_UPD_RETENTION, "retention check");
420
worker_register_job_name(ACLK_DATABASE_DIM_DELETION, "dimension delete");
421
worker_register_job_name(ACLK_DATABASE_ORPHAN_HOST, "node orphan");
423
-#endif
422
worker_register_job_name(ACLK_DATABASE_ALARM_HEALTH_LOG, "alert log");
423
worker_register_job_name(ACLK_DATABASE_CLEANUP, "cleanup");
424
worker_register_job_name(ACLK_DATABASE_DELETE_HOST, "node delete");
@@ -479,7 +477,7 @@ void aclk_database_worker(void *arg)
477
info("Starting ACLK sync thread for host %s -- scratch area %lu bytes", wc->host_guid, sizeof(*wc));
478
479
memset(&cmd, 0, sizeof(cmd));
482
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
480
+#ifdef ENABLE_ACLK
481
uv_work_t retention_work;
482
sql_get_last_chart_sequence(wc);
483
wc->chart_payload_count = sql_get_pending_count(wc);
@@ -532,7 +530,7 @@ void aclk_database_worker(void *arg)
530
break;
531
532
// CHART / DIMENSION OPERATIONS
535
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
533
+#ifdef ENABLE_ACLK
534
case ACLK_DATABASE_ADD_CHART:
535
debug(D_ACLK_SYNC, "Adding chart event for %s", wc->host_guid);
536
aclk_add_chart_event(wc, cmd);
@@ -585,7 +583,7 @@ void aclk_database_worker(void *arg)
583
debug(D_ACLK_SYNC,"Sending node info for %s", wc->uuid_str);
584
sql_build_node_info(wc, cmd);
585
break;
588
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
586
+#ifdef ENABLE_ACLK
587
case ACLK_DATABASE_DIM_DELETION:
588
debug(D_ACLK_SYNC,"Sending dimension deletion information %s", wc->uuid_str);
589
aclk_process_dimension_deletion(wc, cmd);
@@ -918,9 +916,9 @@ void sql_check_aclk_table_list(struct aclk_database_worker_config *wc)
916
917
void aclk_data_rotated(void)
918
{
921
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
919
+#ifdef ENABLE_ACLK
920
923
- if (!aclk_use_new_cloud_arch || !aclk_connected)
921
+ if (!aclk_connected)
922
return;
923
924
time_t next_rotation_time = now_realtime_sec()+ACLK_DATABASE_ROTATION_DELAY;
database/sqlite/sqlite_aclk.h
-2
@@ -115,7 +115,6 @@ static inline char *get_str_from_uuid(uuid_t *uuid)
115
enum aclk_database_opcode {
116
ACLK_DATABASE_NOOP = 0,
117
118
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
118
ACLK_DATABASE_ADD_CHART,
119
ACLK_DATABASE_ADD_DIMENSION,
120
ACLK_DATABASE_PUSH_CHART,
@@ -125,7 +124,6 @@ enum aclk_database_opcode {
124
ACLK_DATABASE_UPD_RETENTION,
125
ACLK_DATABASE_DIM_DELETION,
126
ACLK_DATABASE_ORPHAN_HOST,
128
-#endif
127
ACLK_DATABASE_ALARM_HEALTH_LOG,
128
ACLK_DATABASE_CLEANUP,
129
ACLK_DATABASE_DELETE_HOST,
database/sqlite/sqlite_aclk_alert.c
+10
-53
@@ -3,7 +3,7 @@
3
#include "sqlite_functions.h"
4
#include "sqlite_aclk_alert.h"
5
6
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
6
+#ifdef ENABLE_ACLK
7
#include "../../aclk/aclk_alarm_api.h"
8
#include "../../aclk/aclk.h"
9
#endif
@@ -123,21 +123,6 @@ done:
123
// and handle both cases
124
int sql_queue_alarm_to_aclk(RRDHOST *host, ALARM_ENTRY *ae, int skip_filter)
125
{
126
- //check aclk architecture and handle old json alarm update to cloud
127
- //include also the valid statuses for this case
128
-#ifdef ENABLE_ACLK
129
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
130
- if (!aclk_use_new_cloud_arch && aclk_connected) {
131
-#endif
132
-
133
- if ((ae->new_status == RRDCALC_STATUS_WARNING || ae->new_status == RRDCALC_STATUS_CRITICAL) ||
134
- ((ae->old_status == RRDCALC_STATUS_WARNING || ae->old_status == RRDCALC_STATUS_CRITICAL))) {
135
- aclk_update_alarm(host, ae);
136
- }
137
-#endif
138
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
139
- }
140
-
126
if (!claimed())
127
return 0;
128
@@ -196,17 +181,11 @@ bind_fail:
181
182
buffer_free(sql);
183
return 0;
199
-#else
200
- UNUSED(host);
201
- UNUSED(ae);
202
- UNUSED(skip_filter);
203
-#endif
204
- return 0;
184
}
185
186
int rrdcalc_status_to_proto_enum(RRDCALC_STATUS status)
187
{
209
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
188
+#ifdef ENABLE_ACLK
189
switch(status) {
190
case RRDCALC_STATUS_REMOVED:
191
return ALARM_STATUS_REMOVED;
@@ -234,7 +213,7 @@ int rrdcalc_status_to_proto_enum(RRDCALC_STATUS status)
213
214
void aclk_push_alert_event(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd)
215
{
237
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
216
+#ifndef ENABLE_ACLK
217
UNUSED(wc);
218
UNUSED(cmd);
219
#else
@@ -470,7 +449,7 @@ void aclk_send_alarm_health_log(char *node_id)
449
void aclk_push_alarm_health_log(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd)
450
{
451
UNUSED(cmd);
473
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
452
+#ifndef ENABLE_ACLK
453
UNUSED(wc);
454
#else
455
int rc;
@@ -595,7 +574,7 @@ void aclk_send_alarm_configuration(char *config_hash)
574
int aclk_push_alert_config_event(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd)
575
{
576
UNUSED(wc);
598
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
577
+#ifndef ENABLE_ACLK
578
UNUSED(cmd);
579
#else
580
int rc = 0;
@@ -708,7 +687,6 @@ bind_fail:
687
// Start streaming alerts
688
void aclk_start_alert_streaming(char *node_id, uint64_t batch_id, uint64_t start_seq_id)
689
{
711
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
690
if (unlikely(!node_id))
691
return;
692
@@ -749,20 +727,13 @@ void aclk_start_alert_streaming(char *node_id, uint64_t batch_id, uint64_t start
727
else
728
log_access("ACLK STA [%s (N/A)]: ACLK synchronization thread is not active.", node_id);
729
752
-#else
753
- UNUSED(node_id);
754
- UNUSED(start_seq_id);
755
- UNUSED(batch_id);
756
-#endif
730
return;
731
}
732
733
void sql_process_queue_removed_alerts_to_aclk(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd)
734
{
735
UNUSED(cmd);
763
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
764
- UNUSED(wc);
765
-#else
736
+
737
BUFFER *sql = buffer_create(1024);
738
739
buffer_sprintf(sql,"insert into aclk_alert_%s (alert_unique_id, date_created) " \
@@ -778,13 +749,11 @@ void sql_process_queue_removed_alerts_to_aclk(struct aclk_database_worker_config
749
buffer_free(sql);
750
751
wc->pause_alert_updates = 0;
781
-#endif
752
return;
753
}
754
755
void sql_queue_removed_alerts_to_aclk(RRDHOST *host)
756
{
787
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
757
if (unlikely(!host->dbsync_worker))
758
return;
759
@@ -798,15 +767,11 @@ void sql_queue_removed_alerts_to_aclk(RRDHOST *host)
767
cmd.data_param = NULL;
768
cmd.completion = NULL;
769
aclk_database_enq_cmd((struct aclk_database_worker_config *) host->dbsync_worker, &cmd);
801
-#else
802
- UNUSED(host);
803
-#endif
770
}
771
772
void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id, uint64_t snapshot_id, uint64_t sequence_id)
773
{
774
UNUSED(claim_id);
809
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
775
if (unlikely(!node_id))
776
return;
777
@@ -843,11 +808,7 @@ void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id, uint64_t sn
808
aclk_database_enq_cmd(wc, &cmd);
809
} else
810
log_access("ACLK STA [%s (N/A)]: ACLK synchronization thread is not active.", node_id);
846
-#else
847
- UNUSED(node_id);
848
- UNUSED(snapshot_id);
849
- UNUSED(sequence_id);
850
-#endif
811
+
812
return;
813
}
814
@@ -867,7 +828,7 @@ void aclk_mark_alert_cloud_ack(char *uuid_str, uint64_t alerts_ack_sequence_id)
828
buffer_free(sql);
829
}
830
870
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
831
+#ifdef ENABLE_ACLK
832
void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_ENTRY *ae, RRDHOST *host)
833
{
834
char *edit_command = ae->source ? health_edit_command_from_source(ae->source) : strdupz("UNKNOWN=0=UNKNOWN");
@@ -917,7 +878,7 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN
878
}
879
#endif
880
920
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
881
+#ifdef ENABLE_ACLK
882
static int have_recent_alarm(RRDHOST *host, uint32_t alarm_id, time_t mark)
883
{
884
ALARM_ENTRY *ae = host->health_log.alarms;
@@ -936,7 +897,7 @@ static int have_recent_alarm(RRDHOST *host, uint32_t alarm_id, time_t mark)
897
#define ALARM_EVENTS_PER_CHUNK 10
898
void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, struct aclk_database_cmd cmd)
899
{
939
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
900
+#ifndef ENABLE_ACLK
901
UNUSED(wc);
902
UNUSED(cmd);
903
#else
@@ -1055,7 +1016,6 @@ void aclk_push_alert_snapshot_event(struct aclk_database_worker_config *wc, stru
1016
1017
void sql_aclk_alert_clean_dead_entries(RRDHOST *host)
1018
{
1058
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1019
if (!claimed())
1020
return;
1021
@@ -1075,9 +1035,6 @@ void sql_aclk_alert_clean_dead_entries(RRDHOST *host)
1035
sqlite3_free(err_msg);
1036
}
1037
buffer_free(sql);
1078
-#else
1079
- UNUSED(host);
1080
-#endif
1038
}
1039
1040
int get_proto_alert_status(RRDHOST *host, struct proto_alert_status *proto_alert_status)
database/sqlite/sqlite_aclk_chart.c
+5
-21
@@ -3,7 +3,7 @@
3
#include "sqlite_functions.h"
4
#include "sqlite_aclk_chart.h"
5
6
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
6
+#ifdef ENABLE_ACLK
7
#include "../../aclk/aclk_charts_api.h"
8
#include "../../aclk/aclk.h"
9
@@ -212,7 +212,7 @@ void aclk_process_dimension_deletion(struct aclk_database_worker_config *wc, str
212
int rc = 0;
213
sqlite3_stmt *res = NULL;
214
215
- if (!aclk_use_new_cloud_arch || !aclk_connected)
215
+ if (!aclk_connected)
216
return;
217
218
if (unlikely(!db_meta))
@@ -843,7 +843,7 @@ void aclk_update_retention(struct aclk_database_worker_config *wc)
843
{
844
int rc;
845
846
- if (!aclk_use_new_cloud_arch || !aclk_connected)
846
+ if (!aclk_connected)
847
return;
848
849
char *claim_id = is_agent_claimed();
@@ -1146,9 +1146,6 @@ void queue_dimension_to_aclk(RRDDIM *rd, time_t last_updated)
1146
1147
void aclk_send_dimension_update(RRDDIM *rd)
1148
{
1149
- if (!aclk_use_new_cloud_arch)
1150
- return;
1151
-
1149
char *claim_id = is_agent_claimed();
1150
if (unlikely(!claim_id))
1151
return;
@@ -1316,24 +1313,11 @@ void sql_check_chart_liveness(RRDSET *st) {
1313
rrdset_unlock(st);
1314
}
1315
1319
-#endif //ENABLE_NEW_CLOUD_PROTOCOL
1320
-
1316
// ST is read locked
1317
int queue_chart_to_aclk(RRDSET *st)
1318
{
1324
-#ifndef ENABLE_NEW_CLOUD_PROTOCOL
1325
-#ifdef ENABLE_ACLK
1326
- aclk_update_chart(st->rrdhost, st->id, 1);
1327
-#else
1328
- UNUSED(st);
1329
-#endif
1330
- return 0;
1331
-#else
1332
- if (!aclk_use_new_cloud_arch && aclk_connected) {
1333
- aclk_update_chart(st->rrdhost, st->id, 1);
1334
- return 0;
1335
- }
1319
return sql_queue_chart_payload((struct aclk_database_worker_config *) st->rrdhost->dbsync_worker,
1320
st, ACLK_DATABASE_ADD_CHART);
1338
-#endif
1321
}
1322
+
1323
+#endif //ENABLE_ACLK
database/sqlite/sqlite_aclk_node.c
+2
-2
@@ -3,7 +3,7 @@
3
#include "sqlite_functions.h"
4
#include "sqlite_aclk_node.h"
5
6
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
6
+#ifdef ENABLE_ACLK
7
#include "../../aclk/aclk_charts_api.h"
8
#endif
9
@@ -11,7 +11,7 @@ void sql_build_node_info(struct aclk_database_worker_config *wc, struct aclk_dat
11
{
12
UNUSED(cmd);
13
14
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
14
+#ifdef ENABLE_ACLK
15
struct update_node_info node_info;
16
17
if (!wc->host)
health/health.c
+4
-12
@@ -219,10 +219,6 @@ static void health_reload_host(RRDHOST *host) {
219
* Reload the host configuration for all hosts.
220
*/
221
void health_reload(void) {
222
-#ifdef ENABLE_ACLK
223
- if (netdata_cloud_setting)
224
- aclk_single_update_disable();
225
-#endif
222
sql_refresh_hashes();
223
224
rrd_rdlock();
@@ -234,11 +230,7 @@ void health_reload(void) {
230
rrd_unlock();
231
#ifdef ENABLE_ACLK
232
if (netdata_cloud_setting) {
237
- aclk_single_update_enable();
238
- aclk_alarm_reload();
239
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
233
aclk_alert_reloaded = 1;
241
-#endif
234
}
235
#endif
236
}
@@ -736,7 +728,7 @@ void *health_main(void *ptr) {
728
rrdcalc_labels_unlink();
729
730
unsigned int loop = 0;
739
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
731
+#ifdef ENABLE_ACLK
732
unsigned int marked_aclk_reload_loop = 0;
733
#endif
734
while(!netdata_exit) {
@@ -765,7 +757,7 @@ void *health_main(void *ptr) {
757
}
758
}
759
768
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
760
+#ifdef ENABLE_ACLK
761
if (aclk_alert_reloaded && !marked_aclk_reload_loop)
762
marked_aclk_reload_loop = loop;
763
#endif
@@ -828,7 +820,7 @@ void *health_main(void *ptr) {
820
rc->last_status_change = now;
821
rc->last_updated = now;
822
rc->value = NAN;
831
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
823
+#ifdef ENABLE_ACLK
824
if (netdata_cloud_setting && likely(!aclk_alert_reloaded))
825
sql_queue_alarm_to_aclk(host, ae, 1);
826
#endif
@@ -1180,7 +1172,7 @@ void *health_main(void *ptr) {
1172
health_alarm_wait_for_execution(ae);
1173
}
1174
1183
-#if defined(ENABLE_ACLK) && defined(ENABLE_NEW_CLOUD_PROTOCOL)
1175
+#ifdef ENABLE_ACLK
1176
if (netdata_cloud_setting && unlikely(aclk_alert_reloaded) && loop > (marked_aclk_reload_loop + 2)) {
1177
rrdhost_foreach_read(host) {
1178
if (unlikely(!host->health_enabled))
streaming/receiver.c
+2
-2
@@ -699,7 +699,7 @@ static int rrdpush_receive(struct receiver_state *rpt)
699
700
cd.version = rpt->stream_version;
701
702
-#if defined(ENABLE_NEW_CLOUD_PROTOCOL)
702
+#ifdef ENABLE_ACLK
703
// in case we have cloud connection we inform cloud
704
// new child connected
705
if (netdata_cloud_setting)
@@ -713,7 +713,7 @@ static int rrdpush_receive(struct receiver_state *rpt)
713
error("STREAM %s [receive from [%s]:%s]: disconnected (completed %zu updates).", rpt->hostname, rpt->client_ip,
714
rpt->client_port, count);
715
716
-#if defined(ENABLE_NEW_CLOUD_PROTOCOL)
716
+#ifdef ENABLE_ACLK
717
// in case we have cloud connection we inform cloud
718
// new child connected
719
if (netdata_cloud_setting)
web/api/web_api_v1.c
+1
-11
@@ -3,7 +3,6 @@
3
#include "web_api_v1.h"
4
5
char *api_secret;
6
-extern int aclk_use_new_cloud_arch;
6
7
static struct {
8
const char *name;
@@ -1062,11 +1061,7 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
1061
#ifdef ENABLE_ACLK
1062
buffer_strcat(wb, "\t\"cloud-available\": true,\n");
1063
buffer_strcat(wb, "\t\"aclk-ng-available\": true,\n");
1065
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1064
buffer_strcat(wb, "\t\"aclk-ng-new-cloud-protocol\": true,\n");
1067
-#else
1068
- buffer_strcat(wb, "\t\"aclk-ng-new-cloud-protocol\": false,\n");
1069
-#endif
1065
buffer_strcat(wb, "\t\"aclk-legacy-available\": false,\n");
1066
buffer_strcat(wb, "\t\"aclk-implementation\": \"Next Generation\",\n");
1067
#else
@@ -1084,12 +1079,7 @@ inline int web_client_api_request_v1_info_fill_buffer(RRDHOST *host, BUFFER *wb)
1079
#ifdef ENABLE_ACLK
1080
if (aclk_connected) {
1081
buffer_strcat(wb, "\t\"aclk-available\": true,\n");
1087
-#ifdef ENABLE_NEW_CLOUD_PROTOCOL
1088
- if (aclk_use_new_cloud_arch)
1089
- buffer_strcat(wb, "\t\"aclk-available-protocol\": \"New\",\n");
1090
- else
1091
-#endif
1092
- buffer_strcat(wb, "\t\"aclk-available-protocol\": \"Legacy\",\n");
1082
+ buffer_strcat(wb, "\t\"aclk-available-protocol\": \"New\",\n");
1083
}
1084
else
1085
#endif