streaming logs (#15948)
Costa Tsaousis committed
Sep 13, 2023 at 00:24 UTC
e70e50815ba740edc64d9b3df31e5b79afbffd71
7 files changed
+35
-11
aclk/aclk_otp.c
+1
-1
@@ -502,7 +502,7 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
502
}
503
504
// Decrypt Challenge / Get response
505
- unsigned char *response_plaintext;
505
+ unsigned char *response_plaintext = NULL;
506
int response_plaintext_bytes = private_decrypt(p_key, challenge, challenge_bytes, &response_plaintext);
507
if (response_plaintext_bytes < 0) {
508
netdata_log_error("Couldn't decrypt the challenge received");
collectors/proc.plugin/sys_devices_pci_aer.c
+5
@@ -268,6 +268,11 @@ int do_proc_sys_devices_pci_aer(int update_every, usec_t dt __maybe_unused) {
268
title = "PCI Root-Port Advanced Error Reporting (AER) Fatal Errors";
269
context = "pci.rootport_aer_fatal";
270
break;
271
+
272
+ default:
273
+ title = "Unknown PCI Advanced Error Reporting";
274
+ context = "pci.unknown_aer";
275
+ break;
276
}
277
278
char id[RRD_ID_LENGTH_MAX + 1];
collectors/systemd-journal.plugin/systemd-journal.c
+1
-1
@@ -96,7 +96,7 @@ int systemd_journal_query(BUFFER *wb, FACETS *facets, usec_t after_ut, usec_t be
96
size_t excess_rows_allowed = 100;
97
98
if(sd_journal_seek_realtime_usec(j, before_ut) < 0) {
99
- netdata_log_error("SYSTEMD-JOURNAL: Failed to seek to %llu", before_ut);
99
+ netdata_log_error("SYSTEMD-JOURNAL: Failed to seek to " PRIu64, before_ut);
100
if(sd_journal_seek_tail(j) < 0) {
101
netdata_log_error("SYSTEMD-JOURNAL: Failed to seek to journal's tail");
102
goto finalize;
database/engine/rrdengineapi.c
+11
-5
@@ -534,7 +534,8 @@ static void rrdeng_store_metric_append_point(STORAGE_COLLECT_HANDLE *collection_
534
timing_step(TIMING_STEP_DBENGINE_MRG_UPDATE);
535
}
536
537
-static void store_metric_next_error_log(struct rrdeng_collect_handle *handle, usec_t point_in_time_ut, const char *msg) {
537
+static void store_metric_next_error_log(struct rrdeng_collect_handle *handle __maybe_unused, usec_t point_in_time_ut __maybe_unused, const char *msg __maybe_unused) {
538
+#ifdef NETDATA_INTERNAL_CHECKS
539
time_t point_in_time_s = (time_t)(point_in_time_ut / USEC_PER_SEC);
540
char uuid[UUID_STR_LEN + 1];
541
uuid_unparse(*mrg_metric_uuid(main_mrg, handle->metric), uuid);
@@ -562,6 +563,9 @@ static void store_metric_next_error_log(struct rrdeng_collect_handle *handle, us
563
);
564
565
buffer_free(wb);
566
+#else
567
+ ;
568
+#endif
569
}
570
571
void rrdeng_store_metric_next(STORAGE_COLLECT_HANDLE *collection_handle,
@@ -808,12 +812,14 @@ static bool rrdeng_load_page_next(struct storage_engine_query_handle *rrddim_han
812
if (unlikely(handle->now_s > rrddim_handle->end_time_s))
813
return false;
814
811
- size_t entries;
815
+ size_t entries = 0;
816
handle->page = pg_cache_lookup_next(ctx, handle->pdc, handle->now_s, handle->dt_s, &entries);
813
- if (unlikely(!handle->page))
814
- return false;
817
816
- internal_fatal(pgc_page_data(handle->page) == DBENGINE_EMPTY_PAGE, "Empty page returned");
818
+ internal_fatal((handle->page && pgc_page_data(handle->page) == DBENGINE_EMPTY_PAGE) || !entries,
819
+ "A page was returned, but it is empty - pg_cache_lookup_next() should be handling this case");
820
+
821
+ if (unlikely(!handle->page || pgc_page_data(handle->page) == DBENGINE_EMPTY_PAGE || !entries))
822
+ return false;
823
824
time_t page_start_time_s = pgc_page_start_time_s(handle->page);
825
time_t page_end_time_s = pgc_page_end_time_s(handle->page);
libnetdata/socket/socket.c
+2
-1
@@ -810,7 +810,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
810
errno = 0;
811
if(connect(fd, ai->ai_addr, ai->ai_addrlen) < 0) {
812
if(errno == EALREADY || errno == EINPROGRESS) {
813
- netdata_log_info("Waiting for connection to ip %s port %s to be established", hostBfr, servBfr);
813
+ internal_error(true, "Waiting for connection to ip %s port %s to be established", hostBfr, servBfr);
814
815
// Convert 'struct timeval' to milliseconds for poll():
816
int timeout_milliseconds = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
@@ -835,6 +835,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
835
}
836
else if (ret == 0) {
837
// poll() timed out, the connection is not established within the specified timeout.
838
+ errno = 0;
839
netdata_log_error("Timed out while connecting to '%s', port '%s'.", hostBfr, servBfr);
840
close(fd);
841
fd = -1;
streaming/rrdpush.c
+3
-1
@@ -588,7 +588,7 @@ int connect_to_one_of_destinations(
588
if(d->postpone_reconnection_until > now)
589
continue;
590
591
- netdata_log_info(
591
+ internal_error(true,
592
"STREAM %s: connecting to '%s' (default port: %d)...",
593
rrdhost_hostname(host),
594
string2str(d->destination),
@@ -1166,6 +1166,7 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *decoded_query_stri
1166
// another receiver is already connected
1167
// try again later
1168
1169
+#ifdef NETDATA_INTERNAL_CHECKS
1170
char msg[200 + 1];
1171
snprintfz(msg, 200,
1172
"multiple connections for same host, "
@@ -1176,6 +1177,7 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *decoded_query_stri
1177
rpt,
1178
msg,
1179
"ALREADY CONNECTED");
1180
+#endif
1181
1182
// Have not set WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET - caller should clean up
1183
buffer_flush(w->response.data);
streaming/sender.c
+12
-2
@@ -377,6 +377,7 @@ struct {
377
const char *error;
378
int worker_job_id;
379
time_t postpone_reconnect_seconds;
380
+ bool prevent_log;
381
} stream_responses[] = {
382
{
383
.response = START_STREAMING_PROMPT_VN,
@@ -413,6 +414,7 @@ struct {
414
.error = "remote server rejected this stream, the host we are trying to stream is its localhost",
415
.worker_job_id = WORKER_SENDER_JOB_DISCONNECT_BAD_HANDSHAKE,
416
.postpone_reconnect_seconds = 60 * 60, // the IP may change, try it every hour
417
+ .prevent_log = true,
418
},
419
{
420
.response = START_STREAMING_ERROR_ALREADY_STREAMING,
@@ -422,6 +424,7 @@ struct {
424
.error = "remote server rejected this stream, the host we are trying to stream is already streamed to it",
425
.worker_job_id = WORKER_SENDER_JOB_DISCONNECT_BAD_HANDSHAKE,
426
.postpone_reconnect_seconds = 2 * 60, // 2 minutes
427
+ .prevent_log = true,
428
},
429
{
430
.response = START_STREAMING_ERROR_NOT_PERMITTED,
@@ -469,6 +472,7 @@ struct {
472
.error = "remote node response is not understood, is it Netdata?",
473
.worker_job_id = WORKER_SENDER_JOB_DISCONNECT_BAD_HANDSHAKE,
474
.postpone_reconnect_seconds = 1 * 60, // 1 minute
475
+ .prevent_log = false,
476
}
477
};
478
@@ -498,6 +502,7 @@ static inline bool rrdpush_sender_validate_response(RRDHOST *host, struct sender
502
return true;
503
}
504
505
+ bool prevent_log = stream_responses[i].prevent_log;
506
const char *error = stream_responses[i].error;
507
int worker_job_id = stream_responses[i].worker_job_id;
508
time_t delay = stream_responses[i].postpone_reconnect_seconds;
@@ -509,8 +514,13 @@ static inline bool rrdpush_sender_validate_response(RRDHOST *host, struct sender
514
515
char buf[LOG_DATE_LENGTH];
516
log_date(buf, LOG_DATE_LENGTH, host->destination->postpone_reconnection_until);
512
- netdata_log_error("STREAM %s [send to %s]: %s - will retry in %ld secs, at %s",
513
- rrdhost_hostname(host), s->connected_to, error, delay, buf);
517
+
518
+ if(prevent_log)
519
+ internal_error(true, "STREAM %s [send to %s]: %s - will retry in %ld secs, at %s",
520
+ rrdhost_hostname(host), s->connected_to, error, delay, buf);
521
+ else
522
+ netdata_log_error("STREAM %s [send to %s]: %s - will retry in %ld secs, at %s",
523
+ rrdhost_hostname(host), s->connected_to, error, delay, buf);
524
525
return false;
526
}