Rename generic `error` function (#15296)
thiagoftsm committed
Jul 6, 2023 at 15:46 UTC
e0f388c43f3144abb871cce2a7b44e85a36de48f
135 files changed
+1345
-1271
aclk/aclk.c
+18
-18
@@ -72,7 +72,7 @@ static void aclk_ssl_keylog_cb(const SSL *ssl, const char *line)
72
if (!ssl_log_file)
73
ssl_log_file = fopen(ssl_log_filename, "a");
74
if (!ssl_log_file) {
75
- error("Couldn't open ssl_log file (%s) for append.", ssl_log_filename);
75
+ netdata_log_error("Couldn't open ssl_log file (%s) for append.", ssl_log_filename);
76
return;
77
}
78
fputs(line, ssl_log_file);
@@ -107,14 +107,14 @@ static int load_private_key()
107
long bytes_read;
108
char *private_key = read_by_filename(filename, &bytes_read);
109
if (!private_key) {
110
- error("Claimed agent cannot establish ACLK - unable to load private key '%s' failed.", filename);
110
+ netdata_log_error("Claimed agent cannot establish ACLK - unable to load private key '%s' failed.", filename);
111
return 1;
112
}
113
debug(D_ACLK, "Claimed agent loaded private key len=%ld bytes", bytes_read);
114
115
BIO *key_bio = BIO_new_mem_buf(private_key, -1);
116
if (key_bio==NULL) {
117
- error("Claimed agent cannot establish ACLK - failed to create BIO for key");
117
+ netdata_log_error("Claimed agent cannot establish ACLK - failed to create BIO for key");
118
goto biofailed;
119
}
120
@@ -125,13 +125,13 @@ static int load_private_key()
125
NULL, NULL);
126
127
if (!aclk_dctx) {
128
- error("Loading private key (from claiming) failed - no OpenSSL Decoders found");
128
+ netdata_log_error("Loading private key (from claiming) failed - no OpenSSL Decoders found");
129
goto biofailed;
130
}
131
132
// this is necesseary to avoid RSA key with wrong size
133
if (!OSSL_DECODER_from_bio(aclk_dctx, key_bio)) {
134
- error("Decoding private key (from claiming) failed - invalid format.");
134
+ netdata_log_error("Decoding private key (from claiming) failed - invalid format.");
135
goto biofailed;
136
}
137
#else
@@ -145,7 +145,7 @@ static int load_private_key()
145
}
146
char err[512];
147
ERR_error_string_n(ERR_get_error(), err, sizeof(err));
148
- error("Claimed agent cannot establish ACLK - cannot create private key: %s", err);
148
+ netdata_log_error("Claimed agent cannot establish ACLK - cannot create private key: %s", err);
149
150
biofailed:
151
freez(private_key);
@@ -204,7 +204,7 @@ static int wait_till_agent_claim_ready()
204
// We trap the impossible NULL here to keep the linter happy without using a fatal() in the code.
205
char *cloud_base_url = appconfig_get(&cloud_config, CONFIG_SECTION_GLOBAL, "cloud base url", NULL);
206
if (cloud_base_url == NULL) {
207
- error("Do not move the cloud base url out of post_conf_load!!");
207
+ netdata_log_error("Do not move the cloud base url out of post_conf_load!!");
208
return 1;
209
}
210
@@ -212,7 +212,7 @@ static int wait_till_agent_claim_ready()
212
// TODO make it without malloc/free
213
memset(&url, 0, sizeof(url_t));
214
if (url_parse(cloud_base_url, &url)) {
215
- error("Agent is claimed but the URL in configuration key \"cloud base url\" is invalid, please fix");
215
+ netdata_log_error("Agent is claimed but the URL in configuration key \"cloud base url\" is invalid, please fix");
216
url_t_destroy(&url);
217
sleep(5);
218
continue;
@@ -243,7 +243,7 @@ void aclk_mqtt_wss_log_cb(mqtt_wss_log_type_t log_type, const char* str)
243
debug(D_ACLK, "%s", str);
244
return;
245
default:
246
- error("Unknown log type from mqtt_wss");
246
+ netdata_log_error("Unknown log type from mqtt_wss");
247
}
248
}
249
@@ -255,7 +255,7 @@ static void msg_callback(const char *topic, const void *msg, size_t msglen, int
255
debug(D_ACLK, "Got Message From Broker Topic \"%s\" QOS %d", topic, qos);
256
257
if (aclk_shared_state.mqtt_shutdown_msg_id > 0) {
258
- error("Link is shutting down. Ignoring incoming message.");
258
+ netdata_log_error("Link is shutting down. Ignoring incoming message.");
259
return;
260
}
261
@@ -277,7 +277,7 @@ static void msg_callback(const char *topic, const void *msg, size_t msglen, int
277
snprintf(filename, FN_MAX_LEN, ACLK_LOG_CONVERSATION_DIR "/%010d-rx-%s.bin", ACLK_GET_CONV_LOG_NEXT(), msgtype);
278
logfd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR );
279
if(logfd < 0)
280
- error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
280
+ netdata_log_error("Error opening ACLK Conversation logfile \"%s\" for RX message.", filename);
281
write(logfd, msg, msglen);
282
close(logfd);
283
#endif
@@ -308,7 +308,7 @@ static int read_query_thread_count()
308
threads = MAX(threads, 2);
309
threads = config_get_number(CONFIG_SECTION_CLOUD, "query thread count", threads);
310
if(threads < 1) {
311
- error("You need at least one query thread. Overriding configured setting of \"%d\"", threads);
311
+ netdata_log_error("You need at least one query thread. Overriding configured setting of \"%d\"", threads);
312
threads = 1;
313
config_set_number(CONFIG_SECTION_CLOUD, "query thread count", threads);
314
}
@@ -365,13 +365,13 @@ static inline void mqtt_connected_actions(mqtt_wss_client client)
365
char *topic = (char*)aclk_get_topic(ACLK_TOPICID_COMMAND);
366
367
if (!topic)
368
- error("Unable to fetch topic for COMMAND (to subscribe)");
368
+ netdata_log_error("Unable to fetch topic for COMMAND (to subscribe)");
369
else
370
mqtt_wss_subscribe(client, topic, 1);
371
372
topic = (char*)aclk_get_topic(ACLK_TOPICID_CMD_NG_V1);
373
if (!topic)
374
- error("Unable to fetch topic for protobuf COMMAND (to subscribe)");
374
+ netdata_log_error("Unable to fetch topic for protobuf COMMAND (to subscribe)");
375
else
376
mqtt_wss_subscribe(client, topic, 1);
377
@@ -399,7 +399,7 @@ void aclk_graceful_disconnect(mqtt_wss_client client)
399
time_t t = now_monotonic_sec();
400
while (!mqtt_wss_service(client, 100)) {
401
if (now_monotonic_sec() - t >= 2) {
402
- error("Wasn't able to gracefully shutdown ACLK in time!");
402
+ netdata_log_error("Wasn't able to gracefully shutdown ACLK in time!");
403
break;
404
}
405
if (aclk_shared_state.mqtt_shutdown_msg_rcvd) {
@@ -786,7 +786,7 @@ void *aclk_main(void *ptr)
786
ACLK_PROXY_TYPE proxy_type;
787
aclk_get_proxy(&proxy_type);
788
if (proxy_type == PROXY_TYPE_SOCKS5) {
789
- error("SOCKS5 proxy is not supported by ACLK-NG yet.");
789
+ netdata_log_error("SOCKS5 proxy is not supported by ACLK-NG yet.");
790
static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
791
return NULL;
792
}
@@ -811,7 +811,7 @@ void *aclk_main(void *ptr)
811
goto exit;
812
813
if (!(mqttwss_client = mqtt_wss_new("mqtt_wss", aclk_mqtt_wss_log_cb, msg_callback, puback_callback))) {
814
- error("Couldn't initialize MQTT_WSS network library");
814
+ netdata_log_error("Couldn't initialize MQTT_WSS network library");
815
goto exit;
816
}
817
@@ -906,7 +906,7 @@ void aclk_host_state_update(RRDHOST *host, int cmd)
906
ret = get_node_id(&host->host_uuid, &node_id);
907
if (ret > 0) {
908
// this means we were not able to check if node_id already present
909
- error("Unable to check for node_id. Ignoring the host state update.");
909
+ netdata_log_error("Unable to check for node_id. Ignoring the host state update.");
910
return;
911
}
912
if (ret < 0) {
aclk/aclk_otp.c
+65
-65
@@ -38,7 +38,7 @@ struct auth_data {
38
39
#define PARSE_ENV_JSON_CHK_TYPE(it, type, name) \
40
if (json_object_get_type(json_object_iter_peek_value(it)) != type) { \
41
- error("value of key \"%s\" should be %s", name, #type); \
41
+ netdata_log_error("value of key \"%s\" should be %s", name, #type); \
42
goto exit; \
43
}
44
@@ -55,7 +55,7 @@ static int parse_passwd_response(const char *json_str, struct auth_data *auth) {
55
56
json = json_tokener_parse(json_str);
57
if (!json) {
58
- error("JSON-C failed to parse the payload of http response of /env endpoint");
58
+ netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
59
return 1;
60
}
61
@@ -88,26 +88,26 @@ static int parse_passwd_response(const char *json_str, struct auth_data *auth) {
88
PARSE_ENV_JSON_CHK_TYPE(&it, json_type_array, JSON_KEY_TOPICS)
89
90
if (aclk_generate_topic_cache(json_object_iter_peek_value(&it))) {
91
- error("Failed to generate topic cache!");
91
+ netdata_log_error("Failed to generate topic cache!");
92
goto exit;
93
}
94
json_object_iter_next(&it);
95
continue;
96
}
97
- error("Unknown key \"%s\" in passwd response payload. Ignoring", json_object_iter_peek_name(&it));
97
+ netdata_log_error("Unknown key \"%s\" in passwd response payload. Ignoring", json_object_iter_peek_name(&it));
98
json_object_iter_next(&it);
99
}
100
101
if (!auth->client_id) {
102
- error(JSON_KEY_CLIENTID " is compulsory key in /password response");
102
+ netdata_log_error(JSON_KEY_CLIENTID " is compulsory key in /password response");
103
goto exit;
104
}
105
if (!auth->passwd) {
106
- error(JSON_KEY_PASS " is compulsory in /password response");
106
+ netdata_log_error(JSON_KEY_PASS " is compulsory in /password response");
107
goto exit;
108
}
109
if (!auth->username) {
110
- error(JSON_KEY_USER " is compulsory in /password response");
110
+ netdata_log_error(JSON_KEY_USER " is compulsory in /password response");
111
goto exit;
112
}
113
@@ -126,11 +126,11 @@ exit:
126
static const char *get_json_str_by_path(json_object *json, const char *path) {
127
json_object *ptr;
128
if (json_pointer_get(json, path, &ptr)) {
129
- error("Missing compulsory key \"%s\" in error response", path);
129
+ netdata_log_error("Missing compulsory key \"%s\" in error response", path);
130
return NULL;
131
}
132
if (json_object_get_type(ptr) != json_type_string) {
133
- error("Value of Key \"%s\" in error response should be string", path);
133
+ netdata_log_error("Value of Key \"%s\" in error response should be string", path);
134
return NULL;
135
}
136
return json_object_get_string(ptr);
@@ -147,7 +147,7 @@ static int aclk_parse_otp_error(const char *json_str) {
147
148
json = json_tokener_parse(json_str);
149
if (!json) {
150
- error("JSON-C failed to parse the payload of http response of /env endpoint");
150
+ netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
151
return 1;
152
}
153
@@ -163,7 +163,7 @@ static int aclk_parse_otp_error(const char *json_str) {
163
// optional field
164
if (!json_pointer_get(json, "/" JSON_KEY_ERTRY, &ptr)) {
165
if (json_object_get_type(ptr) != json_type_boolean) {
166
- error("Error response Key " "/" JSON_KEY_ERTRY " should be of boolean type");
166
+ netdata_log_error("Error response Key " "/" JSON_KEY_ERTRY " should be of boolean type");
167
goto exit;
168
}
169
block_retry = json_object_get_boolean(ptr);
@@ -172,7 +172,7 @@ static int aclk_parse_otp_error(const char *json_str) {
172
// optional field
173
if (!json_pointer_get(json, "/" JSON_KEY_EDELAY, &ptr)) {
174
if (json_object_get_type(ptr) != json_type_int) {
175
- error("Error response Key " "/" JSON_KEY_EDELAY " should be of integer type");
175
+ netdata_log_error("Error response Key " "/" JSON_KEY_EDELAY " should be of integer type");
176
goto exit;
177
}
178
backoff = json_object_get_int(ptr);
@@ -184,7 +184,7 @@ static int aclk_parse_otp_error(const char *json_str) {
184
if (backoff > 0)
185
aclk_block_until = now_monotonic_sec() + backoff;
186
187
- error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
187
+ netdata_log_error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
188
rc = 0;
189
exit:
190
json_object_put(json);
@@ -205,7 +205,7 @@ static int aclk_parse_otp_error(const char *json_str) {
205
206
json = json_tokener_parse(json_str);
207
if (!json) {
208
- error("JSON-C failed to parse the payload of http response of /env endpoint");
208
+ netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
209
return 1;
210
}
211
@@ -236,7 +236,7 @@ static int aclk_parse_otp_error(const char *json_str) {
236
}
237
if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_EDELAY)) {
238
if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_int) {
239
- error("value of key " JSON_KEY_EDELAY " should be integer");
239
+ netdata_log_error("value of key " JSON_KEY_EDELAY " should be integer");
240
goto exit;
241
}
242
@@ -246,7 +246,7 @@ static int aclk_parse_otp_error(const char *json_str) {
246
}
247
if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_ERTRY)) {
248
if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_boolean) {
249
- error("value of key " JSON_KEY_ERTRY " should be integer");
249
+ netdata_log_error("value of key " JSON_KEY_ERTRY " should be integer");
250
goto exit;
251
}
252
@@ -254,7 +254,7 @@ static int aclk_parse_otp_error(const char *json_str) {
254
json_object_iter_next(&it);
255
continue;
256
}
257
- error("Unknown key \"%s\" in error response payload. Ignoring", json_object_iter_peek_name(&it));
257
+ netdata_log_error("Unknown key \"%s\" in error response payload. Ignoring", json_object_iter_peek_name(&it));
258
json_object_iter_next(&it);
259
}
260
@@ -264,7 +264,7 @@ static int aclk_parse_otp_error(const char *json_str) {
264
if (backoff > 0)
265
aclk_block_until = now_monotonic_sec() + backoff;
266
267
- error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
267
+ netdata_log_error("Cloud returned EC=\"%s\", Msg-Key:\"%s\", Msg:\"%s\", BlockRetry:%s, Backoff:%ds (-1 unset by cloud)", ec, ek, emsg, block_retry > 0 ? "true" : "false", backoff);
268
rc = 0;
269
exit:
270
json_object_put(json);
@@ -301,7 +301,7 @@ inline static int base64_decode_helper(unsigned char *out, int *outl, const unsi
301
EVP_DecodeFinal(ctx, remaining_data, &remainder);
302
EVP_ENCODE_CTX_free(ctx);
303
if (remainder) {
304
- error("Unexpected data at EVP_DecodeFinal");
304
+ netdata_log_error("Unexpected data at EVP_DecodeFinal");
305
return 1;
306
}
307
return 0;
@@ -322,12 +322,12 @@ int aclk_get_otp_challenge(url_t *target, const char *agent_id, unsigned char **
322
req.url = (char *)buffer_tostring(url);
323
324
if (aclk_https_request(&req, &resp)) {
325
- error ("ACLK_OTP Challenge failed");
325
+ netdata_log_error("ACLK_OTP Challenge failed");
326
buffer_free(url);
327
return 1;
328
}
329
if (resp.http_code != 200) {
330
- error ("ACLK_OTP Challenge HTTP code not 200 OK (got %d)", resp.http_code);
330
+ netdata_log_error("ACLK_OTP Challenge HTTP code not 200 OK (got %d)", resp.http_code);
331
buffer_free(url);
332
if (resp.payload_size)
333
aclk_parse_otp_error(resp.payload);
@@ -339,32 +339,32 @@ int aclk_get_otp_challenge(url_t *target, const char *agent_id, unsigned char **
339
340
json_object *json = json_tokener_parse(resp.payload);
341
if (!json) {
342
- error ("Couldn't parse HTTP GET challenge payload");
342
+ netdata_log_error("Couldn't parse HTTP GET challenge payload");
343
goto cleanup_resp;
344
}
345
json_object *challenge_json;
346
if (!json_object_object_get_ex(json, "challenge", &challenge_json)) {
347
- error ("No key named \"challenge\" in the returned JSON");
347
+ netdata_log_error("No key named \"challenge\" in the returned JSON");
348
goto cleanup_json;
349
}
350
if (!json_object_is_type(challenge_json, json_type_string)) {
351
- error ("\"challenge\" is not a string JSON type");
351
+ netdata_log_error("\"challenge\" is not a string JSON type");
352
goto cleanup_json;
353
}
354
const char *challenge_base64;
355
if (!(challenge_base64 = json_object_get_string(challenge_json))) {
356
- error("Failed to extract challenge from JSON object");
356
+ netdata_log_error("Failed to extract challenge from JSON object");
357
goto cleanup_json;
358
}
359
if (strlen(challenge_base64) != CHALLENGE_LEN_BASE64) {
360
- error("Received Challenge has unexpected length of %zu (expected %d)", strlen(challenge_base64), CHALLENGE_LEN_BASE64);
360
+ netdata_log_error("Received Challenge has unexpected length of %zu (expected %d)", strlen(challenge_base64), CHALLENGE_LEN_BASE64);
361
goto cleanup_json;
362
}
363
364
*challenge = mallocz((CHALLENGE_LEN_BASE64 / 4) * 3);
365
base64_decode_helper(*challenge, challenge_bytes, (const unsigned char*)challenge_base64, strlen(challenge_base64));
366
if (*challenge_bytes != CHALLENGE_LEN) {
367
- error("Unexpected challenge length of %d instead of %d", *challenge_bytes, CHALLENGE_LEN);
367
+ netdata_log_error("Unexpected challenge length of %d instead of %d", *challenge_bytes, CHALLENGE_LEN);
368
freez(*challenge);
369
*challenge = NULL;
370
goto cleanup_json;
@@ -405,11 +405,11 @@ int aclk_send_otp_response(const char *agent_id, const unsigned char *response,
405
req.payload_size = strlen(req.payload);
406
407
if (aclk_https_request(&req, &resp)) {
408
- error ("ACLK_OTP Password error trying to post result to password");
408
+ netdata_log_error("ACLK_OTP Password error trying to post result to password");
409
goto cleanup_buffers;
410
}
411
if (resp.http_code != 201) {
412
- error ("ACLK_OTP Password HTTP code not 201 Created (got %d)", resp.http_code);
412
+ netdata_log_error("ACLK_OTP Password HTTP code not 201 Created (got %d)", resp.http_code);
413
if (resp.payload_size)
414
aclk_parse_otp_error(resp.payload);
415
goto cleanup_response;
@@ -417,7 +417,7 @@ int aclk_send_otp_response(const char *agent_id, const unsigned char *response,
417
netdata_log_info("ACLK_OTP Got Password from Cloud");
418
419
if (parse_passwd_response(resp.payload, mqtt_auth)){
420
- error("Error parsing response of password endpoint");
420
+ netdata_log_error("Error parsing response of password endpoint");
421
goto cleanup_response;
422
}
423
@@ -470,7 +470,7 @@ static int private_decrypt(RSA *p_key, unsigned char * enc_data, int data_len, u
470
{
471
char err[512];
472
ERR_error_string_n(ERR_get_error(), err, sizeof(err));
473
- error("Decryption of the challenge failed: %s", err);
473
+ netdata_log_error("Decryption of the challenge failed: %s", err);
474
}
475
return result;
476
}
@@ -486,13 +486,13 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
486
487
char *agent_id = get_agent_claimid();
488
if (agent_id == NULL) {
489
- error("Agent was not claimed - cannot perform challenge/response");
489
+ netdata_log_error("Agent was not claimed - cannot perform challenge/response");
490
return 1;
491
}
492
493
// Get Challenge
494
if (aclk_get_otp_challenge(target, agent_id, &challenge, &challenge_bytes)) {
495
- error("Error getting challenge");
495
+ netdata_log_error("Error getting challenge");
496
freez(agent_id);
497
return 1;
498
}
@@ -501,7 +501,7 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
501
unsigned char *response_plaintext;
502
int response_plaintext_bytes = private_decrypt(p_key, challenge, challenge_bytes, &response_plaintext);
503
if (response_plaintext_bytes < 0) {
504
- error ("Couldn't decrypt the challenge received");
504
+ netdata_log_error("Couldn't decrypt the challenge received");
505
freez(response_plaintext);
506
freez(challenge);
507
freez(agent_id);
@@ -512,7 +512,7 @@ int aclk_get_mqtt_otp(RSA *p_key, char **mqtt_id, char **mqtt_usr, char **mqtt_p
512
// Encode and Send Challenge
513
struct auth_data data = { .client_id = NULL, .passwd = NULL, .username = NULL };
514
if (aclk_send_otp_response(agent_id, response_plaintext, response_plaintext_bytes, target, &data)) {
515
- error("Error getting response");
515
+ netdata_log_error("Error getting response");
516
freez(response_plaintext);
517
freez(agent_id);
518
return 1;
@@ -549,12 +549,12 @@ static int parse_json_env_transport(json_object *json, aclk_transport_desc_t *tr
549
if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_TRP_TYPE)) {
550
PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_TRP_TYPE)
551
if (trp->type != ACLK_TRP_UNKNOWN) {
552
- error(JSON_KEY_TRP_TYPE " set already");
552
+ netdata_log_error(JSON_KEY_TRP_TYPE " set already");
553
goto exit;
554
}
555
trp->type = aclk_transport_type_t_from_str(json_object_get_string(json_object_iter_peek_value(&it)));
556
if (trp->type == ACLK_TRP_UNKNOWN) {
557
- error(JSON_KEY_TRP_TYPE " unknown type \"%s\"", json_object_get_string(json_object_iter_peek_value(&it)));
557
+ netdata_log_error(JSON_KEY_TRP_TYPE " unknown type \"%s\"", json_object_get_string(json_object_iter_peek_value(&it)));
558
goto exit;
559
}
560
json_object_iter_next(&it);
@@ -564,25 +564,25 @@ static int parse_json_env_transport(json_object *json, aclk_transport_desc_t *tr
564
if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_TRP_ENDPOINT)) {
565
PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_TRP_ENDPOINT)
566
if (trp->endpoint) {
567
- error(JSON_KEY_TRP_ENDPOINT " set already");
567
+ netdata_log_error(JSON_KEY_TRP_ENDPOINT " set already");
568
goto exit;
569
}
570
trp->endpoint = strdupz(json_object_get_string(json_object_iter_peek_value(&it)));
571
json_object_iter_next(&it);
572
continue;
573
}
574
-
575
- error ("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
574
+
575
+ netdata_log_error("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
576
json_object_iter_next(&it);
577
}
578
579
if (!trp->endpoint) {
580
- error (JSON_KEY_TRP_ENDPOINT " is missing from JSON dictionary");
580
+ netdata_log_error(JSON_KEY_TRP_ENDPOINT " is missing from JSON dictionary");
581
goto exit;
582
}
583
584
if (trp->type == ACLK_TRP_UNKNOWN) {
585
- error ("transport type not set");
585
+ netdata_log_error("transport type not set");
586
goto exit;
587
}
588
@@ -598,7 +598,7 @@ static int parse_json_env_transports(json_object *json_array, aclk_env_t *env) {
598
json_object *obj;
599
600
if (env->transports) {
601
- error("transports have been set already");
601
+ netdata_log_error("transports have been set already");
602
return 1;
603
}
604
@@ -610,7 +610,7 @@ static int parse_json_env_transports(json_object *json_array, aclk_env_t *env) {
610
trp = callocz(1, sizeof(aclk_transport_desc_t));
611
obj = json_object_array_get_idx(json_array, i);
612
if (parse_json_env_transport(obj, trp)) {
613
- error("error parsing transport idx %d", (int)i);
613
+ netdata_log_error("error parsing transport idx %d", (int)i);
614
freez(trp);
615
return 1;
616
}
@@ -626,14 +626,14 @@ static int parse_json_env_transports(json_object *json_array, aclk_env_t *env) {
626
static int parse_json_backoff_int(struct json_object_iterator *it, int *out, const char* name, int min, int max) {
627
if (!strcmp(json_object_iter_peek_name(it), name)) {
628
if (json_object_get_type(json_object_iter_peek_value(it)) != json_type_int) {
629
- error("Could not parse \"%s\". Not an integer as expected.", name);
629
+ netdata_log_error("Could not parse \"%s\". Not an integer as expected.", name);
630
return MATCHED_ERROR;
631
}
632
633
*out = json_object_get_int(json_object_iter_peek_value(it));
634
635
if (*out < min || *out > max) {
636
- error("Value of \"%s\"=%d out of range (%d-%d).", name, *out, min, max);
636
+ netdata_log_error("Value of \"%s\"=%d out of range (%d-%d).", name, *out, min, max);
637
return MATCHED_ERROR;
638
}
639
@@ -675,7 +675,7 @@ static int parse_json_backoff(json_object *json, aclk_backoff_t *backoff) {
675
continue;
676
}
677
678
- error ("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
678
+ netdata_log_error("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
679
json_object_iter_next(&it);
680
}
681
@@ -687,7 +687,7 @@ static int parse_json_env_caps(json_object *json, aclk_env_t *env) {
687
const char *str;
688
689
if (env->capabilities) {
690
- error("transports have been set already");
690
+ netdata_log_error("transports have been set already");
691
return 1;
692
}
693
@@ -702,12 +702,12 @@ static int parse_json_env_caps(json_object *json, aclk_env_t *env) {
702
for (size_t i = 0; i < env->capability_count; i++) {
703
obj = json_object_array_get_idx(json, i);
704
if (json_object_get_type(obj) != json_type_string) {
705
- error("Capability at index %d not a string!", (int)i);
705
+ netdata_log_error("Capability at index %d not a string!", (int)i);
706
return 1;
707
}
708
str = json_object_get_string(obj);
709
if (!str) {
710
- error("Error parsing capabilities");
710
+ netdata_log_error("Error parsing capabilities");
711
return 1;
712
}
713
env->capabilities[i] = strdupz(str);
@@ -723,7 +723,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
723
724
json = json_tokener_parse(json_str);
725
if (!json) {
726
- error("JSON-C failed to parse the payload of http response of /env endpoint");
726
+ netdata_log_error("JSON-C failed to parse the payload of http response of /env endpoint");
727
return 1;
728
}
729
@@ -734,7 +734,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
734
if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_AUTH_ENDPOINT)) {
735
PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_AUTH_ENDPOINT)
736
if (env->auth_endpoint) {
737
- error("authEndpoint set already");
737
+ netdata_log_error("authEndpoint set already");
738
goto exit;
739
}
740
env->auth_endpoint = strdupz(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -745,7 +745,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
745
if (!strcmp(json_object_iter_peek_name(&it), JSON_KEY_ENC)) {
746
PARSE_ENV_JSON_CHK_TYPE(&it, json_type_string, JSON_KEY_ENC)
747
if (env->encoding != ACLK_ENC_UNKNOWN) {
748
- error(JSON_KEY_ENC " set already");
748
+ netdata_log_error(JSON_KEY_ENC " set already");
749
goto exit;
750
}
751
env->encoding = aclk_encoding_type_t_from_str(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -768,7 +768,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
768
769
if (parse_json_backoff(json_object_iter_peek_value(&it), &env->backoff)) {
770
env->backoff.base = 0;
771
- error("Error parsing Backoff parameters in env");
771
+ netdata_log_error("Error parsing Backoff parameters in env");
772
goto exit;
773
}
774
@@ -780,7 +780,7 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
780
PARSE_ENV_JSON_CHK_TYPE(&it, json_type_array, JSON_KEY_CAPS)
781
782
if (parse_json_env_caps(json_object_iter_peek_value(&it), env)) {
783
- error("Error parsing capabilities list");
783
+ netdata_log_error("Error parsing capabilities list");
784
goto exit;
785
}
786
@@ -788,25 +788,25 @@ static int parse_json_env(const char *json_str, aclk_env_t *env) {
788
continue;
789
}
790
791
- error ("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
791
+ netdata_log_error("unknown JSON key in dictionary (\"%s\")", json_object_iter_peek_name(&it));
792
json_object_iter_next(&it);
793
}
794
795
// Check all compulsory keys have been set
796
if (env->transport_count < 1) {
797
- error("env has to return at least one transport");
797
+ netdata_log_error("env has to return at least one transport");
798
goto exit;
799
}
800
if (!env->auth_endpoint) {
801
- error(JSON_KEY_AUTH_ENDPOINT " is compulsory");
801
+ netdata_log_error(JSON_KEY_AUTH_ENDPOINT " is compulsory");
802
goto exit;
803
}
804
if (env->encoding == ACLK_ENC_UNKNOWN) {
805
- error(JSON_KEY_ENC " is compulsory");
805
+ netdata_log_error(JSON_KEY_ENC " is compulsory");
806
goto exit;
807
}
808
if (!env->backoff.base) {
809
- error(JSON_KEY_BACKOFF " is compulsory");
809
+ netdata_log_error(JSON_KEY_BACKOFF " is compulsory");
810
goto exit;
811
}
812
@@ -830,7 +830,7 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
830
char *agent_id = get_agent_claimid();
831
if (agent_id == NULL)
832
{
833
- error("Agent was not claimed - cannot perform challenge/response");
833
+ netdata_log_error("Agent was not claimed - cannot perform challenge/response");
834
buffer_free(buf);
835
return 1;
836
}
@@ -843,13 +843,13 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
843
req.port = aclk_port;
844
req.url = buf->buffer;
845
if (aclk_https_request(&req, &resp)) {
846
- error("Error trying to contact env endpoint");
846
+ netdata_log_error("Error trying to contact env endpoint");
847
https_req_response_free(&resp);
848
buffer_free(buf);
849
return 2;
850
}
851
if (resp.http_code != 200) {
852
- error("The HTTP code not 200 OK (Got %d)", resp.http_code);
852
+ netdata_log_error("The HTTP code not 200 OK (Got %d)", resp.http_code);
853
if (resp.payload_size)
854
aclk_parse_otp_error(resp.payload);
855
https_req_response_free(&resp);
@@ -858,14 +858,14 @@ int aclk_get_env(aclk_env_t *env, const char* aclk_hostname, int aclk_port) {
858
}
859
860
if (!resp.payload || !resp.payload_size) {
861
- error("Unexpected empty payload as response to /env call");
861
+ netdata_log_error("Unexpected empty payload as response to /env call");
862
https_req_response_free(&resp);
863
buffer_free(buf);
864
return 4;
865
}
866
867
if (parse_json_env(resp.payload, env)) {
868
- error ("error parsing /env message");
868
+ netdata_log_error("error parsing /env message");
869
https_req_response_free(&resp);
870
buffer_free(buf);
871
return 5;
aclk/aclk_proxy.c
+1
-1
@@ -85,7 +85,7 @@ static inline void safe_log_proxy_error(char *str, const char *proxy)
85
{
86
char *log = strdupz(proxy);
87
safe_log_proxy_censor(log);
88
- error("%s Provided Value:\"%s\"", str, log);
88
+ netdata_log_error("%s Provided Value:\"%s\"", str, log);
89
freez(log);
90
}
91
aclk/aclk_query.c
+4
-4
@@ -164,7 +164,7 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
164
w->response.zinitialized = true;
165
w->response.zoutput = true;
166
} else
167
- error("Failed to initialize zlib. Proceeding without compression.");
167
+ netdata_log_error("Failed to initialize zlib. Proceeding without compression.");
168
}
169
}
170
@@ -177,9 +177,9 @@ static int http_api_v2(struct aclk_query_thread *query_thr, aclk_query_t query)
177
z_ret = deflate(&w->response.zstream, Z_FINISH);
178
if(z_ret < 0) {
179
if(w->response.zstream.msg)
180
- error("Error compressing body. ZLIB error: \"%s\"", w->response.zstream.msg);
180
+ netdata_log_error("Error compressing body. ZLIB error: \"%s\"", w->response.zstream.msg);
181
else
182
- error("Unknown error during zlib compression.");
182
+ netdata_log_error("Unknown error during zlib compression.");
183
retval = 1;
184
w->response.code = 500;
185
aclk_http_msg_v2_err(query_thr->client, query->callback_topic, query->msg_id, w->response.code, CLOUD_EC_ZLIB_ERROR, CLOUD_EMSG_ZLIB_ERROR, NULL, 0);
@@ -366,7 +366,7 @@ void aclk_query_threads_start(struct aclk_query_threads *query_threads, mqtt_wss
366
query_threads->thread_list[i].client = client;
367
368
if(unlikely(snprintfz(thread_name, TASK_LEN_MAX, "ACLK_QRY[%d]", i) < 0))
369
- error("snprintf encoding error");
369
+ netdata_log_error("snprintf encoding error");
370
netdata_thread_create(
371
&query_threads->thread_list[i].thread, thread_name, NETDATA_THREAD_OPTION_JOINABLE, aclk_query_main_thread,
372
&query_threads->thread_list[i]);
aclk/aclk_query_queue.c
+2
-2
@@ -27,7 +27,7 @@ static inline int _aclk_queue_query(aclk_query_t query)
27
if (aclk_query_queue.block_push) {
28
ACLK_QUEUE_UNLOCK;
29
if(service_running(SERVICE_ACLK | ABILITY_DATA_QUERIES))
30
- error("Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
30
+ netdata_log_error("Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
31
aclk_query_free(query);
32
return 1;
33
}
@@ -67,7 +67,7 @@ aclk_query_t aclk_queue_pop(void)
67
if (aclk_query_queue.block_push) {
68
ACLK_QUEUE_UNLOCK;
69
if(service_running(SERVICE_ACLK | ABILITY_DATA_QUERIES))
70
- error("POP Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
70
+ netdata_log_error("POP Query Queue is blocked from accepting new requests. This is normally the case when ACLK prepares to shutdown.");
71
return NULL;
72
}
73
aclk/aclk_query_queue.h
+1
-1
@@ -79,7 +79,7 @@ void aclk_queue_unlock(void);
79
if (likely(query->data.bin_payload.payload)) { \
80
aclk_queue_query(query); \
81
} else { \
82
- error("Failed to generate payload (%s)", __FUNCTION__); \
82
+ netdata_log_error("Failed to generate payload (%s)", __FUNCTION__); \
83
aclk_query_free(query); \
84
}
85
aclk/aclk_rx_msgs.c
+16
-16
@@ -103,14 +103,14 @@ static inline int aclk_v2_payload_get_query(const char *payload, char **query_ur
103
// TODO better check of URL
104
if(strncmp(payload, ACLK_CLOUD_REQ_V2_PREFIX, strlen(ACLK_CLOUD_REQ_V2_PREFIX))) {
105
errno = 0;
106
- error("Only accepting requests that start with \"%s\" from CLOUD.", ACLK_CLOUD_REQ_V2_PREFIX);
106
+ netdata_log_error("Only accepting requests that start with \"%s\" from CLOUD.", ACLK_CLOUD_REQ_V2_PREFIX);
107
return 1;
108
}
109
start = payload + 4;
110
111
if(!(end = strstr(payload, " HTTP/1.1\x0D\x0A"))) {
112
errno = 0;
113
- error("Doesn't look like HTTP GET request.");
113
+ netdata_log_error("Doesn't look like HTTP GET request.");
114
return 1;
115
}
116
@@ -126,7 +126,7 @@ static int aclk_handle_cloud_http_request_v2(struct aclk_request *cloud_to_agent
126
127
errno = 0;
128
if (cloud_to_agent->version < ACLK_V_COMPRESSION) {
129
- error(
129
+ netdata_log_error(
130
"This handler cannot reply to request with version older than %d, received %d.",
131
ACLK_V_COMPRESSION,
132
cloud_to_agent->version);
@@ -136,22 +136,22 @@ static int aclk_handle_cloud_http_request_v2(struct aclk_request *cloud_to_agent
136
query = aclk_query_new(HTTP_API_V2);
137
138
if (unlikely(aclk_extract_v2_data(raw_payload, &query->data.http_api_v2.payload))) {
139
- error("Error extracting payload expected after the JSON dictionary.");
139
+ netdata_log_error("Error extracting payload expected after the JSON dictionary.");
140
goto error;
141
}
142
143
if (unlikely(aclk_v2_payload_get_query(query->data.http_api_v2.payload, &query->dedup_id))) {
144
- error("Could not extract payload from query");
144
+ netdata_log_error("Could not extract payload from query");
145
goto error;
146
}
147
148
if (unlikely(!cloud_to_agent->callback_topic)) {
149
- error("Missing callback_topic");
149
+ netdata_log_error("Missing callback_topic");
150
goto error;
151
}
152
153
if (unlikely(!cloud_to_agent->msg_id)) {
154
- error("Missing msg_id");
154
+ netdata_log_error("Missing msg_id");
155
goto error;
156
}
157
@@ -254,13 +254,13 @@ int create_node_instance_result(const char *msg, size_t msg_len)
254
255
uuid_t host_id, node_id;
256
if (uuid_parse(res.machine_guid, host_id)) {
257
- error("Error parsing machine_guid provided by CreateNodeInstanceResult");
257
+ netdata_log_error("Error parsing machine_guid provided by CreateNodeInstanceResult");
258
freez(res.machine_guid);
259
freez(res.node_id);
260
return 1;
261
}
262
if (uuid_parse(res.node_id, node_id)) {
263
- error("Error parsing node_id provided by CreateNodeInstanceResult");
263
+ netdata_log_error("Error parsing node_id provided by CreateNodeInstanceResult");
264
freez(res.machine_guid);
265
freez(res.node_id);
266
return 1;
@@ -341,7 +341,7 @@ int start_alarm_streaming(const char *msg, size_t msg_len)
341
{
342
struct start_alarm_streaming res = parse_start_alarm_streaming(msg, msg_len);
343
if (!res.node_id) {
344
- error("Error parsing StartAlarmStreaming");
344
+ netdata_log_error("Error parsing StartAlarmStreaming");
345
return 1;
346
}
347
aclk_start_alert_streaming(res.node_id, res.resets);
@@ -353,7 +353,7 @@ int send_alarm_checkpoint(const char *msg, size_t msg_len)
353
{
354
struct send_alarm_checkpoint sac = parse_send_alarm_checkpoint(msg, msg_len);
355
if (!sac.node_id || !sac.claim_id) {
356
- error("Error parsing SendAlarmCheckpoint");
356
+ netdata_log_error("Error parsing SendAlarmCheckpoint");
357
freez(sac.node_id);
358
freez(sac.claim_id);
359
return 1;
@@ -368,7 +368,7 @@ int send_alarm_configuration(const char *msg, size_t msg_len)
368
{
369
char *config_hash = parse_send_alarm_configuration(msg, msg_len);
370
if (!config_hash || !*config_hash) {
371
- error("Error parsing SendAlarmConfiguration");
371
+ netdata_log_error("Error parsing SendAlarmConfiguration");
372
freez(config_hash);
373
return 1;
374
}
@@ -381,7 +381,7 @@ int send_alarm_snapshot(const char *msg, size_t msg_len)
381
{
382
struct send_alarm_snapshot *sas = parse_send_alarm_snapshot(msg, msg_len);
383
if (!sas->node_id || !sas->claim_id || !sas->snapshot_uuid) {
384
- error("Error parsing SendAlarmSnapshot");
384
+ netdata_log_error("Error parsing SendAlarmSnapshot");
385
destroy_send_alarm_snapshot(sas);
386
return 1;
387
}
@@ -396,7 +396,7 @@ int handle_disconnect_req(const char *msg, size_t msg_len)
396
if (!cmd)
397
return 1;
398
if (cmd->permaban) {
399
- error("Cloud Banned This Agent!");
399
+ netdata_log_error("Cloud Banned This Agent!");
400
aclk_disable_runtime = 1;
401
}
402
netdata_log_info("Cloud requested disconnect (EC=%u, \"%s\")", (unsigned int)cmd->error_code, cmd->error_description);
@@ -531,7 +531,7 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
531
new_cloud_rx_msg_t *msg_descriptor = find_rx_handler_by_hash(simple_hash(message_type));
532
debug(D_ACLK, "Got message named '%s' from cloud", message_type);
533
if (unlikely(!msg_descriptor)) {
534
- error("Do not know how to handle message of type '%s'. Ignoring", message_type);
534
+ netdata_log_error("Do not know how to handle message of type '%s'. Ignoring", message_type);
535
if (aclk_stats_enabled) {
536
ACLK_STATS_LOCK;
537
aclk_metrics_per_sample.cloud_req_err++;
@@ -557,7 +557,7 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
557
ACLK_STATS_UNLOCK;
558
}
559
if (msg_descriptor->fnc(msg, msg_len)) {
560
- error("Error processing message of type '%s'", message_type);
560
+ netdata_log_error("Error processing message of type '%s'", message_type);
561
if (aclk_stats_enabled) {
562
ACLK_STATS_LOCK;
563
aclk_metrics_per_sample.cloud_req_err++;
aclk/aclk_stats.c
+2
-2
@@ -193,7 +193,7 @@ static void aclk_stats_query_threads(uint32_t *queries_per_thread)
193
194
for (int i = 0; i < aclk_stats_cfg.query_thread_count; i++) {
195
if (snprintfz(dim_name, MAX_DIM_NAME, "Query %d", i) < 0)
196
- error("snprintf encoding error");
196
+ netdata_log_error("snprintf encoding error");
197
aclk_qt_data[i].dim = rrddim_add(st, dim_name, NULL, 1, localhost->rrd_update_every, RRD_ALGORITHM_ABSOLUTE);
198
}
199
}
@@ -463,7 +463,7 @@ void aclk_stats_msg_puback(uint16_t id)
463
464
if (unlikely(!pub_time[id])) {
465
ACLK_STATS_UNLOCK;
466
- error("Received PUBACK for unknown message?!");
466
+ netdata_log_error("Received PUBACK for unknown message?!");
467
return;
468
}
469
aclk/aclk_tx_msgs.c
+7
-7
@@ -32,7 +32,7 @@ uint16_t aclk_send_bin_message_subtopic_pid(mqtt_wss_client client, char *msg, s
32
const char *topic = aclk_get_topic(subtopic);
33
34
if (unlikely(!topic)) {
35
- error("Couldn't get topic. Aborting message send.");
35
+ netdata_log_error("Couldn't get topic. Aborting message send.");
36
return 0;
37
}
38
@@ -61,7 +61,7 @@ static int aclk_send_message_with_bin_payload(mqtt_wss_client client, json_objec
61
int len;
62
63
if (unlikely(!topic || topic[0] != '/')) {
64
- error ("Full topic required!");
64
+ netdata_log_error("Full topic required!");
65
json_object_put(msg);
66
return HTTP_RESP_INTERNAL_SERVER_ERROR;
67
}
@@ -172,7 +172,7 @@ void aclk_http_msg_v2_err(mqtt_wss_client client, const char *topic, const char
172
json_object_object_add(msg, "error-description", tmp);
173
174
if (aclk_send_message_with_bin_payload(client, msg, topic, payload, payload_len)) {
175
- error("Failed to send cancellation message for http reply %zu %s", payload_len, payload);
175
+ netdata_log_error("Failed to send cancellation message for http reply %zu %s", payload_len, payload);
176
}
177
}
178
@@ -220,7 +220,7 @@ uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable
220
221
rrdhost_aclk_state_lock(localhost);
222
if (unlikely(!localhost->aclk_state.claimed_id)) {
223
- error("Internal error. Should not come here if not claimed");
223
+ netdata_log_error("Internal error. Should not come here if not claimed");
224
rrdhost_aclk_state_unlock(localhost);
225
return 0;
226
}
@@ -233,7 +233,7 @@ uint16_t aclk_send_agent_connection_update(mqtt_wss_client client, int reachable
233
rrdhost_aclk_state_unlock(localhost);
234
235
if (!msg) {
236
- error("Error generating agent::v1::UpdateAgentConnection payload");
236
+ netdata_log_error("Error generating agent::v1::UpdateAgentConnection payload");
237
return 0;
238
}
239
@@ -255,7 +255,7 @@ char *aclk_generate_lwt(size_t *size) {
255
256
rrdhost_aclk_state_lock(localhost);
257
if (unlikely(!localhost->aclk_state.claimed_id)) {
258
- error("Internal error. Should not come here if not claimed");
258
+ netdata_log_error("Internal error. Should not come here if not claimed");
259
rrdhost_aclk_state_unlock(localhost);
260
return NULL;
261
}
@@ -265,7 +265,7 @@ char *aclk_generate_lwt(size_t *size) {
265
rrdhost_aclk_state_unlock(localhost);
266
267
if (!msg)
268
- error("Error generating agent::v1::UpdateAgentConnection payload for LWT");
268
+ netdata_log_error("Error generating agent::v1::UpdateAgentConnection payload for LWT");
269
270
return msg;
271
}
aclk/aclk_util.c
+12
-12
@@ -185,7 +185,7 @@ static void topic_generate_final(struct aclk_topic *t) {
185
186
rrdhost_aclk_state_lock(localhost);
187
if (unlikely(!localhost->aclk_state.claimed_id)) {
188
- error("This should never be called if agent not claimed");
188
+ netdata_log_error("This should never be called if agent not claimed");
189
rrdhost_aclk_state_unlock(localhost);
190
return;
191
}
@@ -214,7 +214,7 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
214
while (!json_object_iter_equal(&it, &itEnd)) {
215
if (!strcmp(json_object_iter_peek_name(&it), JSON_TOPIC_KEY_NAME)) {
216
if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_string) {
217
- error("topic dictionary key \"" JSON_TOPIC_KEY_NAME "\" is expected to be json_type_string");
217
+ netdata_log_error("topic dictionary key \"" JSON_TOPIC_KEY_NAME "\" is expected to be json_type_string");
218
return 1;
219
}
220
topic->topic_id = topic_name_to_id(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -226,7 +226,7 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
226
}
227
if (!strcmp(json_object_iter_peek_name(&it), JSON_TOPIC_KEY_TOPIC)) {
228
if (json_object_get_type(json_object_iter_peek_value(&it)) != json_type_string) {
229
- error("topic dictionary key \"" JSON_TOPIC_KEY_TOPIC "\" is expected to be json_type_string");
229
+ netdata_log_error("topic dictionary key \"" JSON_TOPIC_KEY_TOPIC "\" is expected to be json_type_string");
230
return 1;
231
}
232
topic->topic_recvd = strdupz(json_object_get_string(json_object_iter_peek_value(&it)));
@@ -234,12 +234,12 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
234
continue;
235
}
236
237
- error("topic dictionary has Unknown/Unexpected key \"%s\" in topic description. Ignoring!", json_object_iter_peek_name(&it));
237
+ netdata_log_error("topic dictionary has Unknown/Unexpected key \"%s\" in topic description. Ignoring!", json_object_iter_peek_name(&it));
238
json_object_iter_next(&it);
239
}
240
241
if (!topic->topic_recvd) {
242
- error("topic dictionary Missig compulsory key %s", JSON_TOPIC_KEY_TOPIC);
242
+ netdata_log_error("topic dictionary Missig compulsory key %s", JSON_TOPIC_KEY_TOPIC);
243
return 1;
244
}
245
@@ -255,7 +255,7 @@ int aclk_generate_topic_cache(struct json_object *json)
255
256
size_t array_size = json_object_array_length(json);
257
if (!array_size) {
258
- error("Empty topic list!");
258
+ netdata_log_error("Empty topic list!");
259
return 1;
260
}
261
@@ -267,19 +267,19 @@ int aclk_generate_topic_cache(struct json_object *json)
267
for (size_t i = 0; i < array_size; i++) {
268
obj = json_object_array_get_idx(json, i);
269
if (json_object_get_type(obj) != json_type_object) {
270
- error("expected json_type_object");
270
+ netdata_log_error("expected json_type_object");
271
return 1;
272
}
273
aclk_topic_cache[i] = callocz(1, sizeof(struct aclk_topic));
274
if (topic_cache_add_topic(obj, aclk_topic_cache[i])) {
275
- error("failed to parse topic @idx=%d", (int)i);
275
+ netdata_log_error("failed to parse topic @idx=%d", (int)i);
276
return 1;
277
}
278
}
279
280
for (int i = 0; compulsory_topics[i] != ACLK_TOPICID_UNKNOWN; i++) {
281
if (!aclk_get_topic(compulsory_topics[i])) {
282
- error("missing compulsory topic \"%s\" in password response from cloud", topic_id_to_name(compulsory_topics[i]));
282
+ netdata_log_error("missing compulsory topic \"%s\" in password response from cloud", topic_id_to_name(compulsory_topics[i]));
283
return 1;
284
}
285
}
@@ -295,7 +295,7 @@ int aclk_generate_topic_cache(struct json_object *json)
295
const char *aclk_get_topic(enum aclk_topics topic)
296
{
297
if (!aclk_topic_cache) {
298
- error("Topic cache not initialized");
298
+ netdata_log_error("Topic cache not initialized");
299
return NULL;
300
}
301
@@ -303,7 +303,7 @@ const char *aclk_get_topic(enum aclk_topics topic)
303
if (aclk_topic_cache[i]->topic_id == topic)
304
return aclk_topic_cache[i]->topic;
305
}
306
- error("Unknown topic");
306
+ netdata_log_error("Unknown topic");
307
return NULL;
308
}
309
@@ -315,7 +315,7 @@ const char *aclk_get_topic(enum aclk_topics topic)
315
const char *aclk_topic_cache_iterate(aclk_topic_cache_iter_t *iter)
316
{
317
if (!aclk_topic_cache) {
318
- error("Topic cache not initialized when %s was called.", __FUNCTION__);
318
+ netdata_log_error("Topic cache not initialized when %s was called.", __FUNCTION__);
319
return NULL;
320
}
321
aclk/https_client.c
+43
-43
@@ -70,17 +70,17 @@ static int parse_http_hdr(rbuf_t buf, http_parse_ctx *parse_ctx)
70
char buf_val[HTTP_HDR_BUFFER_SIZE];
71
char *ptr = buf_key;
72
if (!rbuf_find_bytes(buf, HTTP_LINE_TERM, strlen(HTTP_LINE_TERM), &idx_end)) {
73
- error("CRLF expected");
73
+ netdata_log_error("CRLF expected");
74
return 1;
75
}
76
77
char *separator = rbuf_find_bytes(buf, HTTP_KEYVAL_SEPARATOR, strlen(HTTP_KEYVAL_SEPARATOR), &idx);
78
if (!separator) {
79
- error("Missing Key/Value separator");
79
+ netdata_log_error("Missing Key/Value separator");
80
return 1;
81
}
82
if (idx >= HTTP_HDR_BUFFER_SIZE) {
83
- error("Key name is too long");
83
+ netdata_log_error("Key name is too long");
84
return 1;
85
}
86
@@ -90,7 +90,7 @@ static int parse_http_hdr(rbuf_t buf, http_parse_ctx *parse_ctx)
90
rbuf_bump_tail(buf, strlen(HTTP_KEYVAL_SEPARATOR));
91
idx_end -= strlen(HTTP_KEYVAL_SEPARATOR) + idx;
92
if (idx_end >= HTTP_HDR_BUFFER_SIZE) {
93
- error("Value of key \"%s\" too long", buf_key);
93
+ netdata_log_error("Value of key \"%s\" too long", buf_key);
94
return 1;
95
}
96
@@ -116,22 +116,22 @@ static int parse_http_response(rbuf_t buf, http_parse_ctx *parse_ctx)
116
switch (parse_ctx->state) {
117
case HTTP_PARSE_INITIAL:
118
if (rbuf_memcmp_n(buf, RESP_PROTO, strlen(RESP_PROTO))) {
119
- error("Expected response to start with \"%s\"", RESP_PROTO);
119
+ netdata_log_error("Expected response to start with \"%s\"", RESP_PROTO);
120
return PARSE_ERROR;
121
}
122
rbuf_bump_tail(buf, strlen(RESP_PROTO));
123
if (rbuf_pop(buf, rc, 4) != 4) {
124
- error("Expected HTTP status code");
124
+ netdata_log_error("Expected HTTP status code");
125
return PARSE_ERROR;
126
}
127
if (rc[3] != ' ') {
128
- error("Expected space after HTTP return code");
128
+ netdata_log_error("Expected space after HTTP return code");
129
return PARSE_ERROR;
130
}
131
rc[3] = 0;
132
parse_ctx->http_code = atoi(rc);
133
if (parse_ctx->http_code < 100 || parse_ctx->http_code >= 600) {
134
- error("HTTP code not in range 100 to 599");
134
+ netdata_log_error("HTTP code not in range 100 to 599");
135
return PARSE_ERROR;
136
}
137
@@ -186,7 +186,7 @@ typedef struct https_req_ctx {
186
187
static int https_req_check_timedout(https_req_ctx_t *ctx) {
188
if (now_realtime_sec() > ctx->req_start_time + ctx->request->timeout_s) {
189
- error("request timed out");
189
+ netdata_log_error("request timed out");
190
return 1;
191
}
192
return 0;
@@ -220,12 +220,12 @@ static int socket_write_all(https_req_ctx_t *ctx, char *data, size_t data_len) {
220
do {
221
int ret = poll(&ctx->poll_fd, 1, POLL_TO_MS);
222
if (ret < 0) {
223
- error("poll error");
223
+ netdata_log_error("poll error");
224
return 1;
225
}
226
if (ret == 0) {
227
if (https_req_check_timedout(ctx)) {
228
- error("Poll timed out");
228
+ netdata_log_error("Poll timed out");
229
return 2;
230
}
231
continue;
@@ -235,7 +235,7 @@ static int socket_write_all(https_req_ctx_t *ctx, char *data, size_t data_len) {
235
if (ret > 0) {
236
ctx->written += ret;
237
} else if (errno != EAGAIN && errno != EWOULDBLOCK) {
238
- error("Error writing to socket");
238
+ netdata_log_error("Error writing to socket");
239
return 3;
240
}
241
} while (ctx->written < data_len);
@@ -250,12 +250,12 @@ static int ssl_write_all(https_req_ctx_t *ctx, char *data, size_t data_len) {
250
do {
251
int ret = poll(&ctx->poll_fd, 1, POLL_TO_MS);
252
if (ret < 0) {
253
- error("poll error");
253
+ netdata_log_error("poll error");
254
return 1;
255
}
256
if (ret == 0) {
257
if (https_req_check_timedout(ctx)) {
258
- error("Poll timed out");
258
+ netdata_log_error("Poll timed out");
259
return 2;
260
}
261
continue;
@@ -275,7 +275,7 @@ static int ssl_write_all(https_req_ctx_t *ctx, char *data, size_t data_len) {
275
ctx->poll_fd.events |= POLLOUT;
276
break;
277
default:
278
- error("SSL_write Err: %s", _ssl_err_tos(ret));
278
+ netdata_log_error("SSL_write Err: %s", _ssl_err_tos(ret));
279
return 3;
280
}
281
}
@@ -299,12 +299,12 @@ static int read_parse_response(https_req_ctx_t *ctx) {
299
do {
300
ret = poll(&ctx->poll_fd, 1, POLL_TO_MS);
301
if (ret < 0) {
302
- error("poll error");
302
+ netdata_log_error("poll error");
303
return 1;
304
}
305
if (ret == 0) {
306
if (https_req_check_timedout(ctx)) {
307
- error("Poll timed out");
307
+ netdata_log_error("Poll timed out");
308
return 2;
309
}
310
if (!ctx->ssl_ctx)
@@ -332,12 +332,12 @@ static int read_parse_response(https_req_ctx_t *ctx) {
332
ctx->poll_fd.events |= POLLOUT;
333
break;
334
default:
335
- error("SSL_read Err: %s", _ssl_err_tos(ret));
335
+ netdata_log_error("SSL_read Err: %s", _ssl_err_tos(ret));
336
return 3;
337
}
338
} else {
339
if (errno != EAGAIN && errno != EWOULDBLOCK) {
340
- error("write error");
340
+ netdata_log_error("write error");
341
return 3;
342
}
343
ctx->poll_fd.events |= POLLIN;
@@ -346,7 +346,7 @@ static int read_parse_response(https_req_ctx_t *ctx) {
346
} while (!(ret = parse_http_response(ctx->buf_rx, &ctx->parse_ctx)));
347
348
if (ret != PARSE_SUCCESS) {
349
- error("Error parsing HTTP response");
349
+ netdata_log_error("Error parsing HTTP response");
350
return 1;
351
}
352
@@ -373,7 +373,7 @@ static int handle_http_request(https_req_ctx_t *ctx) {
373
buffer_strcat(hdr, "POST ");
374
break;
375
default:
376
- error("Unknown HTTPS request type!");
376
+ netdata_log_error("Unknown HTTPS request type!");
377
rc = 1;
378
goto err_exit;
379
}
@@ -419,14 +419,14 @@ static int handle_http_request(https_req_ctx_t *ctx) {
419
420
// Send the request
421
if (https_client_write_all(ctx, hdr->buffer, hdr->len)) {
422
- error("Couldn't write HTTP request header into SSL connection");
422
+ netdata_log_error("Couldn't write HTTP request header into SSL connection");
423
rc = 2;
424
goto err_exit;
425
}
426
427
if (ctx->request->request_type == HTTP_REQ_POST && ctx->request->payload && ctx->request->payload_size) {
428
if (https_client_write_all(ctx, ctx->request->payload, ctx->request->payload_size)) {
429
- error("Couldn't write payload into SSL connection");
429
+ netdata_log_error("Couldn't write payload into SSL connection");
430
rc = 3;
431
goto err_exit;
432
}
@@ -434,7 +434,7 @@ static int handle_http_request(https_req_ctx_t *ctx) {
434
435
// Read The Response
436
if (read_parse_response(ctx)) {
437
- error("Error reading or parsing response from server");
437
+ netdata_log_error("Error reading or parsing response from server");
438
rc = 4;
439
goto err_exit;
440
}
@@ -456,7 +456,7 @@ static int cert_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
456
err_cert = X509_STORE_CTX_get_current_cert(ctx);
457
err_str = X509_NAME_oneline(X509_get_subject_name(err_cert), NULL, 0);
458
459
- error("Cert Chain verify error:num=%d:%s:depth=%d:%s", err,
459
+ netdata_log_error("Cert Chain verify error:num=%d:%s:depth=%d:%s", err,
460
X509_verify_cert_error_string(err), depth, err_str);
461
462
free(err_str);
@@ -466,7 +466,7 @@ static int cert_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
466
if (!preverify_ok && err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)
467
{
468
preverify_ok = 1;
469
- error("Self Signed Certificate Accepted as the agent was built with ACLK_SSL_ALLOW_SELF_SIGNED");
469
+ netdata_log_error("Self Signed Certificate Accepted as the agent was built with ACLK_SSL_ALLOW_SELF_SIGNED");
470
}
471
#endif
472
@@ -486,7 +486,7 @@ int https_request(https_req_t *request, https_req_response_t *response) {
486
487
ctx->buf_rx = rbuf_create(RX_BUFFER_SIZE);
488
if (!ctx->buf_rx) {
489
- error("Couldn't allocate buffer for RX data");
489
+ netdata_log_error("Couldn't allocate buffer for RX data");
490
goto exit_req_ctx;
491
}
492
@@ -494,12 +494,12 @@ int https_request(https_req_t *request, https_req_response_t *response) {
494
495
ctx->sock = connect_to_this_ip46(IPPROTO_TCP, SOCK_STREAM, connect_host, 0, connect_port_str, &timeout);
496
if (ctx->sock < 0) {
497
- error("Error connecting TCP socket to \"%s\"", connect_host);
497
+ netdata_log_error("Error connecting TCP socket to \"%s\"", connect_host);
498
goto exit_buf_rx;
499
}
500
501
if (fcntl(ctx->sock, F_SETFL, fcntl(ctx->sock, F_GETFL, 0) | O_NONBLOCK) == -1) {
502
- error("Error setting O_NONBLOCK to TCP socket.");
502
+ netdata_log_error("Error setting O_NONBLOCK to TCP socket.");
503
goto exit_sock;
504
}
505
@@ -517,11 +517,11 @@ int https_request(https_req_t *request, https_req_response_t *response) {
517
req.proxy_password = request->proxy_password;
518
ctx->request = &req;
519
if (handle_http_request(ctx)) {
520
- error("Failed to CONNECT with proxy");
520
+ netdata_log_error("Failed to CONNECT with proxy");
521
goto exit_sock;
522
}
523
if (ctx->parse_ctx.http_code != 200) {
524
- error("Proxy didn't return 200 OK (got %d)", ctx->parse_ctx.http_code);
524
+ netdata_log_error("Proxy didn't return 200 OK (got %d)", ctx->parse_ctx.http_code);
525
goto exit_sock;
526
}
527
netdata_log_info("Proxy accepted CONNECT upgrade");
@@ -530,26 +530,26 @@ int https_request(https_req_t *request, https_req_response_t *response) {
530
531
ctx->ssl_ctx = netdata_ssl_create_client_ctx(0);
532
if (ctx->ssl_ctx==NULL) {
533
- error("Cannot allocate SSL context");
533
+ netdata_log_error("Cannot allocate SSL context");
534
goto exit_sock;
535
}
536
537
if (!SSL_CTX_set_default_verify_paths(ctx->ssl_ctx)) {
538
- error("Error setting default verify paths");
538
+ netdata_log_error("Error setting default verify paths");
539
goto exit_CTX;
540
}
541
SSL_CTX_set_verify(ctx->ssl_ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, cert_verify_callback);
542
543
ctx->ssl = SSL_new(ctx->ssl_ctx);
544
if (ctx->ssl==NULL) {
545
- error("Cannot allocate SSL");
545
+ netdata_log_error("Cannot allocate SSL");
546
goto exit_CTX;
547
}
548
549
SSL_set_fd(ctx->ssl, ctx->sock);
550
ret = SSL_connect(ctx->ssl);
551
if (ret != -1 && ret != 1) {
552
- error("SSL could not connect");
552
+ netdata_log_error("SSL could not connect");
553
goto exit_SSL;
554
}
555
if (ret == -1) {
@@ -557,14 +557,14 @@ int https_request(https_req_t *request, https_req_response_t *response) {
557
// consult SSL_connect documentation for details
558
int ec = SSL_get_error(ctx->ssl, ret);
559
if (ec != SSL_ERROR_WANT_READ && ec != SSL_ERROR_WANT_WRITE) {
560
- error("Failed to start SSL connection");
560
+ netdata_log_error("Failed to start SSL connection");
561
goto exit_SSL;
562
}
563
}
564
565
// The actual request here
566
if (handle_http_request(ctx)) {
567
- error("Couldn't process request");
567
+ netdata_log_error("Couldn't process request");
568
goto exit_SSL;
569
}
570
response->http_code = ctx->parse_ctx.http_code;
@@ -573,7 +573,7 @@ int https_request(https_req_t *request, https_req_response_t *response) {
573
response->payload = mallocz(response->payload_size + 1);
574
ret = rbuf_pop(ctx->buf_rx, response->payload, response->payload_size);
575
if (ret != (int)response->payload_size) {
576
- error("Payload size doesn't match remaining data on the buffer!");
576
+ netdata_log_error("Payload size doesn't match remaining data on the buffer!");
577
response->payload_size = ret;
578
}
579
// normally we take payload as it is and copy it
@@ -627,16 +627,16 @@ static int parse_host_port(url_t *url) {
627
if (ptr) {
628
size_t port_len = strlen(ptr + 1);
629
if (!port_len) {
630
- error(URL_PARSER_LOG_PREFIX ": specified but no port number");
630
+ netdata_log_error(URL_PARSER_LOG_PREFIX ": specified but no port number");
631
return 1;
632
}
633
if (port_len > 5 /* MAX port length is 5digit long in decimal */) {
634
- error(URL_PARSER_LOG_PREFIX "port # is too long");
634
+ netdata_log_error(URL_PARSER_LOG_PREFIX "port # is too long");
635
return 1;
636
}
637
*ptr = 0;
638
if (!strlen(url->host)) {
639
- error(URL_PARSER_LOG_PREFIX "host empty after removing port");
639
+ netdata_log_error(URL_PARSER_LOG_PREFIX "host empty after removing port");
640
return 1;
641
}
642
url->port = atoi (ptr + 1);
@@ -672,7 +672,7 @@ int url_parse(const char *url, url_t *parsed) {
672
673
if (end) {
674
if (end == start) {
675
- error (URL_PARSER_LOG_PREFIX "found " URI_PROTO_SEPARATOR " without protocol specified");
675
+ netdata_log_error(URL_PARSER_LOG_PREFIX "found " URI_PROTO_SEPARATOR " without protocol specified");
676
return 1;
677
}
678
@@ -685,7 +685,7 @@ int url_parse(const char *url, url_t *parsed) {
685
end = start + strlen(start);
686
687
if (start == end) {
688
- error(URL_PARSER_LOG_PREFIX "Host empty");
688
+ netdata_log_error(URL_PARSER_LOG_PREFIX "Host empty");
689
return 1;
690
}
691
aclk/schema-wrappers/alarm_stream.cc
+1
-1
@@ -59,7 +59,7 @@ static alarms::v1::AlarmStatus aclk_alarm_status_to_proto(enum aclk_alarm_status
59
case aclk_alarm_status::ALARM_STATUS_CRITICAL:
60
return alarms::v1::ALARM_STATUS_CRITICAL;
61
default:
62
- error("Unknown alarm status");
62
+ netdata_log_error("Unknown alarm status");
63
return alarms::v1::ALARM_STATUS_UNKNOWN;
64
}
65
}
claim/claim.c
+9
-9
@@ -50,7 +50,7 @@ extern struct registry registry;
50
CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, const char **msg)
51
{
52
if (!force || !netdata_cloud_enabled) {
53
- error("Refusing to claim agent -> cloud functionality has been disabled");
53
+ netdata_log_error("Refusing to claim agent -> cloud functionality has been disabled");
54
return CLAIM_AGENT_CLOUD_DISABLED;
55
}
56
@@ -88,7 +88,7 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
88
netdata_log_info("Executing agent claiming command 'netdata-claim.sh'");
89
fp_child_output = netdata_popen(command_buffer, &command_pid, &fp_child_input);
90
if(!fp_child_output) {
91
- error("Cannot popen(\"%s\").", command_buffer);
91
+ netdata_log_error("Cannot popen(\"%s\").", command_buffer);
92
return CLAIM_AGENT_CANNOT_EXECUTE_CLAIM_SCRIPT;
93
}
94
netdata_log_info("Waiting for claiming command to finish.");
@@ -100,19 +100,19 @@ CLAIM_AGENT_RESPONSE claim_agent(const char *claiming_arguments, bool force, con
100
return CLAIM_AGENT_OK;
101
}
102
if (exit_code < 0) {
103
- error("Agent claiming command failed to complete its run.");
103
+ netdata_log_error("Agent claiming command failed to complete its run.");
104
return CLAIM_AGENT_CLAIM_SCRIPT_FAILED;
105
}
106
errno = 0;
107
unsigned maximum_known_exit_code = sizeof(claiming_errors) / sizeof(claiming_errors[0]) - 1;
108
109
if ((unsigned)exit_code > maximum_known_exit_code) {
110
- error("Agent failed to be claimed with an unknown error.");
110
+ netdata_log_error("Agent failed to be claimed with an unknown error.");
111
return CLAIM_AGENT_CLAIM_SCRIPT_RETURNED_INVALID_CODE;
112
}
113
114
- error("Agent failed to be claimed with the following error message:");
115
- error("\"%s\"", claiming_errors[exit_code]);
114
+ netdata_log_error("Agent failed to be claimed with the following error message:");
115
+ netdata_log_error("\"%s\"", claiming_errors[exit_code]);
116
117
if(msg) *msg = claiming_errors[exit_code];
118
@@ -167,7 +167,7 @@ void load_claiming_state(void)
167
long bytes_read;
168
char *claimed_id = read_by_filename(filename, &bytes_read);
169
if(claimed_id && uuid_parse(claimed_id, uuid)) {
170
- error("claimed_id \"%s\" doesn't look like valid UUID", claimed_id);
170
+ netdata_log_error("claimed_id \"%s\" doesn't look like valid UUID", claimed_id);
171
freez(claimed_id);
172
claimed_id = NULL;
173
}
@@ -250,12 +250,12 @@ bool netdata_random_session_id_generate(void) {
250
// save it
251
int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 640);
252
if(fd == -1) {
253
- error("Cannot create random session id file '%s'.", filename);
253
+ netdata_log_error("Cannot create random session id file '%s'.", filename);
254
ret = false;
255
}
256
257
if(write(fd, guid, UUID_STR_LEN - 1) != UUID_STR_LEN - 1) {
258
- error("Cannot write the random session id file '%s'.", filename);
258
+ netdata_log_error("Cannot write the random session id file '%s'.", filename);
259
ret = false;
260
}
261
cli/cli.c
+6
-6
@@ -32,7 +32,7 @@ void *callocz_int(size_t nmemb, size_t size, const char *file __maybe_unused, co
32
{
33
void *p = calloc(nmemb, size);
34
if (unlikely(!p)) {
35
- error("Cannot allocate %zu bytes of memory.", nmemb * size);
35
+ netdata_log_error("Cannot allocate %zu bytes of memory.", nmemb * size);
36
exit(1);
37
}
38
return p;
@@ -42,7 +42,7 @@ void *mallocz_int(size_t size, const char *file __maybe_unused, const char *func
42
{
43
void *p = malloc(size);
44
if (unlikely(!p)) {
45
- error("Cannot allocate %zu bytes of memory.", size);
45
+ netdata_log_error("Cannot allocate %zu bytes of memory.", size);
46
exit(1);
47
}
48
return p;
@@ -52,7 +52,7 @@ void *reallocz_int(void *ptr, size_t size, const char *file __maybe_unused, cons
52
{
53
void *p = realloc(ptr, size);
54
if (unlikely(!p)) {
55
- error("Cannot allocate %zu bytes of memory.", size);
55
+ netdata_log_error("Cannot allocate %zu bytes of memory.", size);
56
exit(1);
57
}
58
return p;
@@ -70,7 +70,7 @@ void freez(void *ptr) {
70
void *mallocz(size_t size) {
71
void *p = malloc(size);
72
if (unlikely(!p)) {
73
- error("Cannot allocate %zu bytes of memory.", size);
73
+ netdata_log_error("Cannot allocate %zu bytes of memory.", size);
74
exit(1);
75
}
76
return p;
@@ -79,7 +79,7 @@ void *mallocz(size_t size) {
79
void *callocz(size_t nmemb, size_t size) {
80
void *p = calloc(nmemb, size);
81
if (unlikely(!p)) {
82
- error("Cannot allocate %zu bytes of memory.", nmemb * size);
82
+ netdata_log_error("Cannot allocate %zu bytes of memory.", nmemb * size);
83
exit(1);
84
}
85
return p;
@@ -88,7 +88,7 @@ void *callocz(size_t nmemb, size_t size) {
88
void *reallocz(void *ptr, size_t size) {
89
void *p = realloc(ptr, size);
90
if (unlikely(!p)) {
91
- error("Cannot allocate %zu bytes of memory.", size);
91
+ netdata_log_error("Cannot allocate %zu bytes of memory.", size);
92
exit(1);
93
}
94
return p;
collectors/apps.plugin/apps_plugin.c
+51
-46
@@ -666,7 +666,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
666
}
667
else {
668
if(unlikely(avl_insert(&ids->index, (avl_t *) user_or_group_id) != (void *) user_or_group_id)) {
669
- error("INTERNAL ERROR: duplicate indexing of id during realloc");
669
+ netdata_log_error("INTERNAL ERROR: duplicate indexing of id during realloc");
670
};
671
672
user_or_group_id->next = ids->root;
@@ -682,7 +682,7 @@ int read_user_or_group_ids(struct user_or_group_ids *ids, struct timespec *last_
682
while(user_or_group_id) {
683
if(unlikely(!user_or_group_id->updated)) {
684
if(unlikely((struct user_or_group_id *)avl_remove(&ids->index, (avl_t *) user_or_group_id) != user_or_group_id))
685
- error("INTERNAL ERROR: removal of unused id from index, removed a different id");
685
+ netdata_log_error("INTERNAL ERROR: removal of unused id from index, removed a different id");
686
687
if(prev_user_id)
688
prev_user_id->next = user_or_group_id->next;
@@ -947,7 +947,7 @@ static int read_apps_groups_conf(const char *path, const char *file)
947
// add this target
948
struct target *n = get_apps_groups_target(s, w, name);
949
if(!n) {
950
- error("Cannot create target '%s' (line %zu, word %zu)", s, line, word);
950
+ netdata_log_error("Cannot create target '%s' (line %zu, word %zu)", s, line, word);
951
continue;
952
}
953
@@ -997,7 +997,7 @@ static inline void del_pid_entry(pid_t pid) {
997
struct pid_stat *p = all_pids[pid];
998
999
if(unlikely(!p)) {
1000
- error("attempted to free pid %d that is not allocated.", pid);
1000
+ netdata_log_error("attempted to free pid %d that is not allocated.", pid);
1001
return;
1002
}
1003
@@ -1035,7 +1035,7 @@ static inline void del_pid_entry(pid_t pid) {
1035
1036
static inline int managed_log(struct pid_stat *p, uint32_t log, int status) {
1037
if(unlikely(!status)) {
1038
- // error("command failed log %u, errno %d", log, errno);
1038
+ // netdata_log_error("command failed log %u, errno %d", log, errno);
1039
1040
if(unlikely(debug_enabled || errno != ENOENT)) {
1041
if(unlikely(debug_enabled || !(p->log_thrown & log))) {
@@ -1043,33 +1043,33 @@ static inline int managed_log(struct pid_stat *p, uint32_t log, int status) {
1043
switch(log) {
1044
case PID_LOG_IO:
1045
#ifdef __FreeBSD__
1046
- error("Cannot fetch process %d I/O info (command '%s')", p->pid, p->comm);
1046
+ netdata_log_error("Cannot fetch process %d I/O info (command '%s')", p->pid, p->comm);
1047
#else
1048
- error("Cannot process %s/proc/%d/io (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1048
+ netdata_log_error("Cannot process %s/proc/%d/io (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1049
#endif
1050
break;
1051
1052
case PID_LOG_STATUS:
1053
#ifdef __FreeBSD__
1054
- error("Cannot fetch process %d status info (command '%s')", p->pid, p->comm);
1054
+ netdata_log_error("Cannot fetch process %d status info (command '%s')", p->pid, p->comm);
1055
#else
1056
- error("Cannot process %s/proc/%d/status (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1056
+ netdata_log_error("Cannot process %s/proc/%d/status (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1057
#endif
1058
break;
1059
1060
case PID_LOG_CMDLINE:
1061
#ifdef __FreeBSD__
1062
- error("Cannot fetch process %d command line (command '%s')", p->pid, p->comm);
1062
+ netdata_log_error("Cannot fetch process %d command line (command '%s')", p->pid, p->comm);
1063
#else
1064
- error("Cannot process %s/proc/%d/cmdline (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1064
+ netdata_log_error("Cannot process %s/proc/%d/cmdline (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1065
#endif
1066
break;
1067
1068
case PID_LOG_FDS:
1069
#ifdef __FreeBSD__
1070
- error("Cannot fetch process %d files (command '%s')", p->pid, p->comm);
1070
+ netdata_log_error("Cannot fetch process %d files (command '%s')", p->pid, p->comm);
1071
#else
1072
- error("Cannot process entries in %s/proc/%d/fd (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1072
+ netdata_log_error("Cannot process entries in %s/proc/%d/fd (command '%s')", netdata_configured_host_prefix, p->pid, p->comm);
1073
#endif
1074
break;
1075
@@ -1077,7 +1077,7 @@ static inline int managed_log(struct pid_stat *p, uint32_t log, int status) {
1077
break;
1078
1079
default:
1080
- error("unhandled error for pid %d, command '%s'", p->pid, p->comm);
1080
+ netdata_log_error("unhandled error for pid %d, command '%s'", p->pid, p->comm);
1081
break;
1082
}
1083
}
@@ -1085,7 +1085,7 @@ static inline int managed_log(struct pid_stat *p, uint32_t log, int status) {
1085
errno = 0;
1086
}
1087
else if(unlikely(p->log_thrown & log)) {
1088
- // error("unsetting log %u on pid %d", log, p->pid);
1088
+ // netdata_log_error("unsetting log %u on pid %d", log, p->pid);
1089
p->log_thrown &= ~log;
1090
}
1091
@@ -1733,7 +1733,7 @@ cleanup:
1733
int file_descriptor_compare(void* a, void* b) {
1734
#ifdef NETDATA_INTERNAL_CHECKS
1735
if(((struct file_descriptor *)a)->magic != 0x0BADCAFE || ((struct file_descriptor *)b)->magic != 0x0BADCAFE)
1736
- error("Corrupted index data detected. Please report this.");
1736
+ netdata_log_error("Corrupted index data detected. Please report this.");
1737
#endif /* NETDATA_INTERNAL_CHECKS */
1738
1739
if(((struct file_descriptor *)a)->hash < ((struct file_descriptor *)b)->hash)
@@ -1777,7 +1777,7 @@ static inline void file_descriptor_not_used(int id)
1777
1778
#ifdef NETDATA_INTERNAL_CHECKS
1779
if(all_files[id].magic != 0x0BADCAFE) {
1780
- error("Ignoring request to remove empty file id %d.", id);
1780
+ netdata_log_error("Ignoring request to remove empty file id %d.", id);
1781
return;
1782
}
1783
#endif /* NETDATA_INTERNAL_CHECKS */
@@ -1791,7 +1791,7 @@ static inline void file_descriptor_not_used(int id)
1791
debug_log(" >> slot %d is empty.", id);
1792
1793
if(unlikely(file_descriptor_remove(&all_files[id]) != (void *)&all_files[id]))
1794
- error("INTERNAL ERROR: removal of unused fd from index, removed a different fd");
1794
+ netdata_log_error("INTERNAL ERROR: removal of unused fd from index, removed a different fd");
1795
1796
#ifdef NETDATA_INTERNAL_CHECKS
1797
all_files[id].magic = 0x00000000;
@@ -1800,9 +1800,14 @@ static inline void file_descriptor_not_used(int id)
1800
}
1801
}
1802
else
1803
- error("Request to decrease counter of fd %d (%s), while the use counter is 0", id, all_files[id].name);
1803
+ netdata_log_error("Request to decrease counter of fd %d (%s), while the use counter is 0",
1804
+ id,
1805
+ all_files[id].name);
1806
}
1805
- else error("Request to decrease counter of fd %d, which is outside the array size (1 to %d)", id, all_files_size);
1807
+ else
1808
+ netdata_log_error("Request to decrease counter of fd %d, which is outside the array size (1 to %d)",
1809
+ id,
1810
+ all_files_size);
1811
}
1812
1813
static inline void all_files_grow() {
@@ -1824,7 +1829,7 @@ static inline void all_files_grow() {
1829
for(i = 0; i < all_files_size; i++) {
1830
if(!all_files[i].count) continue;
1831
if(unlikely(file_descriptor_add(&all_files[i]) != (void *)&all_files[i]))
1827
- error("INTERNAL ERROR: duplicate indexing of fd during realloc.");
1832
+ netdata_log_error("INTERNAL ERROR: duplicate indexing of fd during realloc.");
1833
}
1834
1835
debug_log(" >> re-indexing done.");
@@ -1865,7 +1870,7 @@ static inline int file_descriptor_set_on_empty_slot(const char *name, uint32_t h
1870
1871
#ifdef NETDATA_INTERNAL_CHECKS
1872
if(all_files[c].magic == 0x0BADCAFE && all_files[c].name && file_descriptor_find(all_files[c].name, all_files[c].hash))
1868
- error("fd on position %d is not cleared properly. It still has %s in it.", c, all_files[c].name);
1873
+ netdata_log_error("fd on position %d is not cleared properly. It still has %s in it.", c, all_files[c].name);
1874
#endif /* NETDATA_INTERNAL_CHECKS */
1875
1876
debug_log(" >> %s fd position %d for %s (last name: %s)", all_files[c].name?"re-using":"using", c, name, all_files[c].name);
@@ -1896,7 +1901,7 @@ static inline int file_descriptor_set_on_empty_slot(const char *name, uint32_t h
1901
all_files[c].magic = 0x0BADCAFE;
1902
#endif /* NETDATA_INTERNAL_CHECKS */
1903
if(unlikely(file_descriptor_add(&all_files[c]) != (void *)&all_files[c]))
1899
- error("INTERNAL ERROR: duplicate indexing of fd.");
1904
+ netdata_log_error("INTERNAL ERROR: duplicate indexing of fd.");
1905
1906
debug_log("using fd position %d (name: %s)", c, all_files[c].name);
1907
@@ -2014,13 +2019,13 @@ static inline int read_pid_file_descriptors(struct pid_stat *p, void *ptr) {
2019
mib[3] = p->pid;
2020
2021
if (unlikely(sysctl(mib, 4, NULL, &size, NULL, 0))) {
2017
- error("sysctl error: Can't get file descriptors data size for pid %d", p->pid);
2022
+ netdata_log_error("sysctl error: Can't get file descriptors data size for pid %d", p->pid);
2023
return 0;
2024
}
2025
if (likely(size > 0))
2026
fdsbuf = reallocz(fdsbuf, size);
2027
if (unlikely(sysctl(mib, 4, fdsbuf, &size, NULL, 0))) {
2023
- error("sysctl error: Can't get file descriptors data for pid %d", p->pid);
2028
+ netdata_log_error("sysctl error: Can't get file descriptors data for pid %d", p->pid);
2029
return 0;
2030
}
2031
@@ -2193,7 +2198,7 @@ static inline int read_pid_file_descriptors(struct pid_stat *p, void *ptr) {
2198
// cannot read the link
2199
2200
if(debug_enabled || (p->target && p->target->debug_enabled))
2196
- error("Cannot read link %s", p->fds[fdid].filename);
2201
+ netdata_log_error("Cannot read link %s", p->fds[fdid].filename);
2202
2203
if(unlikely(p->fds[fdid].fd < 0)) {
2204
file_descriptor_not_used(-p->fds[fdid].fd);
@@ -2524,7 +2529,7 @@ static inline void link_all_processes_to_their_parents(void) {
2529
}
2530
else {
2531
p->parent = NULL;
2527
- error("pid %d %s states parent %d, but the later does not exist.", p->pid, p->comm, p->ppid);
2532
+ netdata_log_error("pid %d %s states parent %d, but the later does not exist.", p->pid, p->comm, p->ppid);
2533
}
2534
}
2535
}
@@ -2562,7 +2567,7 @@ static int compar_pid(const void *pid1, const void *pid2) {
2567
2568
static inline int collect_data_for_pid(pid_t pid, void *ptr) {
2569
if(unlikely(pid < 0 || pid > pid_max)) {
2565
- error("Invalid pid %d read (expected %d to %d). Ignoring process.", pid, 0, pid_max);
2570
+ netdata_log_error("Invalid pid %d read (expected %d to %d). Ignoring process.", pid, 0, pid_max);
2571
return 0;
2572
}
2573
@@ -2581,7 +2586,7 @@ static inline int collect_data_for_pid(pid_t pid, void *ptr) {
2586
2587
// check its parent pid
2588
if(unlikely(p->ppid < 0 || p->ppid > pid_max)) {
2584
- error("Pid %d (command '%s') states invalid parent pid %d. Using 0.", pid, p->comm, p->ppid);
2589
+ netdata_log_error("Pid %d (command '%s') states invalid parent pid %d. Using 0.", pid, p->comm, p->ppid);
2590
p->ppid = 0;
2591
}
2592
@@ -2633,7 +2638,7 @@ static int collect_data_for_all_processes(void) {
2638
2639
int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_PROC };
2640
if (unlikely(sysctl(mib, 3, NULL, &new_procbase_size, NULL, 0))) {
2636
- error("sysctl error: Can't get processes data size");
2641
+ netdata_log_error("sysctl error: Can't get processes data size");
2642
return 0;
2643
}
2644
@@ -2653,7 +2658,7 @@ static int collect_data_for_all_processes(void) {
2658
2659
// get the processes from the system
2660
if (unlikely(sysctl(mib, 3, procbase, &new_procbase_size, NULL, 0))) {
2656
- error("sysctl error: Can't get processes data");
2661
+ netdata_log_error("sysctl error: Can't get processes data");
2662
return 0;
2663
}
2664
@@ -2681,7 +2686,7 @@ static int collect_data_for_all_processes(void) {
2686
2687
#if (ALL_PIDS_ARE_READ_INSTANTLY == 0)
2688
if(unlikely(slc != all_pids_count)) {
2684
- error("Internal error: I was thinking I had %zu processes in my arrays, but it seems there are %zu.", all_pids_count, slc);
2689
+ netdata_log_error("Internal error: I was thinking I had %zu processes in my arrays, but it seems there are %zu.", all_pids_count, slc);
2690
all_pids_count = slc;
2691
}
2692
@@ -3105,7 +3110,7 @@ static inline void aggregate_pid_on_target(struct target *w, struct pid_stat *p,
3110
}
3111
3112
if(unlikely(!w)) {
3108
- error("pid %d %s was left without a target!", p->pid, p->comm);
3113
+ netdata_log_error("pid %d %s was left without a target!", p->pid, p->comm);
3114
return;
3115
}
3116
@@ -4187,7 +4192,7 @@ static void parse_args(int argc, char **argv)
4192
exit(1);
4193
}
4194
4190
- error("Cannot understand option %s", argv[i]);
4195
+ netdata_log_error("Cannot understand option %s", argv[i]);
4196
exit(1);
4197
}
4198
@@ -4197,7 +4202,7 @@ static void parse_args(int argc, char **argv)
4202
netdata_log_info("Cannot read process groups configuration file '%s/apps_groups.conf'. Will try '%s/apps_groups.conf'", user_config_dir, stock_config_dir);
4203
4204
if(read_apps_groups_conf(stock_config_dir, "groups")) {
4200
- error("Cannot read process groups '%s/apps_groups.conf'. There are no internal defaults. Failing.", stock_config_dir);
4205
+ netdata_log_error("Cannot read process groups '%s/apps_groups.conf'. There are no internal defaults. Failing.", stock_config_dir);
4206
exit(1);
4207
}
4208
else
@@ -4223,7 +4228,7 @@ static int am_i_running_as_root() {
4228
static int check_capabilities() {
4229
cap_t caps = cap_get_proc();
4230
if(!caps) {
4226
- error("Cannot get current capabilities.");
4231
+ netdata_log_error("Cannot get current capabilities.");
4232
return 0;
4233
}
4234
else if(debug_enabled)
@@ -4233,12 +4238,12 @@ static int check_capabilities() {
4238
4239
cap_flag_value_t cfv = CAP_CLEAR;
4240
if(cap_get_flag(caps, CAP_DAC_READ_SEARCH, CAP_EFFECTIVE, &cfv) == -1) {
4236
- error("Cannot find if CAP_DAC_READ_SEARCH is effective.");
4241
+ netdata_log_error("Cannot find if CAP_DAC_READ_SEARCH is effective.");
4242
ret = 0;
4243
}
4244
else {
4245
if(cfv != CAP_SET) {
4241
- error("apps.plugin should run with CAP_DAC_READ_SEARCH.");
4246
+ netdata_log_error("apps.plugin should run with CAP_DAC_READ_SEARCH.");
4247
ret = 0;
4248
}
4249
else if(debug_enabled)
@@ -4247,12 +4252,12 @@ static int check_capabilities() {
4252
4253
cfv = CAP_CLEAR;
4254
if(cap_get_flag(caps, CAP_SYS_PTRACE, CAP_EFFECTIVE, &cfv) == -1) {
4250
- error("Cannot find if CAP_SYS_PTRACE is effective.");
4255
+ netdata_log_error("Cannot find if CAP_SYS_PTRACE is effective.");
4256
ret = 0;
4257
}
4258
else {
4259
if(cfv != CAP_SET) {
4255
- error("apps.plugin should run with CAP_SYS_PTRACE.");
4260
+ netdata_log_error("apps.plugin should run with CAP_SYS_PTRACE.");
4261
ret = 0;
4262
}
4263
else if(debug_enabled)
@@ -5240,7 +5245,7 @@ void *reader_main(void *arg __maybe_unused) {
5245
char *function = get_word(words, num_words, 3);
5246
5247
if(!transaction || !*transaction || !timeout_s || !*timeout_s || !function || !*function) {
5243
- error("Received incomplete %s (transaction = '%s', timeout = '%s', function = '%s'). Ignoring it.",
5248
+ netdata_log_error("Received incomplete %s (transaction = '%s', timeout = '%s', function = '%s'). Ignoring it.",
5249
keyword,
5250
transaction?transaction:"(unset)",
5251
timeout_s?timeout_s:"(unset)",
@@ -5266,12 +5271,12 @@ void *reader_main(void *arg __maybe_unused) {
5271
}
5272
}
5273
else
5269
- error("Received unknown command: %s", keyword?keyword:"(unset)");
5274
+ netdata_log_error("Received unknown command: %s", keyword?keyword:"(unset)");
5275
}
5276
5277
if(!s || feof(stdin) || ferror(stdin)) {
5278
apps_plugin_exit = true;
5274
- error("Received error on stdin.");
5279
+ netdata_log_error("Received error on stdin.");
5280
}
5281
5282
exit(1);
@@ -5351,14 +5356,14 @@ int main(int argc, char **argv) {
5356
if(!check_capabilities() && !am_i_running_as_root() && !check_proc_1_io()) {
5357
uid_t uid = getuid(), euid = geteuid();
5358
#ifdef HAVE_CAPABILITY
5354
- error("apps.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
5359
+ netdata_log_error("apps.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
5360
"Without these, apps.plugin cannot report disk I/O utilization of other processes. "
5361
"To enable capabilities run: sudo setcap cap_dac_read_search,cap_sys_ptrace+ep %s; "
5362
"To enable setuid to root run: sudo chown root:netdata %s; sudo chmod 4750 %s; "
5363
, uid, euid, argv[0], argv[0], argv[0]
5364
);
5365
#else
5361
- error("apps.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
5366
+ netdata_log_error("apps.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
5367
"Without these, apps.plugin cannot report disk I/O utilization of other processes. "
5368
"Your system does not support capabilities. "
5369
"To enable setuid to root run: sudo chown root:netdata %s; sudo chmod 4750 %s; "
@@ -5419,7 +5424,7 @@ int main(int argc, char **argv) {
5424
get_MemTotal();
5425
5426
if(!collect_data_for_all_processes()) {
5422
- error("Cannot collect /proc data for running processes. Disabling apps.plugin...");
5427
+ netdata_log_error("Cannot collect /proc data for running processes. Disabling apps.plugin...");
5428
printf("DISABLE\n");
5429
netdata_mutex_unlock(&mutex);
5430
netdata_thread_cancel(reader_thread);
collectors/cups.plugin/cups_plugin.c
+4
-4
@@ -104,7 +104,7 @@ void parse_command_line(int argc, char **argv) {
104
if (freq >= netdata_update_every) {
105
netdata_update_every = freq;
106
} else if (freq) {
107
- error("update frequency %d seconds is too small for CUPS. Using %d.", freq, netdata_update_every);
107
+ netdata_log_error("update frequency %d seconds is too small for CUPS. Using %d.", freq, netdata_update_every);
108
}
109
}
110
@@ -275,7 +275,7 @@ int main(int argc, char **argv) {
275
httpClose(http);
276
http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, cupsEncryption(), 0, netdata_update_every * 1000, NULL);
277
if(http == NULL) {
278
- error("cups daemon is not running. Exiting!");
278
+ netdata_log_error("cups daemon is not running. Exiting!");
279
exit(1);
280
}
281
}
@@ -321,7 +321,7 @@ int main(int argc, char **argv) {
321
fprintf(stderr, "printer state is missing for destination %s", curr_dest->name);
322
break;
323
default:
324
- error("Unknown printer state (%d) found.", printer_state);
324
+ netdata_log_error("Unknown printer state (%d) found.", printer_state);
325
break;
326
}
327
@@ -364,7 +364,7 @@ int main(int argc, char **argv) {
364
global_job_metrics.size_processing += curr_job->size;
365
break;
366
default:
367
- error("Unsupported job state (%u) found.", curr_job->state);
367
+ netdata_log_error("Unsupported job state (%u) found.", curr_job->state);
368
break;
369
}
370
}
collectors/debugfs.plugin/debugfs_plugin.c
+5
-5
@@ -30,18 +30,18 @@ static int debugfs_check_capabilities()
30
{
31
cap_t caps = cap_get_proc();
32
if (!caps) {
33
- error("Cannot get current capabilities.");
33
+ netdata_log_error("Cannot get current capabilities.");
34
return 0;
35
}
36
37
int ret = 1;
38
cap_flag_value_t cfv = CAP_CLEAR;
39
if (cap_get_flag(caps, CAP_DAC_READ_SEARCH, CAP_EFFECTIVE, &cfv) == -1) {
40
- error("Cannot find if CAP_DAC_READ_SEARCH is effective.");
40
+ netdata_log_error("Cannot find if CAP_DAC_READ_SEARCH is effective.");
41
ret = 0;
42
} else {
43
if (cfv != CAP_SET) {
44
- error("debugfs.plugin should run with CAP_DAC_READ_SEARCH.");
44
+ netdata_log_error("debugfs.plugin should run with CAP_DAC_READ_SEARCH.");
45
ret = 0;
46
}
47
}
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
186
if (!debugfs_check_capabilities() && !debugfs_am_i_running_as_root() && !debugfs_check_sys_permission()) {
187
uid_t uid = getuid(), euid = geteuid();
188
#ifdef HAVE_CAPABILITY
189
- error(
189
+ netdata_log_error(
190
"debugfs.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
191
"Without these, debugfs.plugin cannot access /sys/kernel/debug. "
192
"To enable capabilities run: sudo setcap cap_dac_read_search,cap_sys_ptrace+ep %s; "
@@ -197,7 +197,7 @@ int main(int argc, char **argv)
197
argv[0],
198
argv[0]);
199
#else
200
- error(
200
+ netdata_log_error(
201
"debugfs.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
202
"Without these, debugfs.plugin cannot access /sys/kernel/debug."
203
"Your system does not support capabilities. "
collectors/debugfs.plugin/debugfs_zswap.c
+1
-1
@@ -251,7 +251,7 @@ int zswap_collect_data(struct netdata_zswap_metric *metric)
251
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, metric->filename);
252
253
if (read_single_number_file(filename, (unsigned long long *)&metric->value)) {
254
- error("Cannot read file %s", filename);
254
+ netdata_log_error("Cannot read file %s", filename);
255
return 1;
256
}
257
collectors/ebpf.plugin/ebpf.c
+13
-13
@@ -557,7 +557,7 @@ ARAL *ebpf_allocate_pid_aral(char *name, size_t size)
557
{
558
static size_t max_elements = NETDATA_EBPF_ALLOC_MAX_PID;
559
if (max_elements < NETDATA_EBPF_ALLOC_MIN_ELEMENTS) {
560
- error("Number of elements given is too small, adjusting it for %d", NETDATA_EBPF_ALLOC_MIN_ELEMENTS);
560
+ netdata_log_error("Number of elements given is too small, adjusting it for %d", NETDATA_EBPF_ALLOC_MIN_ELEMENTS);
561
max_elements = NETDATA_EBPF_ALLOC_MIN_ELEMENTS;
562
}
563
@@ -593,7 +593,7 @@ static inline void ebpf_check_before2go()
593
}
594
595
if (i) {
596
- error("eBPF cannot unload all threads on time, but it will go away");
596
+ netdata_log_error("eBPF cannot unload all threads on time, but it will go away");
597
}
598
}
599
@@ -614,10 +614,10 @@ static void ebpf_exit()
614
char filename[FILENAME_MAX + 1];
615
ebpf_pid_file(filename, FILENAME_MAX);
616
if (unlink(filename))
617
- error("Cannot remove PID file %s", filename);
617
+ netdata_log_error("Cannot remove PID file %s", filename);
618
619
#ifdef NETDATA_INTERNAL_CHECKS
620
- error("Good bye world! I was PID %d", main_thread_id);
620
+ netdata_log_error("Good bye world! I was PID %d", main_thread_id);
621
#endif
622
fprintf(stdout, "EXIT\n");
623
fflush(stdout);
@@ -670,7 +670,7 @@ static void ebpf_unload_unique_maps()
670
671
if (ebpf_modules[i].enabled != NETDATA_THREAD_EBPF_STOPPED) {
672
if (ebpf_modules[i].enabled != NETDATA_THREAD_EBPF_NOT_RUNNING)
673
- error("Cannot unload maps for thread %s, because it is not stopped.", ebpf_modules[i].thread_name);
673
+ netdata_log_error("Cannot unload maps for thread %s, because it is not stopped.", ebpf_modules[i].thread_name);
674
675
continue;
676
}
@@ -1605,7 +1605,7 @@ static void read_local_addresses()
1605
{
1606
struct ifaddrs *ifaddr, *ifa;
1607
if (getifaddrs(&ifaddr) == -1) {
1608
- error("Cannot get the local IP addresses, it is no possible to do separation between inbound and outbound connections");
1608
+ netdata_log_error("Cannot get the local IP addresses, it is no possible to do separation between inbound and outbound connections");
1609
return;
1610
}
1611
@@ -1714,7 +1714,7 @@ static inline void how_to_load(char *ptr)
1714
else if (!strcasecmp(ptr, EBPF_CFG_LOAD_MODE_DEFAULT))
1715
ebpf_set_thread_mode(MODE_ENTRY);
1716
else
1717
- error("the option %s for \"ebpf load mode\" is not a valid option.", ptr);
1717
+ netdata_log_error("the option %s for \"ebpf load mode\" is not a valid option.", ptr);
1718
}
1719
1720
/**
@@ -2051,7 +2051,7 @@ void set_global_variables()
2051
ebpf_nprocs = (int)sysconf(_SC_NPROCESSORS_ONLN);
2052
if (ebpf_nprocs < 0) {
2053
ebpf_nprocs = NETDATA_MAX_PROCESSOR;
2054
- error("Cannot identify number of process, using default value %d", ebpf_nprocs);
2054
+ netdata_log_error("Cannot identify number of process, using default value %d", ebpf_nprocs);
2055
}
2056
2057
isrh = get_redhat_release();
@@ -2080,12 +2080,12 @@ static inline void ebpf_load_thread_config()
2080
int ebpf_check_conditions()
2081
{
2082
if (!has_condition_to_run(running_on_kernel)) {
2083
- error("The current collector cannot run on this kernel.");
2083
+ netdata_log_error("The current collector cannot run on this kernel.");
2084
return -1;
2085
}
2086
2087
if (!am_i_running_as_root()) {
2088
- error(
2088
+ netdata_log_error(
2089
"ebpf.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities..",
2090
(unsigned int)getuid(), (unsigned int)geteuid());
2091
return -1;
@@ -2105,7 +2105,7 @@ int ebpf_adjust_memory_limit()
2105
{
2106
struct rlimit r = { RLIM_INFINITY, RLIM_INFINITY };
2107
if (setrlimit(RLIMIT_MEMLOCK, &r)) {
2108
- error("Setrlimit(RLIMIT_MEMLOCK)");
2108
+ netdata_log_error("Setrlimit(RLIMIT_MEMLOCK)");
2109
return -1;
2110
}
2111
@@ -2398,7 +2398,7 @@ unittest:
2398
ebpf_user_config_dir, ebpf_stock_config_dir);
2399
if (ebpf_read_apps_groups_conf(
2400
&apps_groups_default_target, &apps_groups_root_target, ebpf_stock_config_dir, "groups")) {
2401
- error("Cannot read process groups '%s/apps_groups.conf'. There are no internal defaults. Failing.",
2401
+ netdata_log_error("Cannot read process groups '%s/apps_groups.conf'. There are no internal defaults. Failing.",
2402
ebpf_stock_config_dir);
2403
ebpf_exit();
2404
}
@@ -2445,7 +2445,7 @@ static char *ebpf_get_process_name(pid_t pid)
2445
2446
procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
2447
if(unlikely(!ff)) {
2448
- error("Cannot open %s", filename);
2448
+ netdata_log_error("Cannot open %s", filename);
2449
return name;
2450
}
2451
collectors/ebpf.plugin/ebpf_apps.c
+13
-13
@@ -35,7 +35,7 @@ void ebpf_aral_init(void)
35
{
36
size_t max_elements = NETDATA_EBPF_ALLOC_MAX_PID;
37
if (max_elements < NETDATA_EBPF_ALLOC_MIN_ELEMENTS) {
38
- error("Number of elements given is too small, adjusting it for %d", NETDATA_EBPF_ALLOC_MIN_ELEMENTS);
38
+ netdata_log_error("Number of elements given is too small, adjusting it for %d", NETDATA_EBPF_ALLOC_MIN_ELEMENTS);
39
max_elements = NETDATA_EBPF_ALLOC_MIN_ELEMENTS;
40
}
41
@@ -652,7 +652,7 @@ int ebpf_read_apps_groups_conf(struct ebpf_target **agdt, struct ebpf_target **a
652
// add this target
653
struct ebpf_target *n = get_apps_groups_target(agrt, s, w, name);
654
if (!n) {
655
- error("Cannot create target '%s' (line %zu, word %zu)", s, line, word);
655
+ netdata_log_error("Cannot create target '%s' (line %zu, word %zu)", s, line, word);
656
continue;
657
}
658
@@ -755,32 +755,32 @@ static inline void debug_log_dummy(void)
755
static inline int managed_log(struct ebpf_pid_stat *p, uint32_t log, int status)
756
{
757
if (unlikely(!status)) {
758
- // error("command failed log %u, errno %d", log, errno);
758
+ // netdata_log_error("command failed log %u, errno %d", log, errno);
759
760
if (unlikely(debug_enabled || errno != ENOENT)) {
761
if (unlikely(debug_enabled || !(p->log_thrown & log))) {
762
p->log_thrown |= log;
763
switch (log) {
764
case PID_LOG_IO:
765
- error(
765
+ netdata_log_error(
766
"Cannot process %s/proc/%d/io (command '%s')", netdata_configured_host_prefix, p->pid,
767
p->comm);
768
break;
769
770
case PID_LOG_STATUS:
771
- error(
771
+ netdata_log_error(
772
"Cannot process %s/proc/%d/status (command '%s')", netdata_configured_host_prefix, p->pid,
773
p->comm);
774
break;
775
776
case PID_LOG_CMDLINE:
777
- error(
777
+ netdata_log_error(
778
"Cannot process %s/proc/%d/cmdline (command '%s')", netdata_configured_host_prefix, p->pid,
779
p->comm);
780
break;
781
782
case PID_LOG_FDS:
783
- error(
783
+ netdata_log_error(
784
"Cannot process entries in %s/proc/%d/fd (command '%s')", netdata_configured_host_prefix,
785
p->pid, p->comm);
786
break;
@@ -789,14 +789,14 @@ static inline int managed_log(struct ebpf_pid_stat *p, uint32_t log, int status)
789
break;
790
791
default:
792
- error("unhandled error for pid %d, command '%s'", p->pid, p->comm);
792
+ netdata_log_error("unhandled error for pid %d, command '%s'", p->pid, p->comm);
793
break;
794
}
795
}
796
}
797
errno = 0;
798
} else if (unlikely(p->log_thrown & log)) {
799
- // error("unsetting log %u on pid %d", log, p->pid);
799
+ // netdata_log_error("unsetting log %u on pid %d", log, p->pid);
800
p->log_thrown &= ~log;
801
}
802
@@ -1005,7 +1005,7 @@ static inline int read_proc_pid_stat(struct ebpf_pid_stat *p, void *ptr)
1005
static inline int collect_data_for_pid(pid_t pid, void *ptr)
1006
{
1007
if (unlikely(pid < 0 || pid > pid_max)) {
1008
- error("Invalid pid %d read (expected %d to %d). Ignoring process.", pid, 0, pid_max);
1008
+ netdata_log_error("Invalid pid %d read (expected %d to %d). Ignoring process.", pid, 0, pid_max);
1009
return 0;
1010
}
1011
@@ -1020,7 +1020,7 @@ static inline int collect_data_for_pid(pid_t pid, void *ptr)
1020
1021
// check its parent pid
1022
if (unlikely(p->ppid < 0 || p->ppid > pid_max)) {
1023
- error("Pid %d (command '%s') states invalid parent pid %d. Using 0.", pid, p->comm, p->ppid);
1023
+ netdata_log_error("Pid %d (command '%s') states invalid parent pid %d. Using 0.", pid, p->comm, p->ppid);
1024
p->ppid = 0;
1025
}
1026
@@ -1220,7 +1220,7 @@ static inline void del_pid_entry(pid_t pid)
1220
struct ebpf_pid_stat *p = ebpf_all_pids[pid];
1221
1222
if (unlikely(!p)) {
1223
- error("attempted to free pid %d that is not allocated.", pid);
1223
+ netdata_log_error("attempted to free pid %d that is not allocated.", pid);
1224
return;
1225
}
1226
@@ -1403,7 +1403,7 @@ static inline void aggregate_pid_on_target(struct ebpf_target *w, struct ebpf_pi
1403
}
1404
1405
if (unlikely(!w)) {
1406
- error("pid %d %s was left without a target!", p->pid, p->comm);
1406
+ netdata_log_error("pid %d %s was left without a target!", p->pid, p->comm);
1407
return;
1408
}
1409
collectors/ebpf.plugin/ebpf_cachestat.c
+2
-2
@@ -1220,7 +1220,7 @@ static int ebpf_cachestat_set_internal_value()
1220
}
1221
1222
if (!address.addr) {
1223
- error("%s cachestat.", NETDATA_EBPF_DEFAULT_FNT_NOT_FOUND);
1223
+ netdata_log_error("%s cachestat.", NETDATA_EBPF_DEFAULT_FNT_NOT_FOUND);
1224
return -1;
1225
}
1226
@@ -1261,7 +1261,7 @@ static int ebpf_cachestat_load_bpf(ebpf_module_t *em)
1261
#endif
1262
1263
if (ret)
1264
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1264
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1265
1266
return ret;
1267
}
collectors/ebpf.plugin/ebpf_cgroup.c
+3
-3
@@ -28,7 +28,7 @@ static inline void *ebpf_cgroup_map_shm_locally(int fd, size_t length)
28
29
value = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
30
if (!value) {
31
- error("Cannot map shared memory used between eBPF and cgroup, integration between processes won't happen");
31
+ netdata_log_error("Cannot map shared memory used between eBPF and cgroup, integration between processes won't happen");
32
close(shm_fd_ebpf_cgroup);
33
shm_fd_ebpf_cgroup = -1;
34
shm_unlink(NETDATA_SHARED_MEMORY_EBPF_CGROUP_NAME);
@@ -71,7 +71,7 @@ void ebpf_map_cgroup_shared_memory()
71
shm_fd_ebpf_cgroup = shm_open(NETDATA_SHARED_MEMORY_EBPF_CGROUP_NAME, O_RDWR, 0660);
72
if (shm_fd_ebpf_cgroup < 0) {
73
if (limit_try == NETDATA_EBPF_CGROUP_MAX_TRIES)
74
- error("Shared memory was not initialized, integration between processes won't happen.");
74
+ netdata_log_error("Shared memory was not initialized, integration between processes won't happen.");
75
76
return;
77
}
@@ -103,7 +103,7 @@ void ebpf_map_cgroup_shared_memory()
103
shm_sem_ebpf_cgroup = sem_open(NETDATA_NAMED_SEMAPHORE_EBPF_CGROUP_NAME, O_CREAT, 0660, 1);
104
105
if (shm_sem_ebpf_cgroup == SEM_FAILED) {
106
- error("Cannot create semaphore, integration between eBPF and cgroup won't happen");
106
+ netdata_log_error("Cannot create semaphore, integration between eBPF and cgroup won't happen");
107
limit_try = NETDATA_EBPF_CGROUP_MAX_TRIES + 1;
108
munmap(ebpf_mapped_memory, length);
109
shm_ebpf_cgroup.header = NULL;
collectors/ebpf.plugin/ebpf_dcstat.c
+1
-1
@@ -1112,7 +1112,7 @@ static int ebpf_dcstat_load_bpf(ebpf_module_t *em)
1112
#endif
1113
1114
if (ret)
1115
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1115
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1116
1117
return ret;
1118
}
collectors/ebpf.plugin/ebpf_disk.c
+5
-5
@@ -341,7 +341,7 @@ static void update_disk_table(char *name, int major, int minor, time_t current_t
341
netdata_ebpf_disks_t *check;
342
check = (netdata_ebpf_disks_t *) avl_insert_lock(&disk_tree, (avl_t *)w);
343
if (check != w)
344
- error("Internal error, cannot insert the AVL tree.");
344
+ netdata_log_error("Internal error, cannot insert the AVL tree.");
345
346
#ifdef NETDATA_INTERNAL_CHECKS
347
netdata_log_info("The Latency is monitoring the hard disk %s (Major = %d, Minor = %d, Device = %u)", name, major, minor,w->dev);
@@ -424,12 +424,12 @@ static void ebpf_disk_disable_tracepoints()
424
char *default_message = { "Cannot disable the tracepoint" };
425
if (!was_block_issue_enabled) {
426
if (ebpf_disable_tracing_values(tracepoint_block_type, tracepoint_block_issue))
427
- error("%s %s/%s.", default_message, tracepoint_block_type, tracepoint_block_issue);
427
+ netdata_log_error("%s %s/%s.", default_message, tracepoint_block_type, tracepoint_block_issue);
428
}
429
430
if (!was_block_rq_complete_enabled) {
431
if (ebpf_disable_tracing_values(tracepoint_block_type, tracepoint_block_rq_complete))
432
- error("%s %s/%s.", default_message, tracepoint_block_type, tracepoint_block_rq_complete);
432
+ netdata_log_error("%s %s/%s.", default_message, tracepoint_block_type, tracepoint_block_rq_complete);
433
}
434
}
435
@@ -814,7 +814,7 @@ static int ebpf_disk_load_bpf(ebpf_module_t *em)
814
#endif
815
816
if (ret)
817
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
817
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
818
819
return ret;
820
}
@@ -845,7 +845,7 @@ void *ebpf_disk_thread(void *ptr)
845
}
846
847
if (pthread_mutex_init(&plot_mutex, NULL)) {
848
- error("Cannot initialize local mutex");
848
+ netdata_log_error("Cannot initialize local mutex");
849
goto enddisk;
850
}
851
collectors/ebpf.plugin/ebpf_fd.c
+2
-2
@@ -326,7 +326,7 @@ static inline int ebpf_fd_load_and_attach(struct fd_bpf *obj, ebpf_module_t *em)
326
netdata_ebpf_program_loaded_t test = mt[NETDATA_FD_SYSCALL_OPEN].mode;
327
328
if (ebpf_fd_set_target_values()) {
329
- error("%s file descriptor.", NETDATA_EBPF_DEFAULT_FNT_NOT_FOUND);
329
+ netdata_log_error("%s file descriptor.", NETDATA_EBPF_DEFAULT_FNT_NOT_FOUND);
330
return -1;
331
}
332
@@ -1125,7 +1125,7 @@ static int ebpf_fd_load_bpf(ebpf_module_t *em)
1125
#endif
1126
1127
if (ret)
1128
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1128
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1129
1130
return ret;
1131
}
collectors/ebpf.plugin/ebpf_hardirq.c
+1
-1
@@ -406,7 +406,7 @@ static int hardirq_read_latency_map(int mapfd)
406
407
avl_t *check = avl_insert_lock(&hardirq_pub, (avl_t *)v);
408
if (check != (avl_t *)v) {
409
- error("Internal error, cannot insert the AVL tree.");
409
+ netdata_log_error("Internal error, cannot insert the AVL tree.");
410
}
411
}
412
collectors/ebpf.plugin/ebpf_mdflush.c
+3
-3
@@ -241,7 +241,7 @@ static void mdflush_read_count_map(int maps_per_core)
241
if (v_is_new) {
242
avl_t *check = avl_insert_lock(&mdflush_pub, (avl_t *)v);
243
if (check != (avl_t *)v) {
244
- error("Internal error, cannot insert the AVL tree.");
244
+ netdata_log_error("Internal error, cannot insert the AVL tree.");
245
}
246
}
247
}
@@ -384,7 +384,7 @@ void *ebpf_mdflush_thread(void *ptr)
384
385
char *md_flush_request = ebpf_find_symbol("md_flush_request");
386
if (!md_flush_request) {
387
- error("Cannot monitor MD devices, because md is not loaded.");
387
+ netdata_log_error("Cannot monitor MD devices, because md is not loaded.");
388
goto endmdflush;
389
}
390
@@ -393,7 +393,7 @@ void *ebpf_mdflush_thread(void *ptr)
393
ebpf_adjust_thread_load(em, default_btf);
394
#endif
395
if (ebpf_mdflush_load_bpf(em)) {
396
- error("Cannot load eBPF software.");
396
+ netdata_log_error("Cannot load eBPF software.");
397
goto endmdflush;
398
}
399
collectors/ebpf.plugin/ebpf_mount.c
+1
-1
@@ -408,7 +408,7 @@ static int ebpf_mount_load_bpf(ebpf_module_t *em)
408
#endif
409
410
if (ret)
411
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
411
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
412
413
return ret;
414
}
collectors/ebpf.plugin/ebpf_oomkill.c
+1
-1
@@ -259,7 +259,7 @@ static uint32_t oomkill_read_data(int32_t *keys)
259
if (unlikely(test < 0)) {
260
// since there's only 1 thread doing these deletions, it should be
261
// impossible to get this condition.
262
- error("key unexpectedly not available for deletion.");
262
+ netdata_log_error("key unexpectedly not available for deletion.");
263
}
264
}
265
collectors/ebpf.plugin/ebpf_process.c
+3
-3
@@ -683,17 +683,17 @@ static void ebpf_process_disable_tracepoints()
683
char *default_message = { "Cannot disable the tracepoint" };
684
if (!was_sched_process_exit_enabled) {
685
if (ebpf_disable_tracing_values(tracepoint_sched_type, tracepoint_sched_process_exit))
686
- error("%s %s/%s.", default_message, tracepoint_sched_type, tracepoint_sched_process_exit);
686
+ netdata_log_error("%s %s/%s.", default_message, tracepoint_sched_type, tracepoint_sched_process_exit);
687
}
688
689
if (!was_sched_process_exec_enabled) {
690
if (ebpf_disable_tracing_values(tracepoint_sched_type, tracepoint_sched_process_exec))
691
- error("%s %s/%s.", default_message, tracepoint_sched_type, tracepoint_sched_process_exec);
691
+ netdata_log_error("%s %s/%s.", default_message, tracepoint_sched_type, tracepoint_sched_process_exec);
692
}
693
694
if (!was_sched_process_fork_enabled) {
695
if (ebpf_disable_tracing_values(tracepoint_sched_type, tracepoint_sched_process_fork))
696
- error("%s %s/%s.", default_message, tracepoint_sched_type, tracepoint_sched_process_fork);
696
+ netdata_log_error("%s %s/%s.", default_message, tracepoint_sched_type, tracepoint_sched_process_fork);
697
}
698
}
699
collectors/ebpf.plugin/ebpf_shm.c
+1
-1
@@ -1037,7 +1037,7 @@ static int ebpf_shm_load_bpf(ebpf_module_t *em)
1037
1038
1039
if (ret)
1040
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1040
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
1041
1042
return ret;
1043
}
collectors/ebpf.plugin/ebpf_socket.c
+6
-6
@@ -1927,7 +1927,7 @@ static void store_socket_inside_avl(netdata_vector_plot_t *out, netdata_socket_t
1927
netdata_socket_plot_t *check ;
1928
check = (netdata_socket_plot_t *) avl_insert_lock(&out->tree, (avl_t *)w);
1929
if (check != w)
1930
- error("Internal error, cannot insert the AVL tree.");
1930
+ netdata_log_error("Internal error, cannot insert the AVL tree.");
1931
1932
#ifdef NETDATA_INTERNAL_CHECKS
1933
char iptext[INET6_ADDRSTRLEN];
@@ -3165,7 +3165,7 @@ static inline in_addr_t ipv4_network(in_addr_t addr, int prefix)
3165
static inline int ip2nl(uint8_t *dst, char *ip, int domain, char *source)
3166
{
3167
if (inet_pton(domain, ip, dst) <= 0) {
3168
- error("The address specified (%s) is invalid ", source);
3168
+ netdata_log_error("The address specified (%s) is invalid ", source);
3169
return -1;
3170
}
3171
@@ -3639,7 +3639,7 @@ static void read_max_dimension(struct config *cfg)
3639
EBPF_MAXIMUM_DIMENSIONS,
3640
NETDATA_NV_CAP_VALUE);
3641
if (maxdim < 0) {
3642
- error("'maximum dimensions = %d' must be a positive number, Netdata will change for default value %ld.",
3642
+ netdata_log_error("'maximum dimensions = %d' must be a positive number, Netdata will change for default value %ld.",
3643
maxdim, NETDATA_NV_CAP_VALUE);
3644
maxdim = NETDATA_NV_CAP_VALUE;
3645
}
@@ -3827,7 +3827,7 @@ static void link_dimension_name(char *port, uint32_t hash, char *value)
3827
{
3828
int test = str2i(port);
3829
if (test < NETDATA_MINIMUM_PORT_VALUE || test > NETDATA_MAXIMUM_PORT_VALUE){
3830
- error("The dimension given (%s = %s) has an invalid value and it will be ignored.", port, value);
3830
+ netdata_log_error("The dimension given (%s = %s) has an invalid value and it will be ignored.", port, value);
3831
return;
3832
}
3833
@@ -3950,7 +3950,7 @@ static int ebpf_socket_load_bpf(ebpf_module_t *em)
3950
#endif
3951
3952
if (ret) {
3953
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
3953
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
3954
}
3955
3956
return ret;
@@ -3975,7 +3975,7 @@ void *ebpf_socket_thread(void *ptr)
3975
parse_table_size_options(&socket_config);
3976
3977
if (pthread_mutex_init(&nv_mutex, NULL)) {
3978
- error("Cannot initialize local mutex");
3978
+ netdata_log_error("Cannot initialize local mutex");
3979
goto endsocket;
3980
}
3981
collectors/ebpf.plugin/ebpf_swap.c
+1
-1
@@ -818,7 +818,7 @@ static int ebpf_swap_load_bpf(ebpf_module_t *em)
818
#endif
819
820
if (ret)
821
- error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
821
+ netdata_log_error("%s %s", EBPF_DEFAULT_ERROR_MSG, em->thread_name);
822
823
return ret;
824
}
collectors/plugins.d/plugins_d.c
+6
-6
@@ -94,7 +94,7 @@ static void pluginsd_worker_thread_handle_success(struct plugind *cd) {
94
}
95
96
if (cd->serial_failures > SERIAL_FAILURES_THRESHOLD) {
97
- error("PLUGINSD: 'host:'%s', '%s' (pid %d) does not generate useful output, "
97
+ netdata_log_error("PLUGINSD: 'host:'%s', '%s' (pid %d) does not generate useful output, "
98
"although it reports success (exits with 0)."
99
"We have tried to collect something %zu times - unsuccessfully. Disabling it.",
100
rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, cd->serial_failures);
@@ -112,14 +112,14 @@ static void pluginsd_worker_thread_handle_error(struct plugind *cd, int worker_r
112
}
113
114
if (!cd->successful_collections) {
115
- error("PLUGINSD: 'host:%s', '%s' (pid %d) exited with error code %d and haven't collected any data. Disabling it.",
115
+ netdata_log_error("PLUGINSD: 'host:%s', '%s' (pid %d) exited with error code %d and haven't collected any data. Disabling it.",
116
rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, worker_ret_code);
117
plugin_set_disabled(cd);
118
return;
119
}
120
121
if (cd->serial_failures <= SERIAL_FAILURES_THRESHOLD) {
122
- error("PLUGINSD: 'host:%s', '%s' (pid %d) exited with error code %d, but has given useful output in the past (%zu times). %s",
122
+ netdata_log_error("PLUGINSD: 'host:%s', '%s' (pid %d) exited with error code %d, but has given useful output in the past (%zu times). %s",
123
rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, worker_ret_code, cd->successful_collections,
124
plugin_is_enabled(cd) ? "Waiting a bit before starting it again." : "Will not start it again - it is disabled.");
125
sleep((unsigned int)(cd->update_every * 10));
@@ -127,7 +127,7 @@ static void pluginsd_worker_thread_handle_error(struct plugind *cd, int worker_r
127
}
128
129
if (cd->serial_failures > SERIAL_FAILURES_THRESHOLD) {
130
- error("PLUGINSD: 'host:%s', '%s' (pid %d) exited with error code %d, but has given useful output in the past (%zu times)."
130
+ netdata_log_error("PLUGINSD: 'host:%s', '%s' (pid %d) exited with error code %d, but has given useful output in the past (%zu times)."
131
"We tried to restart it %zu times, but it failed to generate data. Disabling it.",
132
rrdhost_hostname(cd->host), cd->fullfilename, cd->unsafe.pid, worker_ret_code,
133
cd->successful_collections, cd->serial_failures);
@@ -153,7 +153,7 @@ static void *pluginsd_worker_thread(void *arg) {
153
FILE *fp_child_output = netdata_popen(cd->cmd, &cd->unsafe.pid, &fp_child_input);
154
155
if (unlikely(!fp_child_input || !fp_child_output)) {
156
- error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").", rrdhost_hostname(cd->host), cd->cmd);
156
+ netdata_log_error("PLUGINSD: 'host:%s', cannot popen(\"%s\", \"r\").", rrdhost_hostname(cd->host), cd->cmd);
157
break;
158
}
159
@@ -235,7 +235,7 @@ void *pluginsd_main(void *ptr)
235
if (unlikely(!dir)) {
236
if (directory_errors[idx] != errno) {
237
directory_errors[idx] = errno;
238
- error("cannot open plugins directory '%s'", directory_name);
238
+ netdata_log_error("cannot open plugins directory '%s'", directory_name);
239
}
240
continue;
241
}
collectors/plugins.d/pluginsd_parser.c
+77
-72
@@ -22,7 +22,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
22
bytes = netdata_ssl_write(ssl, (void *) txt, strlen(txt));
23
24
else
25
- error("PLUGINSD: cannot send command (SSL)");
25
+ netdata_log_error("PLUGINSD: cannot send command (SSL)");
26
27
spinlock_unlock(&parser->writer.spinlock);
28
return bytes;
@@ -33,7 +33,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
33
34
bytes = fprintf(parser->fp_output, "%s", txt);
35
if(bytes <= 0) {
36
- error("PLUGINSD: cannot send command (FILE)");
36
+ netdata_log_error("PLUGINSD: cannot send command (FILE)");
37
bytes = -2;
38
}
39
else
@@ -51,7 +51,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
51
do {
52
sent = write(parser->fd, &txt[bytes], total - bytes);
53
if(sent <= 0) {
54
- error("PLUGINSD: cannot send command (fd)");
54
+ netdata_log_error("PLUGINSD: cannot send command (fd)");
55
spinlock_unlock(&parser->writer.spinlock);
56
return -3;
57
}
@@ -64,7 +64,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
64
}
65
66
spinlock_unlock(&parser->writer.spinlock);
67
- error("PLUGINSD: cannot send command (no output socket/pipe/file given to plugins.d parser)");
67
+ netdata_log_error("PLUGINSD: cannot send command (no output socket/pipe/file given to plugins.d parser)");
68
return -4;
69
}
70
@@ -72,7 +72,7 @@ static inline RRDHOST *pluginsd_require_host_from_parent(PARSER *parser, const c
72
RRDHOST *host = parser->user.host;
73
74
if(unlikely(!host))
75
- error("PLUGINSD: command %s requires a host, but is not set.", cmd);
75
+ netdata_log_error("PLUGINSD: command %s requires a host, but is not set.", cmd);
76
77
return host;
78
}
@@ -81,7 +81,7 @@ static inline RRDSET *pluginsd_require_chart_from_parent(PARSER *parser, const c
81
RRDSET *st = parser->user.st;
82
83
if(unlikely(!st))
84
- error("PLUGINSD: command %s requires a chart defined via command %s, but is not set.", cmd, parent_cmd);
84
+ netdata_log_error("PLUGINSD: command %s requires a chart defined via command %s, but is not set.", cmd, parent_cmd);
85
86
return st;
87
}
@@ -124,8 +124,10 @@ void pluginsd_rrdset_cleanup(RRDSET *st) {
124
static inline void pluginsd_unlock_previous_chart(PARSER *parser, const char *keyword, bool stale) {
125
if(unlikely(pluginsd_unlock_rrdset_data_collection(parser))) {
126
if(stale)
127
- error("PLUGINSD: 'host:%s/chart:%s/' stale data collection lock found during %s; it has been unlocked",
128
- rrdhost_hostname(parser->user.st->rrdhost), rrdset_id(parser->user.st), keyword);
127
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s/' stale data collection lock found during %s; it has been unlocked",
128
+ rrdhost_hostname(parser->user.st->rrdhost),
129
+ rrdset_id(parser->user.st),
130
+ keyword);
131
}
132
133
if(unlikely(parser->user.v2.ml_locked)) {
@@ -133,8 +135,10 @@ static inline void pluginsd_unlock_previous_chart(PARSER *parser, const char *ke
135
parser->user.v2.ml_locked = false;
136
137
if(stale)
136
- error("PLUGINSD: 'host:%s/chart:%s/' stale ML lock found during %s, it has been unlocked",
137
- rrdhost_hostname(parser->user.st->rrdhost), rrdset_id(parser->user.st), keyword);
138
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s/' stale ML lock found during %s, it has been unlocked",
139
+ rrdhost_hostname(parser->user.st->rrdhost),
140
+ rrdset_id(parser->user.st),
141
+ keyword);
142
}
143
}
144
@@ -159,8 +163,8 @@ static inline void pluginsd_set_chart_from_parent(PARSER *parser, RRDSET *st, co
163
164
static inline RRDDIM *pluginsd_acquire_dimension(RRDHOST *host, RRDSET *st, const char *dimension, const char *cmd) {
165
if (unlikely(!dimension || !*dimension)) {
162
- error("PLUGINSD: 'host:%s/chart:%s' got a %s, without a dimension.",
163
- rrdhost_hostname(host), rrdset_id(st), cmd);
166
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' got a %s, without a dimension.",
167
+ rrdhost_hostname(host), rrdset_id(st), cmd);
168
return NULL;
169
}
170
@@ -181,8 +185,8 @@ static inline RRDDIM *pluginsd_acquire_dimension(RRDHOST *host, RRDSET *st, cons
185
186
rda = rrddim_find_and_acquire(st, dimension);
187
if (unlikely(!rda)) {
184
- error("PLUGINSD: 'host:%s/chart:%s/dim:%s' got a %s but dimension does not exist.",
185
- rrdhost_hostname(host), rrdset_id(st), dimension, cmd);
188
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s/dim:%s' got a %s but dimension does not exist.",
189
+ rrdhost_hostname(host), rrdset_id(st), dimension, cmd);
190
191
return NULL;
192
}
@@ -195,15 +199,15 @@ static inline RRDDIM *pluginsd_acquire_dimension(RRDHOST *host, RRDSET *st, cons
199
200
static inline RRDSET *pluginsd_find_chart(RRDHOST *host, const char *chart, const char *cmd) {
201
if (unlikely(!chart || !*chart)) {
198
- error("PLUGINSD: 'host:%s' got a %s without a chart id.",
199
- rrdhost_hostname(host), cmd);
202
+ netdata_log_error("PLUGINSD: 'host:%s' got a %s without a chart id.",
203
+ rrdhost_hostname(host), cmd);
204
return NULL;
205
}
206
207
RRDSET *st = rrdset_find(host, chart);
208
if (unlikely(!st))
205
- error("PLUGINSD: 'host:%s/chart:%s' got a %s but chart does not exist.",
206
- rrdhost_hostname(host), chart, cmd);
209
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' got a %s but chart does not exist.",
210
+ rrdhost_hostname(host), chart, cmd);
211
212
return st;
213
}
@@ -717,7 +721,7 @@ static void inflight_functions_insert_callback(const DICTIONARY_ITEM *item, void
721
pf->sent_ut = now_realtime_usec();
722
723
if(ret < 0) {
720
- error("FUNCTION: failed to send function to plugin, error %d", ret);
724
+ netdata_log_error("FUNCTION: failed to send function to plugin, error %d", ret);
725
rrd_call_function_error(pf->destination_wb, "Failed to communicate with collector", HTTP_RESP_BACKEND_FETCH_FAILED);
726
}
727
else {
@@ -731,7 +735,7 @@ static void inflight_functions_insert_callback(const DICTIONARY_ITEM *item, void
735
static bool inflight_functions_conflict_callback(const DICTIONARY_ITEM *item __maybe_unused, void *func __maybe_unused, void *new_func, void *parser_ptr __maybe_unused) {
736
struct inflight_function *pf = new_func;
737
734
- error("PLUGINSD_PARSER: duplicate UUID on pending function '%s' detected. Ignoring the second one.", string2str(pf->function));
738
+ netdata_log_error("PLUGINSD_PARSER: duplicate UUID on pending function '%s' detected. Ignoring the second one.", string2str(pf->function));
739
pf->code = rrd_call_function_error(pf->destination_wb, "This request is already in progress", HTTP_RESP_BAD_REQUEST);
740
pf->callback(pf->destination_wb, pf->code, pf->callback_data);
741
string_freez(pf->function);
@@ -841,14 +845,14 @@ static inline PARSER_RC pluginsd_function(char **words, size_t num_words, PARSER
845
if(!st) global = true;
846
847
if (unlikely(!timeout_s || !name || !help || (!global && !st))) {
844
- error("PLUGINSD: 'host:%s/chart:%s' got a FUNCTION, without providing the required data (global = '%s', name = '%s', timeout = '%s', help = '%s'). Ignoring it.",
845
- rrdhost_hostname(host),
846
- st?rrdset_id(st):"(unset)",
847
- global?"yes":"no",
848
- name?name:"(unset)",
849
- timeout_s?timeout_s:"(unset)",
850
- help?help:"(unset)"
851
- );
848
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' got a FUNCTION, without providing the required data (global = '%s', name = '%s', timeout = '%s', help = '%s'). Ignoring it.",
849
+ rrdhost_hostname(host),
850
+ st?rrdset_id(st):"(unset)",
851
+ global?"yes":"no",
852
+ name?name:"(unset)",
853
+ timeout_s?timeout_s:"(unset)",
854
+ help?help:"(unset)"
855
+ );
856
return PARSER_RC_ERROR;
857
}
858
@@ -878,7 +882,7 @@ static inline PARSER_RC pluginsd_function_result_begin(char **words, size_t num_
882
char *expires = get_word(words, num_words, 4);
883
884
if (unlikely(!key || !*key || !status || !*status || !format || !*format || !expires || !*expires)) {
881
- error("got a " PLUGINSD_KEYWORD_FUNCTION_RESULT_BEGIN " without providing the required data (key = '%s', status = '%s', format = '%s', expires = '%s')."
885
+ netdata_log_error("got a " PLUGINSD_KEYWORD_FUNCTION_RESULT_BEGIN " without providing the required data (key = '%s', status = '%s', format = '%s', expires = '%s')."
886
, key ? key : "(unset)"
887
, status ? status : "(unset)"
888
, format ? format : "(unset)"
@@ -898,7 +902,7 @@ static inline PARSER_RC pluginsd_function_result_begin(char **words, size_t num_
902
pf = (struct inflight_function *)dictionary_get(parser->inflight.functions, key);
903
904
if(!pf) {
901
- error("got a " PLUGINSD_KEYWORD_FUNCTION_RESULT_BEGIN " for transaction '%s', but the transaction is not found.", key?key:"(unset)");
905
+ netdata_log_error("got a " PLUGINSD_KEYWORD_FUNCTION_RESULT_BEGIN " for transaction '%s', but the transaction is not found.", key?key:"(unset)");
906
}
907
else {
908
if(format && *format)
@@ -955,11 +959,11 @@ static inline PARSER_RC pluginsd_variable(char **words, size_t num_words, PARSER
959
value = NULL;
960
961
if (unlikely(!value)) {
958
- error("PLUGINSD: 'host:%s/chart:%s' cannot set %s VARIABLE '%s' to an empty value",
959
- rrdhost_hostname(host),
960
- st ? rrdset_id(st):"UNSET",
961
- (global) ? "HOST" : "CHART",
962
- name);
962
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' cannot set %s VARIABLE '%s' to an empty value",
963
+ rrdhost_hostname(host),
964
+ st ? rrdset_id(st):"UNSET",
965
+ (global) ? "HOST" : "CHART",
966
+ name);
967
return PARSER_RC_OK;
968
}
969
@@ -970,18 +974,18 @@ static inline PARSER_RC pluginsd_variable(char **words, size_t num_words, PARSER
974
v = (NETDATA_DOUBLE) str2ndd_encoded(value, &endptr);
975
if (unlikely(endptr && *endptr)) {
976
if (endptr == value)
973
- error("PLUGINSD: 'host:%s/chart:%s' the value '%s' of VARIABLE '%s' cannot be parsed as a number",
974
- rrdhost_hostname(host),
975
- st ? rrdset_id(st):"UNSET",
976
- value,
977
- name);
977
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' the value '%s' of VARIABLE '%s' cannot be parsed as a number",
978
+ rrdhost_hostname(host),
979
+ st ? rrdset_id(st):"UNSET",
980
+ value,
981
+ name);
982
else
979
- error("PLUGINSD: 'host:%s/chart:%s' the value '%s' of VARIABLE '%s' has leftovers: '%s'",
980
- rrdhost_hostname(host),
981
- st ? rrdset_id(st):"UNSET",
982
- value,
983
- name,
984
- endptr);
983
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' the value '%s' of VARIABLE '%s' has leftovers: '%s'",
984
+ rrdhost_hostname(host),
985
+ st ? rrdset_id(st):"UNSET",
986
+ value,
987
+ name,
988
+ endptr);
989
}
990
991
if (global) {
@@ -991,9 +995,9 @@ static inline PARSER_RC pluginsd_variable(char **words, size_t num_words, PARSER
995
rrdvar_custom_host_variable_release(host, rva);
996
}
997
else
994
- error("PLUGINSD: 'host:%s' cannot find/create HOST VARIABLE '%s'",
995
- rrdhost_hostname(host),
996
- name);
998
+ netdata_log_error("PLUGINSD: 'host:%s' cannot find/create HOST VARIABLE '%s'",
999
+ rrdhost_hostname(host),
1000
+ name);
1001
} else {
1002
const RRDSETVAR_ACQUIRED *rsa = rrdsetvar_custom_chart_variable_add_and_acquire(st, name);
1003
if (rsa) {
@@ -1001,8 +1005,8 @@ static inline PARSER_RC pluginsd_variable(char **words, size_t num_words, PARSER
1005
rrdsetvar_custom_chart_variable_release(st, rsa);
1006
}
1007
else
1004
- error("PLUGINSD: 'host:%s/chart:%s' cannot find/create CHART VARIABLE '%s'",
1005
- rrdhost_hostname(host), rrdset_id(st), name);
1008
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s' cannot find/create CHART VARIABLE '%s'",
1009
+ rrdhost_hostname(host), rrdset_id(st), name);
1010
}
1011
1012
return PARSER_RC_OK;
@@ -1093,7 +1097,7 @@ static inline PARSER_RC pluginsd_clabel(char **words, size_t num_words, PARSER *
1097
const char *label_source = get_word(words, num_words, 3);
1098
1099
if (!name || !value || !*label_source) {
1096
- error("Ignoring malformed or empty CHART LABEL command.");
1100
+ netdata_log_error("Ignoring malformed or empty CHART LABEL command.");
1101
return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
1102
}
1103
@@ -1118,7 +1122,7 @@ static inline PARSER_RC pluginsd_clabel_commit(char **words __maybe_unused, size
1122
debug(D_PLUGINSD, "requested to commit chart labels");
1123
1124
if(!parser->user.chart_rrdlabels_linked_temporarily) {
1121
- error("PLUGINSD: 'host:%s' got CLABEL_COMMIT, without a CHART or BEGIN. Ignoring it.", rrdhost_hostname(host));
1125
+ netdata_log_error("PLUGINSD: 'host:%s' got CLABEL_COMMIT, without a CHART or BEGIN. Ignoring it.", rrdhost_hostname(host));
1126
return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
1127
}
1128
@@ -1209,11 +1213,12 @@ static inline PARSER_RC pluginsd_replay_begin(char **words, size_t num_words, PA
1213
return PARSER_RC_OK;
1214
}
1215
1212
- error("PLUGINSD REPLAY ERROR: 'host:%s/chart:%s' got a " PLUGINSD_KEYWORD_REPLAY_BEGIN
1213
- " from %ld to %ld, but timestamps are invalid "
1214
- "(now is %ld [%s], tolerance %ld). Ignoring " PLUGINSD_KEYWORD_REPLAY_SET,
1215
- rrdhost_hostname(st->rrdhost), rrdset_id(st), start_time, end_time,
1216
- wall_clock_time, wall_clock_comes_from_child ? "child wall clock" : "parent wall clock", tolerance);
1216
+ netdata_log_error("PLUGINSD REPLAY ERROR: 'host:%s/chart:%s' got a " PLUGINSD_KEYWORD_REPLAY_BEGIN
1217
+ " from %ld to %ld, but timestamps are invalid "
1218
+ "(now is %ld [%s], tolerance %ld). Ignoring " PLUGINSD_KEYWORD_REPLAY_SET,
1219
+ rrdhost_hostname(st->rrdhost), rrdset_id(st), start_time, end_time,
1220
+ wall_clock_time, wall_clock_comes_from_child ? "child wall clock" : "parent wall clock",
1221
+ tolerance);
1222
}
1223
1224
// the child sends an RBEGIN without any parameters initially
@@ -1279,7 +1284,7 @@ static inline PARSER_RC pluginsd_replay_set(char **words, size_t num_words, PARS
1284
if(!rd) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
1285
1286
if (unlikely(!parser->user.replay.start_time || !parser->user.replay.end_time)) {
1282
- error("PLUGINSD: 'host:%s/chart:%s/dim:%s' got a %s with invalid timestamps %ld to %ld from a %s. Disabling it.",
1287
+ netdata_log_error("PLUGINSD: 'host:%s/chart:%s/dim:%s' got a %s with invalid timestamps %ld to %ld from a %s. Disabling it.",
1288
rrdhost_hostname(host),
1289
rrdset_id(st),
1290
dimension,
@@ -1391,7 +1396,7 @@ static inline PARSER_RC pluginsd_replay_rrdset_collection_state(char **words, si
1396
1397
static inline PARSER_RC pluginsd_replay_end(char **words, size_t num_words, PARSER *parser) {
1398
if (num_words < 7) { // accepts 7, but the 7th is optional
1394
- error("REPLAY: malformed " PLUGINSD_KEYWORD_REPLAY_END " command");
1399
+ netdata_log_error("REPLAY: malformed " PLUGINSD_KEYWORD_REPLAY_END " command");
1400
return PARSER_RC_ERROR;
1401
}
1402
@@ -1808,7 +1813,7 @@ static inline PARSER_RC streaming_claimed_id(char **words, size_t num_words, PAR
1813
const char *claim_id_str = get_word(words, num_words, 2);
1814
1815
if (!host_uuid_str || !claim_id_str) {
1811
- error("Command CLAIMED_ID came malformed, uuid = '%s', claim_id = '%s'",
1816
+ netdata_log_error("Command CLAIMED_ID came malformed, uuid = '%s', claim_id = '%s'",
1817
host_uuid_str ? host_uuid_str : "[unset]",
1818
claim_id_str ? claim_id_str : "[unset]");
1819
return PARSER_RC_ERROR;
@@ -1820,16 +1825,16 @@ static inline PARSER_RC streaming_claimed_id(char **words, size_t num_words, PAR
1825
// We don't need the parsed UUID
1826
// just do it to check the format
1827
if(uuid_parse(host_uuid_str, uuid)) {
1823
- error("1st parameter (host GUID) to CLAIMED_ID command is not valid GUID. Received: \"%s\".", host_uuid_str);
1828
+ netdata_log_error("1st parameter (host GUID) to CLAIMED_ID command is not valid GUID. Received: \"%s\".", host_uuid_str);
1829
return PARSER_RC_ERROR;
1830
}
1831
if(uuid_parse(claim_id_str, uuid) && strcmp(claim_id_str, "NULL") != 0) {
1827
- error("2nd parameter (Claim ID) to CLAIMED_ID command is not valid GUID. Received: \"%s\".", claim_id_str);
1832
+ netdata_log_error("2nd parameter (Claim ID) to CLAIMED_ID command is not valid GUID. Received: \"%s\".", claim_id_str);
1833
return PARSER_RC_ERROR;
1834
}
1835
1836
if(strcmp(host_uuid_str, host->machine_guid) != 0) {
1832
- error("Claim ID is for host \"%s\" but it came over connection for \"%s\"", host_uuid_str, host->machine_guid);
1837
+ netdata_log_error("Claim ID is for host \"%s\" but it came over connection for \"%s\"", host_uuid_str, host->machine_guid);
1838
return PARSER_RC_OK; //the message is OK problem must be somewhere else
1839
}
1840
@@ -1882,27 +1887,27 @@ static inline bool buffered_reader_read_timeout(struct buffered_reader *reader,
1887
return buffered_reader_read(reader, fd);
1888
1889
else if(fds[0].revents & POLLERR) {
1885
- error("PARSER: read failed: POLLERR.");
1890
+ netdata_log_error("PARSER: read failed: POLLERR.");
1891
return false;
1892
}
1893
else if(fds[0].revents & POLLHUP) {
1889
- error("PARSER: read failed: POLLHUP.");
1894
+ netdata_log_error("PARSER: read failed: POLLHUP.");
1895
return false;
1896
}
1897
else if(fds[0].revents & POLLNVAL) {
1893
- error("PARSER: read failed: POLLNVAL.");
1898
+ netdata_log_error("PARSER: read failed: POLLNVAL.");
1899
return false;
1900
}
1901
1897
- error("PARSER: poll() returned positive number, but POLLIN|POLLERR|POLLHUP|POLLNVAL are not set.");
1902
+ netdata_log_error("PARSER: poll() returned positive number, but POLLIN|POLLERR|POLLHUP|POLLNVAL are not set.");
1903
return false;
1904
}
1905
else if (ret == 0) {
1901
- error("PARSER: timeout while waiting for data.");
1906
+ netdata_log_error("PARSER: timeout while waiting for data.");
1907
return false;
1908
}
1909
1905
- error("PARSER: poll() failed with code %d.", ret);
1910
+ netdata_log_error("PARSER: poll() failed with code %d.", ret);
1911
return false;
1912
}
1913
@@ -1927,13 +1932,13 @@ inline size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp_plugi
1932
}
1933
1934
if (unlikely(fileno(fp_plugin_input) == -1)) {
1930
- error("input file descriptor given is not a valid stream");
1935
+ netdata_log_error("input file descriptor given is not a valid stream");
1936
cd->serial_failures++;
1937
return 0;
1938
}
1939
1940
if (unlikely(fileno(fp_plugin_output) == -1)) {
1936
- error("output file descriptor given is not a valid stream");
1941
+ netdata_log_error("output file descriptor given is not a valid stream");
1942
cd->serial_failures++;
1943
return 0;
1944
}
collectors/plugins.d/pluginsd_parser.h
+2
-2
@@ -209,8 +209,8 @@ static inline int parser_action(PARSER *parser, char *input) {
209
buffer_fast_strcat(wb, "\"", 1);
210
}
211
212
- error("PLUGINSD: parser_action('%s') failed on line %zu: { %s } (quotes added to show parsing)",
213
- command, parser->line, buffer_tostring(wb));
212
+ netdata_log_error("PLUGINSD: parser_action('%s') failed on line %zu: { %s } (quotes added to show parsing)",
213
+ command, parser->line, buffer_tostring(wb));
214
215
buffer_free(wb);
216
}
collectors/statsd.plugin/statsd.c
+24
-24
@@ -571,7 +571,7 @@ static inline void statsd_process_set(STATSD_METRIC *m, const char *value) {
571
if(!is_metric_useful_for_collection(m)) return;
572
573
if(unlikely(!value || !*value)) {
574
- error("STATSD: metric of type set, with empty value is ignored.");
574
+ netdata_log_error("STATSD: metric of type set, with empty value is ignored.");
575
return;
576
}
577
@@ -606,7 +606,7 @@ static inline void statsd_process_dictionary(STATSD_METRIC *m, const char *value
606
if(!is_metric_useful_for_collection(m)) return;
607
608
if(unlikely(!value || !*value)) {
609
- error("STATSD: metric of type set, with empty value is ignored.");
609
+ netdata_log_error("STATSD: metric of type set, with empty value is ignored.");
610
return;
611
}
612
@@ -720,7 +720,7 @@ static void statsd_process_metric(const char *name, const char *value, const cha
720
}
721
else {
722
statsd.unknown_types++;
723
- error("STATSD: metric '%s' with value '%s' is sent with unknown metric type '%s'", name, value?value:"", type);
723
+ netdata_log_error("STATSD: metric '%s' with value '%s' is sent with unknown metric type '%s'", name, value?value:"", type);
724
}
725
726
if(m && tags && *tags) {
@@ -892,14 +892,14 @@ static void statsd_del_callback(POLLINFO *pi) {
892
if(t->type == STATSD_SOCKET_DATA_TYPE_TCP) {
893
if(t->len != 0) {
894
statsd.socket_errors++;
895
- error("STATSD: client is probably sending unterminated metrics. Closed socket left with '%s'. Trying to process it.", t->buffer);
895
+ netdata_log_error("STATSD: client is probably sending unterminated metrics. Closed socket left with '%s'. Trying to process it.", t->buffer);
896
statsd_process(t->buffer, t->len, 0);
897
}
898
statsd.tcp_socket_disconnects++;
899
statsd.tcp_socket_connected--;
900
}
901
else
902
- error("STATSD: internal error: received socket data type is %d, but expected %d", (int)t->type, (int)STATSD_SOCKET_DATA_TYPE_TCP);
902
+ netdata_log_error("STATSD: internal error: received socket data type is %d, but expected %d", (int)t->type, (int)STATSD_SOCKET_DATA_TYPE_TCP);
903
904
freez(t);
905
}
@@ -920,7 +920,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
920
case SOCK_STREAM: {
921
struct statsd_tcp *d = (struct statsd_tcp *)pi->data;
922
if(unlikely(!d)) {
923
- error("STATSD: internal error: expected TCP data pointer is NULL");
923
+ netdata_log_error("STATSD: internal error: expected TCP data pointer is NULL");
924
statsd.socket_errors++;
925
retval = -1;
926
goto cleanup;
@@ -928,7 +928,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
928
929
#ifdef NETDATA_INTERNAL_CHECKS
930
if(unlikely(d->type != STATSD_SOCKET_DATA_TYPE_TCP)) {
931
- error("STATSD: internal error: socket data type should be %d, but it is %d", (int)STATSD_SOCKET_DATA_TYPE_TCP, (int)d->type);
931
+ netdata_log_error("STATSD: internal error: socket data type should be %d, but it is %d", (int)STATSD_SOCKET_DATA_TYPE_TCP, (int)d->type);
932
statsd.socket_errors++;
933
retval = -1;
934
goto cleanup;
@@ -942,7 +942,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
942
if (rc < 0) {
943
// read failed
944
if (errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR) {
945
- error("STATSD: recv() on TCP socket %d failed.", fd);
945
+ netdata_log_error("STATSD: recv() on TCP socket %d failed.", fd);
946
statsd.socket_errors++;
947
ret = -1;
948
}
@@ -976,7 +976,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
976
case SOCK_DGRAM: {
977
struct statsd_udp *d = (struct statsd_udp *)pi->data;
978
if(unlikely(!d)) {
979
- error("STATSD: internal error: expected UDP data pointer is NULL");
979
+ netdata_log_error("STATSD: internal error: expected UDP data pointer is NULL");
980
statsd.socket_errors++;
981
retval = -1;
982
goto cleanup;
@@ -984,7 +984,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
984
985
#ifdef NETDATA_INTERNAL_CHECKS
986
if(unlikely(d->type != STATSD_SOCKET_DATA_TYPE_UDP)) {
987
- error("STATSD: internal error: socket data should be %d, but it is %d", (int)d->type, (int)STATSD_SOCKET_DATA_TYPE_UDP);
987
+ netdata_log_error("STATSD: internal error: socket data should be %d, but it is %d", (int)d->type, (int)STATSD_SOCKET_DATA_TYPE_UDP);
988
statsd.socket_errors++;
989
retval = -1;
990
goto cleanup;
@@ -998,7 +998,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
998
if (rc < 0) {
999
// read failed
1000
if (errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR) {
1001
- error("STATSD: recvmmsg() on UDP socket %d failed.", fd);
1001
+ netdata_log_error("STATSD: recvmmsg() on UDP socket %d failed.", fd);
1002
statsd.socket_errors++;
1003
retval = -1;
1004
goto cleanup;
@@ -1024,7 +1024,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
1024
if (rc < 0) {
1025
// read failed
1026
if (errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR) {
1027
- error("STATSD: recv() on UDP socket %d failed.", fd);
1027
+ netdata_log_error("STATSD: recv() on UDP socket %d failed.", fd);
1028
statsd.socket_errors++;
1029
retval = -1;
1030
goto cleanup;
@@ -1043,7 +1043,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
1043
}
1044
1045
default: {
1046
- error("STATSD: internal error: unknown socktype %d on socket %d", pi->socktype, fd);
1046
+ netdata_log_error("STATSD: internal error: unknown socktype %d on socket %d", pi->socktype, fd);
1047
statsd.socket_errors++;
1048
retval = -1;
1049
goto cleanup;
@@ -1061,7 +1061,7 @@ static int statsd_snd_callback(POLLINFO *pi, short int *events) {
1061
(void)events;
1062
1063
worker_is_busy(WORKER_JOB_TYPE_SND_DATA);
1064
- error("STATSD: snd_callback() called, but we never requested to send data to statsd clients.");
1064
+ netdata_log_error("STATSD: snd_callback() called, but we never requested to send data to statsd clients.");
1065
worker_is_idle();
1066
1067
return -1;
@@ -1169,7 +1169,7 @@ static STATSD_APP_CHART_DIM_VALUE_TYPE string2valuetype(const char *type, size_t
1169
else if(!strcmp(type, "stddev")) return STATSD_APP_CHART_DIM_VALUE_TYPE_STDDEV;
1170
else if(!strcmp(type, "percentile")) return STATSD_APP_CHART_DIM_VALUE_TYPE_PERCENTILE;
1171
1172
- error("STATSD: invalid type '%s' at line %zu of file '%s'. Using 'last'.", type, line, filename);
1172
+ netdata_log_error("STATSD: invalid type '%s' at line %zu of file '%s'. Using 'last'.", type, line, filename);
1173
return STATSD_APP_CHART_DIM_VALUE_TYPE_LAST;
1174
}
1175
@@ -1244,7 +1244,7 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
1244
1245
FILE *fp = fopen(filename, "r");
1246
if(!fp) {
1247
- error("STATSD: cannot open file '%s'.", filename);
1247
+ netdata_log_error("STATSD: cannot open file '%s'.", filename);
1248
freez(buffer);
1249
return -1;
1250
}
@@ -1281,7 +1281,7 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
1281
freez(tmp);
1282
}
1283
else
1284
- error("STATSD: ignoring line %zu of file '%s', include filename is empty", line, filename);
1284
+ netdata_log_error("STATSD: ignoring line %zu of file '%s', include filename is empty", line, filename);
1285
1286
continue;
1287
}
@@ -1348,20 +1348,20 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
1348
}
1349
}
1350
else
1351
- error("STATSD: ignoring line %zu ('%s') of file '%s', [app] is not defined.", line, s, filename);
1351
+ netdata_log_error("STATSD: ignoring line %zu ('%s') of file '%s', [app] is not defined.", line, s, filename);
1352
1353
continue;
1354
}
1355
1356
if(!app) {
1357
- error("STATSD: ignoring line %zu ('%s') of file '%s', it is outside all sections.", line, s, filename);
1357
+ netdata_log_error("STATSD: ignoring line %zu ('%s') of file '%s', it is outside all sections.", line, s, filename);
1358
continue;
1359
}
1360
1361
char *name = s;
1362
char *value = strchr(s, '=');
1363
if(!value) {
1364
- error("STATSD: ignoring line %zu ('%s') of file '%s', there is no = in it.", line, s, filename);
1364
+ netdata_log_error("STATSD: ignoring line %zu ('%s') of file '%s', there is no = in it.", line, s, filename);
1365
continue;
1366
}
1367
*value = '\0';
@@ -1371,7 +1371,7 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
1371
value = trim(value);
1372
1373
if(!name || *name == '#') {
1374
- error("STATSD: ignoring line %zu of file '%s', name is empty.", line, filename);
1374
+ netdata_log_error("STATSD: ignoring line %zu of file '%s', name is empty.", line, filename);
1375
continue;
1376
}
1377
if(!value) {
@@ -1418,7 +1418,7 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
1418
app->rrd_history_entries = 5;
1419
}
1420
else {
1421
- error("STATSD: ignoring line %zu ('%s') of file '%s'. Unknown keyword for the [app] section.", line, name, filename);
1421
+ netdata_log_error("STATSD: ignoring line %zu ('%s') of file '%s'. Unknown keyword for the [app] section.", line, name, filename);
1422
continue;
1423
}
1424
}
@@ -1512,7 +1512,7 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
1512
dim->metric_pattern = simple_pattern_create(dim->metric, NULL, SIMPLE_PATTERN_EXACT, true);
1513
}
1514
else {
1515
- error("STATSD: ignoring line %zu ('%s') of file '%s'. Unknown keyword for the [%s] section.", line, name, filename, chart->id);
1515
+ netdata_log_error("STATSD: ignoring line %zu ('%s') of file '%s'. Unknown keyword for the [%s] section.", line, name, filename, chart->id);
1516
continue;
1517
}
1518
}
@@ -2049,7 +2049,7 @@ static inline void link_metric_to_app_dimension(STATSD_APP *app, STATSD_METRIC *
2049
}
2050
else {
2051
if (dim->value_type != STATSD_APP_CHART_DIM_VALUE_TYPE_LAST)
2052
- error("STATSD: unsupported value type for dimension '%s' of chart '%s' of app '%s' on metric '%s'", dim->name, chart->id, app->name, m->name);
2052
+ netdata_log_error("STATSD: unsupported value type for dimension '%s' of chart '%s' of app '%s' on metric '%s'", dim->name, chart->id, app->name, m->name);
2053
2054
dim->value_ptr = &m->last;
2055
dim->algorithm = statsd_algorithm_for_metric(m);
collectors/timex.plugin/plugin_timex.c
+1
-1
@@ -79,7 +79,7 @@ void *timex_main(void *ptr)
79
prev_sync_state = sync_state;
80
81
if (non_seq_failure) {
82
- error("Cannot get clock synchronization state");
82
+ netdata_log_error("Cannot get clock synchronization state");
83
continue;
84
}
85
collectors/xenstat.plugin/xenstat_plugin.c
+10
-10
@@ -178,7 +178,7 @@ static struct domain_metrics *domain_metrics_free(struct domain_metrics *d) {
178
}
179
180
if(unlikely(!cur)) {
181
- error("XENSTAT: failed to free domain metrics.");
181
+ netdata_log_error("XENSTAT: failed to free domain metrics.");
182
return NULL;
183
}
184
@@ -242,7 +242,7 @@ static int vcpu_metrics_collect(struct domain_metrics *d, xenstat_domain *domain
242
vcpu = xenstat_domain_vcpu(domain, i);
243
244
if(unlikely(!vcpu)) {
245
- error("XENSTAT: cannot get VCPU statistics.");
245
+ netdata_log_error("XENSTAT: cannot get VCPU statistics.");
246
return 1;
247
}
248
@@ -288,7 +288,7 @@ static int vbd_metrics_collect(struct domain_metrics *d, xenstat_domain *domain)
288
vbd = xenstat_domain_vbd(domain, i);
289
290
if(unlikely(!vbd)) {
291
- error("XENSTAT: cannot get VBD statistics.");
291
+ netdata_log_error("XENSTAT: cannot get VBD statistics.");
292
return 1;
293
}
294
@@ -336,7 +336,7 @@ static int network_metrics_collect(struct domain_metrics *d, xenstat_domain *dom
336
network = xenstat_domain_network(domain, i);
337
338
if(unlikely(!network)) {
339
- error("XENSTAT: cannot get network statistics.");
339
+ netdata_log_error("XENSTAT: cannot get network statistics.");
340
return 1;
341
}
342
@@ -368,7 +368,7 @@ static int xenstat_collect(xenstat_handle *xhandle, libxl_ctx *ctx, libxl_dominf
368
369
xenstat_node *node = xenstat_get_node(xhandle, XENSTAT_ALL);
370
if (unlikely(!node)) {
371
- error("XENSTAT: failed to retrieve statistics from libxenstat.");
371
+ netdata_log_error("XENSTAT: failed to retrieve statistics from libxenstat.");
372
return 1;
373
}
374
@@ -388,7 +388,7 @@ static int xenstat_collect(xenstat_handle *xhandle, libxl_ctx *ctx, libxl_dominf
388
// get domain UUID
389
unsigned int id = xenstat_domain_id(domain);
390
if(unlikely(libxl_domain_info(ctx, info, id))) {
391
- error("XENSTAT: cannot get domain info.");
391
+ netdata_log_error("XENSTAT: cannot get domain info.");
392
}
393
else {
394
snprintfz(uuid, LIBXL_UUID_FMTLEN, LIBXL_UUID_FMT "\n", LIBXL_UUID_BYTES(info->uuid));
@@ -989,7 +989,7 @@ int main(int argc, char **argv) {
989
exit(1);
990
}
991
992
- error("xenstat.plugin: ignoring parameter '%s'", argv[i]);
992
+ netdata_log_error("xenstat.plugin: ignoring parameter '%s'", argv[i]);
993
}
994
995
errno = 0;
@@ -997,7 +997,7 @@ int main(int argc, char **argv) {
997
if(freq >= netdata_update_every)
998
netdata_update_every = freq;
999
else if(freq)
1000
- error("update frequency %d seconds is too small for XENSTAT. Using %d.", freq, netdata_update_every);
1000
+ netdata_log_error("update frequency %d seconds is too small for XENSTAT. Using %d.", freq, netdata_update_every);
1001
1002
// ------------------------------------------------------------------------
1003
// initialize xen API handles
@@ -1008,13 +1008,13 @@ int main(int argc, char **argv) {
1008
if(unlikely(debug)) fprintf(stderr, "xenstat.plugin: calling xenstat_init()\n");
1009
xhandle = xenstat_init();
1010
if (xhandle == NULL) {
1011
- error("XENSTAT: failed to initialize xenstat library.");
1011
+ netdata_log_error("XENSTAT: failed to initialize xenstat library.");
1012
return 1;
1013
}
1014
1015
if(unlikely(debug)) fprintf(stderr, "xenstat.plugin: calling libxl_ctx_alloc()\n");
1016
if (libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, NULL)) {
1017
- error("XENSTAT: failed to initialize xl context.");
1017
+ netdata_log_error("XENSTAT: failed to initialize xl context.");
1018
xenstat_uninit(xhandle);
1019
return 1;
1020
}
daemon/analytics.c
+3
-3
@@ -1035,11 +1035,11 @@ void send_statistics(const char *action, const char *action_result, const char *
1035
char *s = fgets(buffer, 4, fp_child_output);
1036
int exit_code = netdata_pclose(fp_child_input, fp_child_output, command_pid);
1037
if (exit_code)
1038
- error("Execution of anonymous statistics script returned %d.", exit_code);
1038
+ netdata_log_error("Execution of anonymous statistics script returned %d.", exit_code);
1039
if (s && strncmp(buffer, "200", 3))
1040
- error("Execution of anonymous statistics script returned http code %s.", buffer);
1040
+ netdata_log_error("Execution of anonymous statistics script returned http code %s.", buffer);
1041
} else {
1042
- error("Failed to run anonymous statistics script %s.", as_script);
1042
+ netdata_log_error("Failed to run anonymous statistics script %s.", as_script);
1043
}
1044
freez(command_to_run);
1045
}
daemon/commands.c
+17
-15
@@ -251,8 +251,10 @@ static cmd_status_t cmd_read_config_execute(char *args, char **message)
251
char *value = appconfig_get(tmp_config, temp + offset + 1, temp + offset2 + 1, NULL);
252
if (value == NULL)
253
{
254
- error("Cannot execute read-config conf_file=%s section=%s / key=%s because no value set", conf_file,
255
- temp + offset + 1, temp + offset2 + 1);
254
+ netdata_log_error("Cannot execute read-config conf_file=%s section=%s / key=%s because no value set",
255
+ conf_file,
256
+ temp + offset + 1,
257
+ temp + offset2 + 1);
258
freez(temp);
259
return CMD_STATUS_FAILURE;
260
}
@@ -449,7 +451,7 @@ static void send_command_reply(struct command_context *cmd_ctx, cmd_status_t sta
451
write_buf.len = reply_string_size;
452
ret = uv_write(&cmd_ctx->write_req, (uv_stream_t *)client, &write_buf, 1, pipe_write_cb);
453
if (ret) {
452
- error("uv_write(): %s", uv_strerror(ret));
454
+ netdata_log_error("uv_write(): %s", uv_strerror(ret));
455
}
456
}
457
@@ -535,7 +537,7 @@ static void pipe_read_cb(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf
537
netdata_log_info("EOF found in command pipe.");
538
parse_commands(cmd_ctx);
539
} else if (nread < 0) {
538
- error("%s: %s", __func__, uv_strerror(nread));
540
+ netdata_log_error("%s: %s", __func__, uv_strerror(nread));
541
}
542
543
if (nread < 0) { /* stop stream due to EOF or error */
@@ -579,13 +581,13 @@ static void connection_cb(uv_stream_t *server, int status)
581
client = (uv_pipe_t *)cmd_ctx;
582
ret = uv_pipe_init(server->loop, client, 1);
583
if (ret) {
582
- error("uv_pipe_init(): %s", uv_strerror(ret));
584
+ netdata_log_error("uv_pipe_init(): %s", uv_strerror(ret));
585
freez(cmd_ctx);
586
return;
587
}
588
ret = uv_accept(server, (uv_stream_t *)client);
589
if (ret) {
588
- error("uv_accept(): %s", uv_strerror(ret));
590
+ netdata_log_error("uv_accept(): %s", uv_strerror(ret));
591
uv_close((uv_handle_t *)client, pipe_close_cb);
592
return;
593
}
@@ -598,7 +600,7 @@ static void connection_cb(uv_stream_t *server, int status)
600
601
ret = uv_read_start((uv_stream_t*)client, alloc_cb, pipe_read_cb);
602
if (ret) {
601
- error("uv_read_start(): %s", uv_strerror(ret));
603
+ netdata_log_error("uv_read_start(): %s", uv_strerror(ret));
604
uv_close((uv_handle_t *)client, pipe_close_cb);
605
--clients;
606
netdata_log_info("Command Clients = %u\n", clients);
@@ -620,7 +622,7 @@ static void command_thread(void *arg)
622
loop = mallocz(sizeof(uv_loop_t));
623
ret = uv_loop_init(loop);
624
if (ret) {
623
- error("uv_loop_init(): %s", uv_strerror(ret));
625
+ netdata_log_error("uv_loop_init(): %s", uv_strerror(ret));
626
command_thread_error = ret;
627
goto error_after_loop_init;
628
}
@@ -628,7 +630,7 @@ static void command_thread(void *arg)
630
631
ret = uv_async_init(loop, &async, async_cb);
632
if (ret) {
631
- error("uv_async_init(): %s", uv_strerror(ret));
633
+ netdata_log_error("uv_async_init(): %s", uv_strerror(ret));
634
command_thread_error = ret;
635
goto error_after_async_init;
636
}
@@ -636,7 +638,7 @@ static void command_thread(void *arg)
638
639
ret = uv_pipe_init(loop, &server_pipe, 0);
640
if (ret) {
639
- error("uv_pipe_init(): %s", uv_strerror(ret));
641
+ netdata_log_error("uv_pipe_init(): %s", uv_strerror(ret));
642
command_thread_error = ret;
643
goto error_after_pipe_init;
644
}
@@ -647,7 +649,7 @@ static void command_thread(void *arg)
649
uv_fs_req_cleanup(&req);
650
ret = uv_pipe_bind(&server_pipe, pipename);
651
if (ret) {
650
- error("uv_pipe_bind(): %s", uv_strerror(ret));
652
+ netdata_log_error("uv_pipe_bind(): %s", uv_strerror(ret));
653
command_thread_error = ret;
654
goto error_after_pipe_bind;
655
}
@@ -659,7 +661,7 @@ static void command_thread(void *arg)
661
ret = uv_listen((uv_stream_t *)&server_pipe, 1, connection_cb);
662
}
663
if (ret) {
662
- error("uv_listen(): %s", uv_strerror(ret));
664
+ netdata_log_error("uv_listen(): %s", uv_strerror(ret));
665
command_thread_error = ret;
666
goto error_after_uv_listen;
667
}
@@ -723,7 +725,7 @@ void commands_init(void)
725
completion_init(&completion);
726
error = uv_thread_create(&thread, command_thread, NULL);
727
if (error) {
726
- error("uv_thread_create(): %s", uv_strerror(error));
728
+ netdata_log_error("uv_thread_create(): %s", uv_strerror(error));
729
goto after_error;
730
}
731
/* wait for worker thread to initialize */
@@ -734,7 +736,7 @@ void commands_init(void)
736
if (command_thread_error) {
737
error = uv_thread_join(&thread);
738
if (error) {
737
- error("uv_thread_create(): %s", uv_strerror(error));
739
+ netdata_log_error("uv_thread_create(): %s", uv_strerror(error));
740
}
741
goto after_error;
742
}
@@ -743,7 +745,7 @@ void commands_init(void)
745
return;
746
747
after_error:
746
- error("Failed to initialize command server. The netdata cli tool will be unable to send commands.");
748
+ netdata_log_error("Failed to initialize command server. The netdata cli tool will be unable to send commands.");
749
}
750
751
void commands_exit(void)
daemon/daemon.c
+39
-34
@@ -20,7 +20,7 @@ void get_netdata_execution_path(void)
20
exepath_size = sizeof(exepath) - 1;
21
ret = uv_exepath(exepath, &exepath_size);
22
if (0 != ret) {
23
- error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
23
+ netdata_log_error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
24
uv_strerror(ret));
25
fatal("Cannot start netdata without getting execution path.");
26
}
@@ -33,13 +33,13 @@ static void chown_open_file(int fd, uid_t uid, gid_t gid) {
33
struct stat buf;
34
35
if(fstat(fd, &buf) == -1) {
36
- error("Cannot fstat() fd %d", fd);
36
+ netdata_log_error("Cannot fstat() fd %d", fd);
37
return;
38
}
39
40
if((buf.st_uid != uid || buf.st_gid != gid) && S_ISREG(buf.st_mode)) {
41
if(fchown(fd, uid, gid) == -1)
42
- error("Cannot fchown() fd %d.", fd);
42
+ netdata_log_error("Cannot fchown() fd %d.", fd);
43
}
44
}
45
@@ -60,7 +60,7 @@ static void fix_directory_file_permissions(const char *dirname, uid_t uid, gid_t
60
(void) snprintfz(filename, FILENAME_MAX, "%s/%s", dirname, de->d_name);
61
if (de->d_type == DT_REG || recursive) {
62
if (chown(filename, uid, gid) == -1)
63
- error("Cannot chown %s '%s' to %u:%u", de->d_type == DT_DIR ? "directory" : "file", filename, (unsigned int)uid, (unsigned int)gid);
63
+ netdata_log_error("Cannot chown %s '%s' to %u:%u", de->d_type == DT_DIR ? "directory" : "file", filename, (unsigned int)uid, (unsigned int)gid);
64
}
65
66
if (de->d_type == DT_DIR && recursive)
@@ -73,7 +73,7 @@ static void fix_directory_file_permissions(const char *dirname, uid_t uid, gid_t
73
void change_dir_ownership(const char *dir, uid_t uid, gid_t gid, bool recursive)
74
{
75
if (chown(dir, uid, gid) == -1)
76
- error("Cannot chown directory '%s' to %u:%u", dir, (unsigned int)uid, (unsigned int)gid);
76
+ netdata_log_error("Cannot chown directory '%s' to %u:%u", dir, (unsigned int)uid, (unsigned int)gid);
77
78
fix_directory_file_permissions(dir, uid, gid, recursive);
79
}
@@ -89,7 +89,7 @@ void clean_directory(char *dirname)
89
while((de = readdir(dir)))
90
if(de->d_type == DT_REG)
91
if (unlinkat(dir_fd, de->d_name, 0))
92
- error("Cannot delete %s/%s", dirname, de->d_name);
92
+ netdata_log_error("Cannot delete %s/%s", dirname, de->d_name);
93
94
closedir(dir);
95
}
@@ -113,7 +113,7 @@ int become_user(const char *username, int pid_fd) {
113
114
struct passwd *pw = getpwnam(username);
115
if(!pw) {
116
- error("User %s is not present.", username);
116
+ netdata_log_error("User %s is not present.", username);
117
return -1;
118
}
119
@@ -127,7 +127,7 @@ int become_user(const char *username, int pid_fd) {
127
128
if(pidfile[0]) {
129
if(chown(pidfile, uid, gid) == -1)
130
- error("Cannot chown '%s' to %u:%u", pidfile, (unsigned int)uid, (unsigned int)gid);
130
+ netdata_log_error("Cannot chown '%s' to %u:%u", pidfile, (unsigned int)uid, (unsigned int)gid);
131
}
132
133
int ngroups = (int)sysconf(_SC_NGROUPS_MAX);
@@ -140,7 +140,7 @@ int become_user(const char *username, int pid_fd) {
140
if(getgrouplist(username, gid, supplementary_groups, &ngroups) == -1) {
141
#endif /* __APPLE__ */
142
if(am_i_root)
143
- error("Cannot get supplementary groups of user '%s'.", username);
143
+ netdata_log_error("Cannot get supplementary groups of user '%s'.", username);
144
145
ngroups = 0;
146
}
@@ -154,7 +154,7 @@ int become_user(const char *username, int pid_fd) {
154
if(supplementary_groups && ngroups > 0) {
155
if(setgroups((size_t)ngroups, supplementary_groups) == -1) {
156
if(am_i_root)
157
- error("Cannot set supplementary groups for user '%s'", username);
157
+ netdata_log_error("Cannot set supplementary groups for user '%s'", username);
158
}
159
ngroups = 0;
160
}
@@ -167,7 +167,7 @@ int become_user(const char *username, int pid_fd) {
167
#else
168
if(setresgid(gid, gid, gid) != 0) {
169
#endif /* __APPLE__ */
170
- error("Cannot switch to user's %s group (gid: %u).", username, gid);
170
+ netdata_log_error("Cannot switch to user's %s group (gid: %u).", username, gid);
171
return -1;
172
}
173
@@ -176,24 +176,24 @@ int become_user(const char *username, int pid_fd) {
176
#else
177
if(setresuid(uid, uid, uid) != 0) {
178
#endif /* __APPLE__ */
179
- error("Cannot switch to user %s (uid: %u).", username, uid);
179
+ netdata_log_error("Cannot switch to user %s (uid: %u).", username, uid);
180
return -1;
181
}
182
183
if(setgid(gid) != 0) {
184
- error("Cannot switch to user's %s group (gid: %u).", username, gid);
184
+ netdata_log_error("Cannot switch to user's %s group (gid: %u).", username, gid);
185
return -1;
186
}
187
if(setegid(gid) != 0) {
188
- error("Cannot effectively switch to user's %s group (gid: %u).", username, gid);
188
+ netdata_log_error("Cannot effectively switch to user's %s group (gid: %u).", username, gid);
189
return -1;
190
}
191
if(setuid(uid) != 0) {
192
- error("Cannot switch to user %s (uid: %u).", username, uid);
192
+ netdata_log_error("Cannot switch to user %s (uid: %u).", username, uid);
193
return -1;
194
}
195
if(seteuid(uid) != 0) {
196
- error("Cannot effectively switch to user %s (uid: %u).", username, uid);
196
+ netdata_log_error("Cannot effectively switch to user %s (uid: %u).", username, uid);
197
return -1;
198
}
199
@@ -213,7 +213,7 @@ static void oom_score_adj(void) {
213
214
// read the existing score
215
if(read_single_signed_number_file("/proc/self/oom_score_adj", &old_score)) {
216
- error("Out-Of-Memory (OOM) score setting is not supported on this system.");
216
+ netdata_log_error("Out-Of-Memory (OOM) score setting is not supported on this system.");
217
return;
218
}
219
@@ -243,12 +243,12 @@ static void oom_score_adj(void) {
243
}
244
245
if(wanted_score < OOM_SCORE_ADJ_MIN) {
246
- error("Wanted Out-Of-Memory (OOM) score %d is too small. Using %d", (int)wanted_score, (int)OOM_SCORE_ADJ_MIN);
246
+ netdata_log_error("Wanted Out-Of-Memory (OOM) score %d is too small. Using %d", (int)wanted_score, (int)OOM_SCORE_ADJ_MIN);
247
wanted_score = OOM_SCORE_ADJ_MIN;
248
}
249
250
if(wanted_score > OOM_SCORE_ADJ_MAX) {
251
- error("Wanted Out-Of-Memory (OOM) score %d is too big. Using %d", (int)wanted_score, (int)OOM_SCORE_ADJ_MAX);
251
+ netdata_log_error("Wanted Out-Of-Memory (OOM) score %d is too big. Using %d", (int)wanted_score, (int)OOM_SCORE_ADJ_MAX);
252
wanted_score = OOM_SCORE_ADJ_MAX;
253
}
254
@@ -267,24 +267,25 @@ static void oom_score_adj(void) {
267
268
if(written) {
269
if(read_single_signed_number_file("/proc/self/oom_score_adj", &final_score))
270
- error("Adjusted my Out-Of-Memory (OOM) score to %d, but cannot verify it.", (int)wanted_score);
270
+ netdata_log_error("Adjusted my Out-Of-Memory (OOM) score to %d, but cannot verify it.", (int)wanted_score);
271
else if(final_score == wanted_score)
272
netdata_log_info("Adjusted my Out-Of-Memory (OOM) score from %d to %d.", (int)old_score, (int)final_score);
273
else
274
- error("Adjusted my Out-Of-Memory (OOM) score from %d to %d, but it has been set to %d.", (int)old_score, (int)wanted_score, (int)final_score);
274
+ netdata_log_error("Adjusted my Out-Of-Memory (OOM) score from %d to %d, but it has been set to %d.", (int)old_score, (int)wanted_score, (int)final_score);
275
analytics_report_oom_score(final_score);
276
}
277
else
278
- error("Failed to adjust my Out-Of-Memory (OOM) score to %d. Running with %d. (systemd systems may change it via netdata.service)", (int)wanted_score, (int)old_score);
278
+ netdata_log_error("Failed to adjust my Out-Of-Memory (OOM) score to %d. Running with %d. (systemd systems may change it via netdata.service)", (int)wanted_score, (int)old_score);
279
}
280
else
281
- error("Failed to adjust my Out-Of-Memory (OOM) score. Cannot open /proc/self/oom_score_adj for writing.");
281
+ netdata_log_error("Failed to adjust my Out-Of-Memory (OOM) score. Cannot open /proc/self/oom_score_adj for writing.");
282
}
283
284
static void process_nice_level(void) {
285
#ifdef HAVE_NICE
286
int nice_level = (int)config_get_number(CONFIG_SECTION_GLOBAL, "process nice level", 19);
287
- if(nice(nice_level) == -1) error("Cannot set netdata CPU nice level to %d.", nice_level);
287
+ if(nice(nice_level) == -1)
288
+ netdata_log_error("Cannot set netdata CPU nice level to %d.", nice_level);
289
else debug(D_SYSTEM, "Set netdata nice level to %d.", nice_level);
290
#endif // HAVE_NICE
291
};
@@ -341,7 +342,7 @@ struct sched_def {
342
static void sched_getscheduler_report(void) {
343
int sched = sched_getscheduler(0);
344
if(sched == -1) {
344
- error("Cannot get my current process scheduling policy.");
345
+ netdata_log_error("Cannot get my current process scheduling policy.");
346
return;
347
}
348
else {
@@ -351,7 +352,7 @@ static void sched_getscheduler_report(void) {
352
if(scheduler_defaults[i].flags & SCHED_FLAG_PRIORITY_CONFIGURABLE) {
353
struct sched_param param;
354
if(sched_getparam(0, ¶m) == -1) {
354
- error("Cannot get the process scheduling priority for my policy '%s'", scheduler_defaults[i].name);
355
+ netdata_log_error("Cannot get the process scheduling priority for my policy '%s'", scheduler_defaults[i].name);
356
return;
357
}
358
else {
@@ -406,14 +407,14 @@ static void sched_setscheduler_set(void) {
407
#ifdef HAVE_SCHED_GET_PRIORITY_MIN
408
errno = 0;
409
if(priority < sched_get_priority_min(policy)) {
409
- error("scheduler %s (%d) priority %d is below the minimum %d. Using the minimum.", name, policy, priority, sched_get_priority_min(policy));
410
+ netdata_log_error("scheduler %s (%d) priority %d is below the minimum %d. Using the minimum.", name, policy, priority, sched_get_priority_min(policy));
411
priority = sched_get_priority_min(policy);
412
}
413
#endif
414
#ifdef HAVE_SCHED_GET_PRIORITY_MAX
415
errno = 0;
416
if(priority > sched_get_priority_max(policy)) {
416
- error("scheduler %s (%d) priority %d is above the maximum %d. Using the maximum.", name, policy, priority, sched_get_priority_max(policy));
417
+ netdata_log_error("scheduler %s (%d) priority %d is above the maximum %d. Using the maximum.", name, policy, priority, sched_get_priority_max(policy));
418
priority = sched_get_priority_max(policy);
419
}
420
#endif
@@ -422,7 +423,7 @@ static void sched_setscheduler_set(void) {
423
}
424
425
if(!found) {
425
- error("Unknown scheduling policy '%s' - falling back to nice", name);
426
+ netdata_log_error("Unknown scheduling policy '%s' - falling back to nice", name);
427
goto fallback;
428
}
429
@@ -433,7 +434,10 @@ static void sched_setscheduler_set(void) {
434
errno = 0;
435
i = sched_setscheduler(0, policy, ¶m);
436
if(i != 0) {
436
- error("Cannot adjust netdata scheduling policy to %s (%d), with priority %d. Falling back to nice.", name, policy, priority);
437
+ netdata_log_error("Cannot adjust netdata scheduling policy to %s (%d), with priority %d. Falling back to nice.",
438
+ name,
439
+ policy,
440
+ priority);
441
}
442
else {
443
netdata_log_info("Adjusted netdata scheduling policy to %s (%d), with priority %d.", name, policy, priority);
@@ -489,15 +493,16 @@ int become_daemon(int dont_fork, const char *user)
493
pidfd = open(pidfile, O_WRONLY | O_CREAT, 0644);
494
if(pidfd >= 0) {
495
if(ftruncate(pidfd, 0) != 0)
492
- error("Cannot truncate pidfile '%s'.", pidfile);
496
+ netdata_log_error("Cannot truncate pidfile '%s'.", pidfile);
497
498
char b[100];
499
sprintf(b, "%d\n", getpid());
500
ssize_t i = write(pidfd, b, strlen(b));
501
if(i <= 0)
498
- error("Cannot write pidfile '%s'.", pidfile);
502
+ netdata_log_error("Cannot write pidfile '%s'.", pidfile);
503
}
500
- else error("Failed to open pidfile '%s'.", pidfile);
504
+ else
505
+ netdata_log_error("Failed to open pidfile '%s'.", pidfile);
506
}
507
508
// Set new file permissions
@@ -514,7 +519,7 @@ int become_daemon(int dont_fork, const char *user)
519
520
if(user && *user) {
521
if(become_user(user, pidfd) != 0) {
517
- error("Cannot become user '%s'. Continuing as we are.", user);
522
+ netdata_log_error("Cannot become user '%s'. Continuing as we are.", user);
523
}
524
else debug(D_SYSTEM, "Successfully became user '%s'.", user);
525
}
daemon/main.c
+27
-27
@@ -479,7 +479,7 @@ void netdata_cleanup_and_exit(int ret) {
479
delta_shutdown_time("remove pid file");
480
481
if(unlink(pidfile) != 0)
482
- error("EXIT: cannot unlink pidfile '%s'.", pidfile);
482
+ netdata_log_error("EXIT: cannot unlink pidfile '%s'.", pidfile);
483
}
484
485
#ifdef ENABLE_HTTPS
@@ -518,7 +518,7 @@ int make_dns_decision(const char *section_name, const char *config_name, const c
518
if(!strcmp("no",value))
519
return 0;
520
if(strcmp("heuristic",value))
521
- error("Invalid configuration option '%s' for '%s'/'%s'. Valid options are 'yes', 'no' and 'heuristic'. Proceeding with 'heuristic'",
521
+ netdata_log_error("Invalid configuration option '%s' for '%s'/'%s'. Valid options are 'yes', 'no' and 'heuristic'. Proceeding with 'heuristic'",
522
value, section_name, config_name);
523
524
return simple_pattern_is_potential_name(p);
@@ -592,17 +592,17 @@ void web_server_config_options(void)
592
else if(!strcmp(s, "fixed"))
593
web_gzip_strategy = Z_FIXED;
594
else {
595
- error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
595
+ netdata_log_error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
596
web_gzip_strategy = Z_DEFAULT_STRATEGY;
597
}
598
599
web_gzip_level = (int)config_get_number(CONFIG_SECTION_WEB, "gzip compression level", 3);
600
if(web_gzip_level < 1) {
601
- error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).", web_gzip_level);
601
+ netdata_log_error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).", web_gzip_level);
602
web_gzip_level = 1;
603
}
604
else if(web_gzip_level > 9) {
605
- error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).", web_gzip_level);
605
+ netdata_log_error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).", web_gzip_level);
606
web_gzip_level = 9;
607
}
608
}
@@ -622,11 +622,11 @@ int killpid(pid_t pid) {
622
return ret;
623
624
case EPERM:
625
- error("Cannot kill pid %d, but I do not have enough permissions.", pid);
625
+ netdata_log_error("Cannot kill pid %d, but I do not have enough permissions.", pid);
626
break;
627
628
default:
629
- error("Cannot kill pid %d, but I received an error.", pid);
629
+ netdata_log_error("Cannot kill pid %d, but I received an error.", pid);
630
break;
631
}
632
}
@@ -637,7 +637,7 @@ int killpid(pid_t pid) {
637
static void set_nofile_limit(struct rlimit *rl) {
638
// get the num files allowed
639
if(getrlimit(RLIMIT_NOFILE, rl) != 0) {
640
- error("getrlimit(RLIMIT_NOFILE) failed");
640
+ netdata_log_error("getrlimit(RLIMIT_NOFILE) failed");
641
return;
642
}
643
@@ -647,17 +647,17 @@ static void set_nofile_limit(struct rlimit *rl) {
647
// make the soft/hard limits equal
648
rl->rlim_cur = rl->rlim_max;
649
if (setrlimit(RLIMIT_NOFILE, rl) != 0) {
650
- error("setrlimit(RLIMIT_NOFILE, { %zu, %zu }) failed", (size_t)rl->rlim_cur, (size_t)rl->rlim_max);
650
+ netdata_log_error("setrlimit(RLIMIT_NOFILE, { %zu, %zu }) failed", (size_t)rl->rlim_cur, (size_t)rl->rlim_max);
651
}
652
653
// sanity check to make sure we have enough file descriptors available to open
654
if (getrlimit(RLIMIT_NOFILE, rl) != 0) {
655
- error("getrlimit(RLIMIT_NOFILE) failed");
655
+ netdata_log_error("getrlimit(RLIMIT_NOFILE) failed");
656
return;
657
}
658
659
if (rl->rlim_cur < 1024)
660
- error("Number of open file descriptors allowed for this process is too low (RLIMIT_NOFILE=%zu)", (size_t)rl->rlim_cur);
660
+ netdata_log_error("Number of open file descriptors allowed for this process is too low (RLIMIT_NOFILE=%zu)", (size_t)rl->rlim_cur);
661
}
662
663
void cancel_main_threads() {
@@ -694,7 +694,7 @@ void cancel_main_threads() {
694
if(found) {
695
for (i = 0; static_threads[i].name != NULL ; i++) {
696
if (static_threads[i].enabled != NETDATA_MAIN_THREAD_EXITED)
697
- error("Main thread %s takes too long to exit. Giving up...", static_threads[i].name);
697
+ netdata_log_error("Main thread %s takes too long to exit. Giving up...", static_threads[i].name);
698
}
699
}
700
else
@@ -1056,7 +1056,7 @@ static void get_netdata_configured_variables() {
1056
1057
char buf[HOSTNAME_MAX + 1];
1058
if(gethostname(buf, HOSTNAME_MAX) == -1){
1059
- error("Cannot get machine hostname.");
1059
+ netdata_log_error("Cannot get machine hostname.");
1060
}
1061
1062
netdata_configured_hostname = config_get(CONFIG_SECTION_GLOBAL, "hostname", buf);
@@ -1067,7 +1067,7 @@ static void get_netdata_configured_variables() {
1067
1068
default_rrd_update_every = (int) config_get_number(CONFIG_SECTION_DB, "update every", UPDATE_EVERY);
1069
if(default_rrd_update_every < 1 || default_rrd_update_every > 600) {
1070
- error("Invalid data collection frequency (update every) %d given. Defaulting to %d.", default_rrd_update_every, UPDATE_EVERY);
1070
+ netdata_log_error("Invalid data collection frequency (update every) %d given. Defaulting to %d.", default_rrd_update_every, UPDATE_EVERY);
1071
default_rrd_update_every = UPDATE_EVERY;
1072
config_set_number(CONFIG_SECTION_DB, "update every", default_rrd_update_every);
1073
}
@@ -1079,7 +1079,7 @@ static void get_netdata_configured_variables() {
1079
const char *mode = config_get(CONFIG_SECTION_DB, "mode", rrd_memory_mode_name(default_rrd_memory_mode));
1080
default_rrd_memory_mode = rrd_memory_mode_id(mode);
1081
if(strcmp(mode, rrd_memory_mode_name(default_rrd_memory_mode)) != 0) {
1082
- error("Invalid memory mode '%s' given. Using '%s'", mode, rrd_memory_mode_name(default_rrd_memory_mode));
1082
+ netdata_log_error("Invalid memory mode '%s' given. Using '%s'", mode, rrd_memory_mode_name(default_rrd_memory_mode));
1083
config_set(CONFIG_SECTION_DB, "mode", rrd_memory_mode_name(default_rrd_memory_mode));
1084
}
1085
}
@@ -1130,7 +1130,7 @@ static void get_netdata_configured_variables() {
1130
default_rrdeng_extent_cache_mb = 0;
1131
1132
if(default_rrdeng_page_cache_mb < RRDENG_MIN_PAGE_CACHE_SIZE_MB) {
1133
- error("Invalid page cache size %d given. Defaulting to %d.", default_rrdeng_page_cache_mb, RRDENG_MIN_PAGE_CACHE_SIZE_MB);
1133
+ netdata_log_error("Invalid page cache size %d given. Defaulting to %d.", default_rrdeng_page_cache_mb, RRDENG_MIN_PAGE_CACHE_SIZE_MB);
1134
default_rrdeng_page_cache_mb = RRDENG_MIN_PAGE_CACHE_SIZE_MB;
1135
config_set_number(CONFIG_SECTION_DB, "dbengine page cache size MB", default_rrdeng_page_cache_mb);
1136
}
@@ -1140,14 +1140,14 @@ static void get_netdata_configured_variables() {
1140
1141
default_rrdeng_disk_quota_mb = (int) config_get_number(CONFIG_SECTION_DB, "dbengine disk space MB", default_rrdeng_disk_quota_mb);
1142
if(default_rrdeng_disk_quota_mb < RRDENG_MIN_DISK_SPACE_MB) {
1143
- error("Invalid dbengine disk space %d given. Defaulting to %d.", default_rrdeng_disk_quota_mb, RRDENG_MIN_DISK_SPACE_MB);
1143
+ netdata_log_error("Invalid dbengine disk space %d given. Defaulting to %d.", default_rrdeng_disk_quota_mb, RRDENG_MIN_DISK_SPACE_MB);
1144
default_rrdeng_disk_quota_mb = RRDENG_MIN_DISK_SPACE_MB;
1145
config_set_number(CONFIG_SECTION_DB, "dbengine disk space MB", default_rrdeng_disk_quota_mb);
1146
}
1147
1148
default_multidb_disk_quota_mb = (int) config_get_number(CONFIG_SECTION_DB, "dbengine multihost disk space MB", compute_multidb_diskspace());
1149
if(default_multidb_disk_quota_mb < RRDENG_MIN_DISK_SPACE_MB) {
1150
- error("Invalid multidb disk space %d given. Defaulting to %d.", default_multidb_disk_quota_mb, default_rrdeng_disk_quota_mb);
1150
+ netdata_log_error("Invalid multidb disk space %d given. Defaulting to %d.", default_multidb_disk_quota_mb, default_rrdeng_disk_quota_mb);
1151
default_multidb_disk_quota_mb = default_rrdeng_disk_quota_mb;
1152
config_set_number(CONFIG_SECTION_DB, "dbengine multihost disk space MB", default_multidb_disk_quota_mb);
1153
}
@@ -1229,7 +1229,7 @@ static bool load_netdata_conf(char *filename, char overwrite_used, char **user)
1229
if(filename && *filename) {
1230
ret = config_load(filename, overwrite_used, NULL);
1231
if(!ret)
1232
- error("CONFIG: cannot load config file '%s'.", filename);
1232
+ netdata_log_error("CONFIG: cannot load config file '%s'.", filename);
1233
}
1234
else {
1235
filename = strdupz_path_subpath(netdata_configured_user_config_dir, "netdata.conf");
@@ -1263,7 +1263,7 @@ int get_system_info(struct rrdhost_system_info *system_info, bool log) {
1263
script = mallocz(sizeof(char) * (strlen(netdata_configured_primary_plugins_dir) + strlen("system-info.sh") + 2));
1264
sprintf(script, "%s/%s", netdata_configured_primary_plugins_dir, "system-info.sh");
1265
if (unlikely(access(script, R_OK) != 0)) {
1266
- error("System info script %s not found.",script);
1266
+ netdata_log_error("System info script %s not found.",script);
1267
freez(script);
1268
return 1;
1269
}
@@ -1289,7 +1289,7 @@ int get_system_info(struct rrdhost_system_info *system_info, bool log) {
1289
coverity_remove_taint(value);
1290
1291
if(unlikely(rrdhost_set_system_info_variable(system_info, line, value))) {
1292
- error("Unexpected environment variable %s=%s", line, value);
1292
+ netdata_log_error("Unexpected environment variable %s=%s", line, value);
1293
}
1294
else {
1295
if(log)
@@ -1341,7 +1341,7 @@ int main(int argc, char **argv) {
1341
usec_t started_ut = now_monotonic_usec();
1342
usec_t last_ut = started_ut;
1343
const char *prev_msg = NULL;
1344
- // Initialize stderror avoiding coredump when netdata_log_info() or error() is called
1344
+ // Initialize stderror avoiding coredump when netdata_log_info() or netdata_log_error() is called
1345
stderror = stderr;
1346
1347
int i;
@@ -1386,7 +1386,7 @@ int main(int argc, char **argv) {
1386
switch(opt) {
1387
case 'c':
1388
if(!load_netdata_conf(optarg, 1, &user)) {
1389
- error("Cannot load configuration file %s.", optarg);
1389
+ netdata_log_error("Cannot load configuration file %s.", optarg);
1390
return 1;
1391
}
1392
else {
@@ -1881,7 +1881,7 @@ int main(int argc, char **argv) {
1881
if(debug_flags != 0) {
1882
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
1883
if(setrlimit(RLIMIT_CORE, &rl) != 0)
1884
- error("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
1884
+ netdata_log_error("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
1885
1886
#ifdef HAVE_SYS_PRCTL_H
1887
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
@@ -1985,7 +1985,7 @@ int main(int argc, char **argv) {
1985
if(debug_flags != 0) {
1986
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
1987
if(setrlimit(RLIMIT_CORE, &rl) != 0)
1988
- error("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
1988
+ netdata_log_error("Cannot request unlimited core dumps for debugging... Proceeding anyway...");
1989
#ifdef HAVE_SYS_PRCTL_H
1990
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
1991
#endif
@@ -2131,14 +2131,14 @@ int main(int argc, char **argv) {
2131
// ------------------------------------------------------------------------
2132
// Report ACLK build failure
2133
#ifndef ENABLE_ACLK
2134
- error("This agent doesn't have ACLK.");
2134
+ netdata_log_error("This agent doesn't have ACLK.");
2135
char filename[FILENAME_MAX + 1];
2136
snprintfz(filename, FILENAME_MAX, "%s/.aclk_report_sent", netdata_configured_varlib_dir);
2137
if (netdata_anonymous_statistics_enabled > 0 && access(filename, F_OK)) { // -1 -> not initialized
2138
send_statistics("ACLK_DISABLED", "-", "-");
2139
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 444);
2140
if (fd == -1)
2141
- error("Cannot create file '%s'. Please fix this.", filename);
2141
+ netdata_log_error("Cannot create file '%s'. Please fix this.", filename);
2142
else
2143
close(fd);
2144
}
daemon/service.c
+1
-1
@@ -42,7 +42,7 @@ static void svc_rrddim_obsolete_to_archive(RRDDIM *rd) {
42
if(cache_filename) {
43
netdata_log_info("Deleting dimension file '%s'.", cache_filename);
44
if (unlikely(unlink(cache_filename) == -1))
45
- error("Cannot delete dimension file '%s'", cache_filename);
45
+ netdata_log_error("Cannot delete dimension file '%s'", cache_filename);
46
}
47
48
if (rd->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
daemon/signals.c
+8
-8
@@ -59,7 +59,7 @@ void signals_block(void) {
59
sigfillset(&sigset);
60
61
if(pthread_sigmask(SIG_BLOCK, &sigset, NULL) == -1)
62
- error("SIGNAL: Could not block signals for threads");
62
+ netdata_log_error("SIGNAL: Could not block signals for threads");
63
}
64
65
void signals_unblock(void) {
@@ -67,7 +67,7 @@ void signals_unblock(void) {
67
sigfillset(&sigset);
68
69
if(pthread_sigmask(SIG_UNBLOCK, &sigset, NULL) == -1) {
70
- error("SIGNAL: Could not unblock signals for threads");
70
+ netdata_log_error("SIGNAL: Could not unblock signals for threads");
71
}
72
}
73
@@ -91,7 +91,7 @@ void signals_init(void) {
91
}
92
93
if(sigaction(signals_waiting[i].signo, &sa, NULL) == -1)
94
- error("SIGNAL: Failed to change signal handler for: %s", signals_waiting[i].name);
94
+ netdata_log_error("SIGNAL: Failed to change signal handler for: %s", signals_waiting[i].name);
95
}
96
}
97
@@ -104,7 +104,7 @@ void signals_restore_SIGCHLD(void)
104
sa.sa_handler = signal_handler;
105
106
if(sigaction(SIGCHLD, &sa, NULL) == -1)
107
- error("SIGNAL: Failed to change signal handler for: SIGCHLD");
107
+ netdata_log_error("SIGNAL: Failed to change signal handler for: SIGCHLD");
108
}
109
110
void signals_reset(void) {
@@ -116,7 +116,7 @@ void signals_reset(void) {
116
int i;
117
for (i = 0; signals_waiting[i].action != NETDATA_SIGNAL_END_OF_LIST; i++) {
118
if(sigaction(signals_waiting[i].signo, &sa, NULL) == -1)
119
- error("SIGNAL: Failed to reset signal handler for: %s", signals_waiting[i].name);
119
+ netdata_log_error("SIGNAL: Failed to reset signal handler for: %s", signals_waiting[i].name);
120
}
121
}
122
@@ -128,14 +128,14 @@ static void reap_child(pid_t pid) {
128
debug(D_CHILDS, "SIGNAL: reap_child(%d)...", pid);
129
if (netdata_waitid(P_PID, (id_t)pid, &i, WEXITED|WNOHANG) == -1) {
130
if (errno != ECHILD)
131
- error("SIGNAL: waitid(%d): failed to wait for child", pid);
131
+ netdata_log_error("SIGNAL: waitid(%d): failed to wait for child", pid);
132
else
133
netdata_log_info("SIGNAL: waitid(%d): failed - it seems the child is already reaped", pid);
134
return;
135
}
136
else if (i.si_pid == 0) {
137
// Process didn't exit, this shouldn't happen.
138
- error("SIGNAL: waitid(%d): reports pid 0 - child has not exited", pid);
138
+ netdata_log_error("SIGNAL: waitid(%d): reports pid 0 - child has not exited", pid);
139
return;
140
}
141
@@ -248,6 +248,6 @@ void signals_handle(void) {
248
}
249
}
250
else
251
- error("SIGNAL: pause() returned but it was not interrupted by a signal.");
251
+ netdata_log_error("SIGNAL: pause() returned but it was not interrupted by a signal.");
252
}
253
}
database/contexts/api_v1.c
+2
-2
@@ -356,7 +356,7 @@ static inline int rrdcontext_to_json_callback(const DICTIONARY_ITEM *item, void
356
357
int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, const char *context, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
358
if(!host->rrdctx.contexts) {
359
- error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, rrdhost_hostname(host));
359
+ netdata_log_error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, rrdhost_hostname(host));
360
return HTTP_RESP_NOT_FOUND;
361
}
362
@@ -393,7 +393,7 @@ int rrdcontext_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, R
393
394
int rrdcontexts_to_json(RRDHOST *host, BUFFER *wb, time_t after, time_t before, RRDCONTEXT_TO_JSON_OPTIONS options, SIMPLE_PATTERN *chart_label_key, SIMPLE_PATTERN *chart_labels_filter, SIMPLE_PATTERN *chart_dimensions) {
395
if(!host->rrdctx.contexts) {
396
- error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, rrdhost_hostname(host));
396
+ netdata_log_error("%s(): request for host '%s' that does not have rrdcontexts initialized.", __FUNCTION__, rrdhost_hostname(host));
397
return HTTP_RESP_NOT_FOUND;
398
}
399
database/contexts/context.c
+1
-1
@@ -33,7 +33,7 @@ static void rrdcontext_insert_callback(const DICTIONARY_ITEM *item __maybe_unuse
33
// we are loading data from the SQL database
34
35
if(rc->version)
36
- error("RRDCONTEXT: context '%s' is already initialized with version %"PRIu64", but it is loaded again from SQL with version %"PRIu64"", string2str(rc->id), rc->version, rc->hub.version);
36
+ netdata_log_error("RRDCONTEXT: context '%s' is already initialized with version %"PRIu64", but it is loaded again from SQL with version %"PRIu64"", string2str(rc->id), rc->version, rc->hub.version);
37
38
// IMPORTANT
39
// replace all string pointers in rc->hub with our own versions
database/contexts/instance.c
+2
-2
@@ -407,13 +407,13 @@ inline void rrdinstance_from_rrdset(RRDSET *st) {
407
#define rrdset_get_rrdinstance(st) rrdset_get_rrdinstance_with_trace(st, __FUNCTION__);
408
static inline RRDINSTANCE *rrdset_get_rrdinstance_with_trace(RRDSET *st, const char *function) {
409
if(unlikely(!st->rrdinstance)) {
410
- error("RRDINSTANCE: RRDSET '%s' is not linked to an RRDINSTANCE at %s()", rrdset_id(st), function);
410
+ netdata_log_error("RRDINSTANCE: RRDSET '%s' is not linked to an RRDINSTANCE at %s()", rrdset_id(st), function);
411
return NULL;
412
}
413
414
RRDINSTANCE *ri = rrdinstance_acquired_value(st->rrdinstance);
415
if(unlikely(!ri)) {
416
- error("RRDINSTANCE: RRDSET '%s' lost its link to an RRDINSTANCE at %s()", rrdset_id(st), function);
416
+ netdata_log_error("RRDINSTANCE: RRDSET '%s' lost its link to an RRDINSTANCE at %s()", rrdset_id(st), function);
417
return NULL;
418
}
419
database/contexts/metric.c
+2
-2
@@ -263,13 +263,13 @@ void rrdmetric_from_rrddim(RRDDIM *rd) {
263
#define rrddim_get_rrdmetric(rd) rrddim_get_rrdmetric_with_trace(rd, __FUNCTION__)
264
static inline RRDMETRIC *rrddim_get_rrdmetric_with_trace(RRDDIM *rd, const char *function) {
265
if(unlikely(!rd->rrdmetric)) {
266
- error("RRDMETRIC: RRDDIM '%s' is not linked to an RRDMETRIC at %s()", rrddim_id(rd), function);
266
+ netdata_log_error("RRDMETRIC: RRDDIM '%s' is not linked to an RRDMETRIC at %s()", rrddim_id(rd), function);
267
return NULL;
268
}
269
270
RRDMETRIC *rm = rrdmetric_acquired_value(rd->rrdmetric);
271
if(unlikely(!rm)) {
272
- error("RRDMETRIC: RRDDIM '%s' lost the link to its RRDMETRIC at %s()", rrddim_id(rd), function);
272
+ netdata_log_error("RRDMETRIC: RRDDIM '%s' lost the link to its RRDMETRIC at %s()", rrddim_id(rd), function);
273
return NULL;
274
}
275
database/contexts/query_target.c
+4
-4
@@ -895,12 +895,12 @@ static ssize_t query_node_add(void *data, RRDHOST *host, bool queryable_host) {
895
896
// is the chart given valid?
897
if(unlikely(qtl->st && (!qtl->st->rrdinstance || !qtl->st->rrdcontext))) {
898
- error("QUERY TARGET: RRDSET '%s' given, but it is not linked to rrdcontext structures. Linking it now.", rrdset_name(qtl->st));
898
+ netdata_log_error("QUERY TARGET: RRDSET '%s' given, but it is not linked to rrdcontext structures. Linking it now.", rrdset_name(qtl->st));
899
rrdinstance_from_rrdset(qtl->st);
900
901
if(unlikely(qtl->st && (!qtl->st->rrdinstance || !qtl->st->rrdcontext))) {
902
- error("QUERY TARGET: RRDSET '%s' given, but failed to be linked to rrdcontext structures. Switching to context query.",
903
- rrdset_name(qtl->st));
902
+ netdata_log_error("QUERY TARGET: RRDSET '%s' given, but failed to be linked to rrdcontext structures. Switching to context query.",
903
+ rrdset_name(qtl->st));
904
905
if (!is_valid_sp(qtl->instances))
906
qtl->instances = rrdset_name(qtl->st);
@@ -1098,7 +1098,7 @@ QUERY_TARGET *query_target_create(QUERY_TARGET_REQUEST *qtr) {
1098
}
1099
else if (unlikely(host != qtl.st->rrdhost)) {
1100
// Oops! A different host!
1101
- error("QUERY TARGET: RRDSET '%s' given does not belong to host '%s'. Switching query host to '%s'",
1101
+ netdata_log_error("QUERY TARGET: RRDSET '%s' given does not belong to host '%s'. Switching query host to '%s'",
1102
rrdset_name(qtl.st), rrdhost_hostname(host), rrdhost_hostname(qtl.st->rrdhost));
1103
host = qtl.st->rrdhost;
1104
}
database/contexts/rrdcontext.c
+18
-17
@@ -224,25 +224,26 @@ void rrdcontext_hub_checkpoint_command(void *ptr) {
224
struct ctxs_checkpoint *cmd = ptr;
225
226
if(!rrdhost_check_our_claim_id(cmd->claim_id)) {
227
- error("RRDCONTEXT: received checkpoint command for claim_id '%s', node id '%s', but this is not our claim id. Ours '%s', received '%s'. Ignoring command.",
228
- cmd->claim_id, cmd->node_id,
229
- localhost->aclk_state.claimed_id?localhost->aclk_state.claimed_id:"NOT SET",
230
- cmd->claim_id);
227
+ netdata_log_error("RRDCONTEXT: received checkpoint command for claim_id '%s', node id '%s', but this is not our claim id. Ours '%s', received '%s'. Ignoring command.",
228
+ cmd->claim_id, cmd->node_id,
229
+ localhost->aclk_state.claimed_id?localhost->aclk_state.claimed_id:"NOT SET",
230
+ cmd->claim_id);
231
232
return;
233
}
234
235
RRDHOST *host = rrdhost_find_by_node_id(cmd->node_id);
236
if(!host) {
237
- error("RRDCONTEXT: received checkpoint command for claim id '%s', node id '%s', but there is no node with such node id here. Ignoring command.",
238
- cmd->claim_id, cmd->node_id);
237
+ netdata_log_error("RRDCONTEXT: received checkpoint command for claim id '%s', node id '%s', but there is no node with such node id here. Ignoring command.",
238
+ cmd->claim_id,
239
+ cmd->node_id);
240
241
return;
242
}
243
244
if(rrdhost_flag_check(host, RRDHOST_FLAG_ACLK_STREAM_CONTEXTS)) {
245
netdata_log_info("RRDCONTEXT: received checkpoint command for claim id '%s', node id '%s', while node '%s' has an active context streaming.",
245
- cmd->claim_id, cmd->node_id, rrdhost_hostname(host));
246
+ cmd->claim_id, cmd->node_id, rrdhost_hostname(host));
247
248
// disable it temporarily, so that our worker will not attempt to send messages in parallel
249
rrdhost_flag_clear(host, RRDHOST_FLAG_ACLK_STREAM_CONTEXTS);
@@ -251,8 +252,8 @@ void rrdcontext_hub_checkpoint_command(void *ptr) {
252
uint64_t our_version_hash = rrdcontext_version_hash(host);
253
254
if(cmd->version_hash != our_version_hash) {
254
- error("RRDCONTEXT: received version hash %"PRIu64" for host '%s', does not match our version hash %"PRIu64". Sending snapshot of all contexts.",
255
- cmd->version_hash, rrdhost_hostname(host), our_version_hash);
255
+ netdata_log_error("RRDCONTEXT: received version hash %"PRIu64" for host '%s', does not match our version hash %"PRIu64". Sending snapshot of all contexts.",
256
+ cmd->version_hash, rrdhost_hostname(host), our_version_hash);
257
258
#ifdef ENABLE_ACLK
259
// prepare the snapshot
@@ -285,25 +286,25 @@ void rrdcontext_hub_stop_streaming_command(void *ptr) {
286
struct stop_streaming_ctxs *cmd = ptr;
287
288
if(!rrdhost_check_our_claim_id(cmd->claim_id)) {
288
- error("RRDCONTEXT: received stop streaming command for claim_id '%s', node id '%s', but this is not our claim id. Ours '%s', received '%s'. Ignoring command.",
289
- cmd->claim_id, cmd->node_id,
290
- localhost->aclk_state.claimed_id?localhost->aclk_state.claimed_id:"NOT SET",
291
- cmd->claim_id);
289
+ netdata_log_error("RRDCONTEXT: received stop streaming command for claim_id '%s', node id '%s', but this is not our claim id. Ours '%s', received '%s'. Ignoring command.",
290
+ cmd->claim_id, cmd->node_id,
291
+ localhost->aclk_state.claimed_id?localhost->aclk_state.claimed_id:"NOT SET",
292
+ cmd->claim_id);
293
294
return;
295
}
296
297
RRDHOST *host = rrdhost_find_by_node_id(cmd->node_id);
298
if(!host) {
298
- error("RRDCONTEXT: received stop streaming command for claim id '%s', node id '%s', but there is no node with such node id here. Ignoring command.",
299
- cmd->claim_id, cmd->node_id);
299
+ netdata_log_error("RRDCONTEXT: received stop streaming command for claim id '%s', node id '%s', but there is no node with such node id here. Ignoring command.",
300
+ cmd->claim_id, cmd->node_id);
301
302
return;
303
}
304
305
if(!rrdhost_flag_check(host, RRDHOST_FLAG_ACLK_STREAM_CONTEXTS)) {
305
- error("RRDCONTEXT: received stop streaming command for claim id '%s', node id '%s', but node '%s' does not have active context streaming. Ignoring command.",
306
- cmd->claim_id, cmd->node_id, rrdhost_hostname(host));
306
+ netdata_log_error("RRDCONTEXT: received stop streaming command for claim id '%s', node id '%s', but node '%s' does not have active context streaming. Ignoring command.",
307
+ cmd->claim_id, cmd->node_id, rrdhost_hostname(host));
308
309
return;
310
}
database/contexts/worker.c
+15
-14
@@ -350,7 +350,8 @@ void rrdcontext_delete_from_sql_unsafe(RRDCONTEXT *rc) {
350
351
// delete it from SQL
352
if(ctx_delete_context(&rc->rrdhost->host_uuid, &rc->hub) != 0)
353
- error("RRDCONTEXT: failed to delete context '%s' version %"PRIu64" from SQL.", rc->hub.id, rc->hub.version);
353
+ netdata_log_error("RRDCONTEXT: failed to delete context '%s' version %"PRIu64" from SQL.",
354
+ rc->hub.id, rc->hub.version);
355
}
356
357
static void rrdcontext_garbage_collect_single_host(RRDHOST *host, bool worker_jobs) {
@@ -374,11 +375,11 @@ static void rrdcontext_garbage_collect_single_host(RRDHOST *host, bool worker_jo
375
if(rrdmetric_should_be_deleted(rm)) {
376
if(worker_jobs) worker_is_busy(WORKER_JOB_CLEANUP_DELETE);
377
if(!dictionary_del(ri->rrdmetrics, string2str(rm->id)))
377
- error("RRDCONTEXT: metric '%s' of instance '%s' of context '%s' of host '%s', failed to be deleted from rrdmetrics dictionary.",
378
- string2str(rm->id),
379
- string2str(ri->id),
380
- string2str(rc->id),
381
- rrdhost_hostname(host));
378
+ netdata_log_error("RRDCONTEXT: metric '%s' of instance '%s' of context '%s' of host '%s', failed to be deleted from rrdmetrics dictionary.",
379
+ string2str(rm->id),
380
+ string2str(ri->id),
381
+ string2str(rc->id),
382
+ rrdhost_hostname(host));
383
else
384
internal_error(
385
true,
@@ -394,10 +395,10 @@ static void rrdcontext_garbage_collect_single_host(RRDHOST *host, bool worker_jo
395
if(rrdinstance_should_be_deleted(ri)) {
396
if(worker_jobs) worker_is_busy(WORKER_JOB_CLEANUP_DELETE);
397
if(!dictionary_del(rc->rrdinstances, string2str(ri->id)))
397
- error("RRDCONTEXT: instance '%s' of context '%s' of host '%s', failed to be deleted from rrdmetrics dictionary.",
398
- string2str(ri->id),
399
- string2str(rc->id),
400
- rrdhost_hostname(host));
398
+ netdata_log_error("RRDCONTEXT: instance '%s' of context '%s' of host '%s', failed to be deleted from rrdmetrics dictionary.",
399
+ string2str(ri->id),
400
+ string2str(rc->id),
401
+ rrdhost_hostname(host));
402
else
403
internal_error(
404
true,
@@ -415,7 +416,7 @@ static void rrdcontext_garbage_collect_single_host(RRDHOST *host, bool worker_jo
416
rrdcontext_delete_from_sql_unsafe(rc);
417
418
if(!dictionary_del(host->rrdctx.contexts, string2str(rc->id)))
418
- error("RRDCONTEXT: context '%s' of host '%s', failed to be deleted from rrdmetrics dictionary.",
419
+ netdata_log_error("RRDCONTEXT: context '%s' of host '%s', failed to be deleted from rrdmetrics dictionary.",
420
string2str(rc->id),
421
rrdhost_hostname(host));
422
else
@@ -844,7 +845,7 @@ void rrdcontext_message_send_unsafe(RRDCONTEXT *rc, bool snapshot __maybe_unused
845
rrdcontext_delete_from_sql_unsafe(rc);
846
847
else if (ctx_store_context(&rc->rrdhost->host_uuid, &rc->hub) != 0)
847
- error("RRDCONTEXT: failed to save context '%s' version %"PRIu64" to SQL.", rc->hub.id, rc->hub.version);
848
+ netdata_log_error("RRDCONTEXT: failed to save context '%s' version %"PRIu64" to SQL.", rc->hub.id, rc->hub.version);
849
}
850
851
static bool check_if_cloud_version_changed_unsafe(RRDCONTEXT *rc, bool sending __maybe_unused) {
@@ -1021,8 +1022,8 @@ static void rrdcontext_dispatch_queued_contexts_to_hub(RRDHOST *host, usec_t now
1022
1023
// delete it from the master dictionary
1024
if(!dictionary_del(host->rrdctx.contexts, string2str(rc->id)))
1024
- error("RRDCONTEXT: '%s' of host '%s' failed to be deleted from rrdcontext dictionary.",
1025
- string2str(id), rrdhost_hostname(host));
1025
+ netdata_log_error("RRDCONTEXT: '%s' of host '%s' failed to be deleted from rrdcontext dictionary.",
1026
+ string2str(id), rrdhost_hostname(host));
1027
1028
string_freez(id);
1029
}
database/engine/cache.c
+1
-1
@@ -1847,7 +1847,7 @@ void pgc_destroy(PGC *cache) {
1847
free_all_unreferenced_clean_pages(cache);
1848
1849
if(PGC_REFERENCED_PAGES(cache))
1850
- error("DBENGINE CACHE: there are %zu referenced cache pages - leaving the cache allocated", PGC_REFERENCED_PAGES(cache));
1850
+ netdata_log_error("DBENGINE CACHE: there are %zu referenced cache pages - leaving the cache allocated", PGC_REFERENCED_PAGES(cache));
1851
else {
1852
pointer_destroy_index(cache);
1853
database/engine/datafile.c
+14
-14
@@ -175,7 +175,7 @@ int close_data_file(struct rrdengine_datafile *datafile)
175
176
ret = uv_fs_close(NULL, &req, datafile->file, NULL);
177
if (ret < 0) {
178
- error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
178
+ netdata_log_error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
179
ctx_fs_error(ctx);
180
}
181
uv_fs_req_cleanup(&req);
@@ -194,7 +194,7 @@ int unlink_data_file(struct rrdengine_datafile *datafile)
194
195
ret = uv_fs_unlink(NULL, &req, path, NULL);
196
if (ret < 0) {
197
- error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
197
+ netdata_log_error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
198
ctx_fs_error(ctx);
199
}
200
uv_fs_req_cleanup(&req);
@@ -215,21 +215,21 @@ int destroy_data_file_unsafe(struct rrdengine_datafile *datafile)
215
216
ret = uv_fs_ftruncate(NULL, &req, datafile->file, 0, NULL);
217
if (ret < 0) {
218
- error("DBENGINE: uv_fs_ftruncate(%s): %s", path, uv_strerror(ret));
218
+ netdata_log_error("DBENGINE: uv_fs_ftruncate(%s): %s", path, uv_strerror(ret));
219
ctx_fs_error(ctx);
220
}
221
uv_fs_req_cleanup(&req);
222
223
ret = uv_fs_close(NULL, &req, datafile->file, NULL);
224
if (ret < 0) {
225
- error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
225
+ netdata_log_error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
226
ctx_fs_error(ctx);
227
}
228
uv_fs_req_cleanup(&req);
229
230
ret = uv_fs_unlink(NULL, &req, path, NULL);
231
if (ret < 0) {
232
- error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
232
+ netdata_log_error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
233
ctx_fs_error(ctx);
234
}
235
uv_fs_req_cleanup(&req);
@@ -272,7 +272,7 @@ int create_data_file(struct rrdengine_datafile *datafile)
272
ret = uv_fs_write(NULL, &req, file, &iov, 1, 0, NULL);
273
if (ret < 0) {
274
fatal_assert(req.result < 0);
275
- error("DBENGINE: uv_fs_write: %s", uv_strerror(ret));
275
+ netdata_log_error("DBENGINE: uv_fs_write: %s", uv_strerror(ret));
276
ctx_io_error(ctx);
277
}
278
uv_fs_req_cleanup(&req);
@@ -303,7 +303,7 @@ static int check_data_file_superblock(uv_file file)
303
304
ret = uv_fs_read(NULL, &req, file, &iov, 1, 0, NULL);
305
if (ret < 0) {
306
- error("DBENGINE: uv_fs_read: %s", uv_strerror(ret));
306
+ netdata_log_error("DBENGINE: uv_fs_read: %s", uv_strerror(ret));
307
uv_fs_req_cleanup(&req);
308
goto error;
309
}
@@ -313,7 +313,7 @@ static int check_data_file_superblock(uv_file file)
313
if (strncmp(superblock->magic_number, RRDENG_DF_MAGIC, RRDENG_MAGIC_SZ) ||
314
strncmp(superblock->version, RRDENG_DF_VER, RRDENG_VER_SZ) ||
315
superblock->tier != 1) {
316
- error("DBENGINE: file has invalid superblock.");
316
+ netdata_log_error("DBENGINE: file has invalid superblock.");
317
ret = UV_EINVAL;
318
} else {
319
ret = 0;
@@ -361,7 +361,7 @@ static int load_data_file(struct rrdengine_datafile *datafile)
361
error = ret;
362
ret = uv_fs_close(NULL, &req, file, NULL);
363
if (ret < 0) {
364
- error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
364
+ netdata_log_error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
365
ctx_fs_error(ctx);
366
}
367
uv_fs_req_cleanup(&req);
@@ -394,7 +394,7 @@ static int scan_data_files(struct rrdengine_instance *ctx)
394
if (ret < 0) {
395
fatal_assert(req.result < 0);
396
uv_fs_req_cleanup(&req);
397
- error("DBENGINE: uv_fs_scandir(%s): %s", ctx->config.dbfiles_path, uv_strerror(ret));
397
+ netdata_log_error("DBENGINE: uv_fs_scandir(%s): %s", ctx->config.dbfiles_path, uv_strerror(ret));
398
ctx_fs_error(ctx);
399
return ret;
400
}
@@ -416,7 +416,7 @@ static int scan_data_files(struct rrdengine_instance *ctx)
416
}
417
418
if (matched_files == MAX_DATAFILES)
419
- error("DBENGINE: warning: hit maximum database engine file limit of %d files", MAX_DATAFILES);
419
+ netdata_log_error("DBENGINE: warning: hit maximum database engine file limit of %d files", MAX_DATAFILES);
420
421
qsort(datafiles, matched_files, sizeof(*datafiles), scan_data_files_cmp);
422
@@ -441,7 +441,7 @@ static int scan_data_files(struct rrdengine_instance *ctx)
441
if (must_delete_pair) {
442
char path[RRDENG_PATH_MAX];
443
444
- error("DBENGINE: deleting invalid data and journal file pair.");
444
+ netdata_log_error("DBENGINE: deleting invalid data and journal file pair.");
445
ret = journalfile_unlink(journalfile);
446
if (!ret) {
447
journalfile_v1_generate_path(datafile, path, sizeof(path));
@@ -521,14 +521,14 @@ int init_data_files(struct rrdengine_instance *ctx)
521
fatal_assert(0 == uv_rwlock_init(&ctx->datafiles.rwlock));
522
ret = scan_data_files(ctx);
523
if (ret < 0) {
524
- error("DBENGINE: failed to scan path \"%s\".", ctx->config.dbfiles_path);
524
+ netdata_log_error("DBENGINE: failed to scan path \"%s\".", ctx->config.dbfiles_path);
525
return ret;
526
} else if (0 == ret) {
527
netdata_log_info("DBENGINE: data files not found, creating in path \"%s\".", ctx->config.dbfiles_path);
528
ctx->atomic.last_fileno = 0;
529
ret = create_new_datafile_pair(ctx, false);
530
if (ret) {
531
- error("DBENGINE: failed to create data and journal files in path \"%s\".", ctx->config.dbfiles_path);
531
+ netdata_log_error("DBENGINE: failed to create data and journal files in path \"%s\".", ctx->config.dbfiles_path);
532
return ret;
533
}
534
}
database/engine/journalfile.c
+26
-26
@@ -12,7 +12,7 @@ static void after_extent_write_journalfile_v1_io(uv_fs_t* req)
12
debug(D_RRDENGINE, "%s: Journal block was written to disk.", __func__);
13
if (req->result < 0) {
14
ctx_io_error(ctx);
15
- error("DBENGINE: %s: uv_fs_write: %s", __func__, uv_strerror((int)req->result));
15
+ netdata_log_error("DBENGINE: %s: uv_fs_write: %s", __func__, uv_strerror((int)req->result));
16
} else {
17
debug(D_RRDENGINE, "%s: Journal block was written to disk.", __func__);
18
}
@@ -271,7 +271,7 @@ static bool journalfile_v2_mounted_data_unmount(struct rrdengine_journalfile *jo
271
if (munmap(journalfile->mmap.data, journalfile->mmap.size)) {
272
char path[RRDENG_PATH_MAX];
273
journalfile_v2_generate_path(journalfile->datafile, path, sizeof(path));
274
- error("DBENGINE: failed to unmap index file '%s'", path);
274
+ netdata_log_error("DBENGINE: failed to unmap index file '%s'", path);
275
internal_fatal(true, "DBENGINE: failed to unmap file '%s'", path);
276
ctx_fs_error(journalfile->datafile->ctx);
277
}
@@ -483,7 +483,7 @@ static int close_uv_file(struct rrdengine_datafile *datafile, uv_file file)
483
ret = uv_fs_close(NULL, &req, file, NULL);
484
if (ret < 0) {
485
journalfile_v1_generate_path(datafile, path, sizeof(path));
486
- error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
486
+ netdata_log_error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
487
ctx_fs_error(datafile->ctx);
488
}
489
uv_fs_req_cleanup(&req);
@@ -512,7 +512,7 @@ int journalfile_unlink(struct rrdengine_journalfile *journalfile)
512
513
ret = uv_fs_unlink(NULL, &req, path, NULL);
514
if (ret < 0) {
515
- error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
515
+ netdata_log_error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
516
ctx_fs_error(ctx);
517
}
518
uv_fs_req_cleanup(&req);
@@ -536,7 +536,7 @@ int journalfile_destroy_unsafe(struct rrdengine_journalfile *journalfile, struct
536
if (journalfile->file) {
537
ret = uv_fs_ftruncate(NULL, &req, journalfile->file, 0, NULL);
538
if (ret < 0) {
539
- error("DBENGINE: uv_fs_ftruncate(%s): %s", path, uv_strerror(ret));
539
+ netdata_log_error("DBENGINE: uv_fs_ftruncate(%s): %s", path, uv_strerror(ret));
540
ctx_fs_error(ctx);
541
}
542
uv_fs_req_cleanup(&req);
@@ -546,14 +546,14 @@ int journalfile_destroy_unsafe(struct rrdengine_journalfile *journalfile, struct
546
// This is the new journal v2 index file
547
ret = uv_fs_unlink(NULL, &req, path_v2, NULL);
548
if (ret < 0) {
549
- error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
549
+ netdata_log_error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
550
ctx_fs_error(ctx);
551
}
552
uv_fs_req_cleanup(&req);
553
554
ret = uv_fs_unlink(NULL, &req, path, NULL);
555
if (ret < 0) {
556
- error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
556
+ netdata_log_error("DBENGINE: uv_fs_fsunlink(%s): %s", path, uv_strerror(ret));
557
ctx_fs_error(ctx);
558
}
559
uv_fs_req_cleanup(&req);
@@ -598,7 +598,7 @@ int journalfile_create(struct rrdengine_journalfile *journalfile, struct rrdengi
598
ret = uv_fs_write(NULL, &req, file, &iov, 1, 0, NULL);
599
if (ret < 0) {
600
fatal_assert(req.result < 0);
601
- error("DBENGINE: uv_fs_write: %s", uv_strerror(ret));
601
+ netdata_log_error("DBENGINE: uv_fs_write: %s", uv_strerror(ret));
602
ctx_io_error(ctx);
603
}
604
uv_fs_req_cleanup(&req);
@@ -630,7 +630,7 @@ static int journalfile_check_superblock(uv_file file)
630
631
ret = uv_fs_read(NULL, &req, file, &iov, 1, 0, NULL);
632
if (ret < 0) {
633
- error("DBENGINE: uv_fs_read: %s", uv_strerror(ret));
633
+ netdata_log_error("DBENGINE: uv_fs_read: %s", uv_strerror(ret));
634
uv_fs_req_cleanup(&req);
635
goto error;
636
}
@@ -639,7 +639,7 @@ static int journalfile_check_superblock(uv_file file)
639
640
if (strncmp(superblock->magic_number, RRDENG_JF_MAGIC, RRDENG_MAGIC_SZ) ||
641
strncmp(superblock->version, RRDENG_JF_VER, RRDENG_VER_SZ)) {
642
- error("DBENGINE: File has invalid superblock.");
642
+ netdata_log_error("DBENGINE: File has invalid superblock.");
643
ret = UV_EINVAL;
644
} else {
645
ret = 0;
@@ -660,7 +660,7 @@ static void journalfile_restore_extent_metadata(struct rrdengine_instance *ctx,
660
descr_size = sizeof(*jf_metric_data->descr) * count;
661
payload_length = sizeof(*jf_metric_data) + descr_size;
662
if (payload_length > max_size) {
663
- error("DBENGINE: corrupted transaction payload.");
663
+ netdata_log_error("DBENGINE: corrupted transaction payload.");
664
return;
665
}
666
@@ -671,7 +671,7 @@ static void journalfile_restore_extent_metadata(struct rrdengine_instance *ctx,
671
672
if (page_type > PAGE_TYPE_MAX) {
673
if (!bitmap256_get_bit(&page_error_map, page_type)) {
674
- error("DBENGINE: unknown page type %d encountered.", page_type);
674
+ netdata_log_error("DBENGINE: unknown page type %d encountered.", page_type);
675
bitmap256_set_bit(&page_error_map, page_type, 1);
676
}
677
continue;
@@ -744,14 +744,14 @@ static unsigned journalfile_replay_transaction(struct rrdengine_instance *ctx, s
744
return 0;
745
}
746
if (sizeof(*jf_header) > max_size) {
747
- error("DBENGINE: corrupted transaction record, skipping.");
747
+ netdata_log_error("DBENGINE: corrupted transaction record, skipping.");
748
return 0;
749
}
750
*id = jf_header->id;
751
payload_length = jf_header->payload_length;
752
size_bytes = sizeof(*jf_header) + payload_length + sizeof(*jf_trailer);
753
if (size_bytes > max_size) {
754
- error("DBENGINE: corrupted transaction record, skipping.");
754
+ netdata_log_error("DBENGINE: corrupted transaction record, skipping.");
755
return 0;
756
}
757
jf_trailer = buf + sizeof(*jf_header) + payload_length;
@@ -760,7 +760,7 @@ static unsigned journalfile_replay_transaction(struct rrdengine_instance *ctx, s
760
ret = crc32cmp(jf_trailer->checksum, crc);
761
debug(D_RRDENGINE, "Transaction %"PRIu64" was read from disk. CRC32 check: %s", *id, ret ? "FAILED" : "SUCCEEDED");
762
if (unlikely(ret)) {
763
- error("DBENGINE: transaction %"PRIu64" was read from disk. CRC32 check: FAILED", *id);
763
+ netdata_log_error("DBENGINE: transaction %"PRIu64" was read from disk. CRC32 check: FAILED", *id);
764
return size_bytes;
765
}
766
switch (jf_header->type) {
@@ -769,7 +769,7 @@ static unsigned journalfile_replay_transaction(struct rrdengine_instance *ctx, s
769
journalfile_restore_extent_metadata(ctx, journalfile, buf + sizeof(*jf_header), payload_length);
770
break;
771
default:
772
- error("DBENGINE: unknown transaction type, skipping record.");
772
+ netdata_log_error("DBENGINE: unknown transaction type, skipping record.");
773
break;
774
}
775
@@ -807,7 +807,7 @@ static uint64_t journalfile_iterate_transactions(struct rrdengine_instance *ctx,
807
iov = uv_buf_init(buf, size_bytes);
808
ret = uv_fs_read(NULL, &req, file, &iov, 1, pos, NULL);
809
if (ret < 0) {
810
- error("DBENGINE: uv_fs_read: pos=%" PRIu64 ", %s", pos, uv_strerror(ret));
810
+ netdata_log_error("DBENGINE: uv_fs_read: pos=%" PRIu64 ", %s", pos, uv_strerror(ret));
811
uv_fs_req_cleanup(&req);
812
goto skip_file;
813
}
@@ -846,7 +846,7 @@ static int journalfile_check_v2_extent_list (void *data_start, size_t file_size)
846
crc = crc32(0L, Z_NULL, 0);
847
crc = crc32(crc, (uint8_t *) data_start + j2_header->extent_offset, j2_header->extent_count * sizeof(struct journal_extent_list));
848
if (unlikely(crc32cmp(journal_v2_trailer->checksum, crc))) {
849
- error("DBENGINE: extent list CRC32 check: FAILED");
849
+ netdata_log_error("DBENGINE: extent list CRC32 check: FAILED");
850
return 1;
851
}
852
@@ -866,7 +866,7 @@ static int journalfile_check_v2_metric_list(void *data_start, size_t file_size)
866
crc = crc32(0L, Z_NULL, 0);
867
crc = crc32(crc, (uint8_t *) data_start + j2_header->metric_offset, j2_header->metric_count * sizeof(struct journal_metric_list));
868
if (unlikely(crc32cmp(journal_v2_trailer->checksum, crc))) {
869
- error("DBENGINE: metric list CRC32 check: FAILED");
869
+ netdata_log_error("DBENGINE: metric list CRC32 check: FAILED");
870
return 1;
871
}
872
return 0;
@@ -910,7 +910,7 @@ static int journalfile_v2_validate(void *data_start, size_t journal_v2_file_size
910
911
rc = crc32cmp(journal_v2_trailer->checksum, crc);
912
if (unlikely(rc)) {
913
- error("DBENGINE: file CRC32 check: FAILED");
913
+ netdata_log_error("DBENGINE: file CRC32 check: FAILED");
914
return 1;
915
}
916
@@ -1047,13 +1047,13 @@ int journalfile_v2_load(struct rrdengine_instance *ctx, struct rrdengine_journal
1047
if (errno == ENOENT)
1048
return 1;
1049
ctx_fs_error(ctx);
1050
- error("DBENGINE: failed to open '%s'", path_v2);
1050
+ netdata_log_error("DBENGINE: failed to open '%s'", path_v2);
1051
return 1;
1052
}
1053
1054
ret = fstat(fd, &statbuf);
1055
if (ret) {
1056
- error("DBENGINE: failed to get file information for '%s'", path_v2);
1056
+ netdata_log_error("DBENGINE: failed to get file information for '%s'", path_v2);
1057
close(fd);
1058
return 1;
1059
}
@@ -1085,7 +1085,7 @@ int journalfile_v2_load(struct rrdengine_instance *ctx, struct rrdengine_journal
1085
error_report("File %s is invalid and it will be rebuilt", path_v2);
1086
1087
if (unlikely(munmap(data_start, journal_v2_file_size)))
1088
- error("DBENGINE: failed to unmap '%s'", path_v2);
1088
+ netdata_log_error("DBENGINE: failed to unmap '%s'", path_v2);
1089
1090
close(fd);
1091
return rc;
@@ -1096,7 +1096,7 @@ int journalfile_v2_load(struct rrdengine_instance *ctx, struct rrdengine_journal
1096
1097
if (unlikely(!entries)) {
1098
if (unlikely(munmap(data_start, journal_v2_file_size)))
1099
- error("DBENGINE: failed to unmap '%s'", path_v2);
1099
+ netdata_log_error("DBENGINE: failed to unmap '%s'", path_v2);
1100
1101
close(fd);
1102
return 1;
@@ -1479,7 +1479,7 @@ void journalfile_migrate_to_v2_callback(Word_t section, unsigned datafile_fileno
1479
if (ret < 0) {
1480
ctx_current_disk_space_increase(ctx, total_file_size);
1481
ctx_fs_error(ctx);
1482
- error("DBENGINE: failed to resize file '%s'", path);
1482
+ netdata_log_error("DBENGINE: failed to resize file '%s'", path);
1483
}
1484
else
1485
ctx_current_disk_space_increase(ctx, resize_file_to);
@@ -1560,7 +1560,7 @@ int journalfile_load(struct rrdengine_instance *ctx, struct rrdengine_journalfil
1560
cleanup:
1561
ret = uv_fs_close(NULL, &req, file, NULL);
1562
if (ret < 0) {
1563
- error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
1563
+ netdata_log_error("DBENGINE: uv_fs_close(%s): %s", path, uv_strerror(ret));
1564
ctx_fs_error(ctx);
1565
}
1566
uv_fs_req_cleanup(&req);
database/engine/rrdengine.c
+4
-4
@@ -733,7 +733,7 @@ static void after_extent_write_datafile_io(uv_fs_t *uv_fs_request) {
733
734
if (uv_fs_request->result < 0) {
735
ctx_io_error(ctx);
736
- error("DBENGINE: %s: uv_fs_write(): %s", __func__, uv_strerror((int)uv_fs_request->result));
736
+ netdata_log_error("DBENGINE: %s: uv_fs_write(): %s", __func__, uv_strerror((int)uv_fs_request->result));
737
}
738
739
journalfile_v1_extent_write(ctx, xt_io_descr->datafile, xt_io_descr->wal, &rrdeng_main.loop);
@@ -1643,14 +1643,14 @@ bool rrdeng_dbengine_spawn(struct rrdengine_instance *ctx __maybe_unused) {
1643
1644
ret = uv_loop_init(&rrdeng_main.loop);
1645
if (ret) {
1646
- error("DBENGINE: uv_loop_init(): %s", uv_strerror(ret));
1646
+ netdata_log_error("DBENGINE: uv_loop_init(): %s", uv_strerror(ret));
1647
return false;
1648
}
1649
rrdeng_main.loop.data = &rrdeng_main;
1650
1651
ret = uv_async_init(&rrdeng_main.loop, &rrdeng_main.async, async_cb);
1652
if (ret) {
1653
- error("DBENGINE: uv_async_init(): %s", uv_strerror(ret));
1653
+ netdata_log_error("DBENGINE: uv_async_init(): %s", uv_strerror(ret));
1654
fatal_assert(0 == uv_loop_close(&rrdeng_main.loop));
1655
return false;
1656
}
@@ -1658,7 +1658,7 @@ bool rrdeng_dbengine_spawn(struct rrdengine_instance *ctx __maybe_unused) {
1658
1659
ret = uv_timer_init(&rrdeng_main.loop, &rrdeng_main.timer);
1660
if (ret) {
1661
- error("DBENGINE: uv_timer_init(): %s", uv_strerror(ret));
1661
+ netdata_log_error("DBENGINE: uv_timer_init(): %s", uv_strerror(ret));
1662
uv_close((uv_handle_t *)&rrdeng_main.async, NULL);
1663
fatal_assert(0 == uv_loop_close(&rrdeng_main.loop));
1664
return false;
database/engine/rrdengineapi.c
+5
-5
@@ -247,7 +247,7 @@ STORAGE_COLLECT_HANDLE *rrdeng_store_metric_init(STORAGE_METRIC_HANDLE *db_metri
247
is_1st_metric_writer = false;
248
char uuid[UUID_STR_LEN + 1];
249
uuid_unparse(*mrg_metric_uuid(main_mrg, metric), uuid);
250
- error("DBENGINE: metric '%s' is already collected and should not be collected twice - expect gaps on the charts", uuid);
250
+ netdata_log_error("DBENGINE: metric '%s' is already collected and should not be collected twice - expect gaps on the charts", uuid);
251
}
252
253
metric = mrg_metric_dup(main_mrg, metric);
@@ -312,7 +312,7 @@ static bool page_has_only_empty_metrics(struct rrdeng_collect_handle *handle) {
312
default: {
313
static bool logged = false;
314
if(!logged) {
315
- error("DBENGINE: cannot check page for nulls on unknown page type id %d", (mrg_metric_ctx(handle->metric))->config.page_type);
315
+ netdata_log_error("DBENGINE: cannot check page for nulls on unknown page type id %d", (mrg_metric_ctx(handle->metric))->config.page_type);
316
logged = true;
317
}
318
return false;
@@ -908,7 +908,7 @@ STORAGE_POINT rrdeng_load_metric_next(struct storage_engine_query_handle *rrddim
908
default: {
909
static bool logged = false;
910
if(!logged) {
911
- error("DBENGINE: unknown page type %d found. Cannot decode it. Ignoring its metrics.", handle->ctx->config.page_type);
911
+ netdata_log_error("DBENGINE: unknown page type %d found. Cannot decode it. Ignoring its metrics.", handle->ctx->config.page_type);
912
logged = true;
913
}
914
storage_point_empty(sp, sp.start_time_s, sp.end_time_s);
@@ -986,7 +986,7 @@ bool rrdeng_metric_retention_by_uuid(STORAGE_INSTANCE *db_instance, uuid_t *dim_
986
{
987
struct rrdengine_instance *ctx = (struct rrdengine_instance *)db_instance;
988
if (unlikely(!ctx)) {
989
- error("DBENGINE: invalid STORAGE INSTANCE to %s()", __FUNCTION__);
989
+ netdata_log_error("DBENGINE: invalid STORAGE INSTANCE to %s()", __FUNCTION__);
990
return false;
991
}
992
@@ -1160,7 +1160,7 @@ int rrdeng_init(struct rrdengine_instance **ctxp, const char *dbfiles_path,
1160
/* reserve RRDENG_FD_BUDGET_PER_INSTANCE file descriptors for this instance */
1161
rrd_stat_atomic_add(&rrdeng_reserved_file_descriptors, RRDENG_FD_BUDGET_PER_INSTANCE);
1162
if (rrdeng_reserved_file_descriptors > max_open_files) {
1163
- error(
1163
+ netdata_log_error(
1164
"Exceeded the budget of available file descriptors (%u/%u), cannot create new dbengine instance.",
1165
(unsigned)rrdeng_reserved_file_descriptors,
1166
(unsigned)max_open_files);
database/engine/rrdenginelib.c
+7
-7
@@ -14,12 +14,12 @@ int check_file_properties(uv_file file, uint64_t *file_size, size_t min_size)
14
fatal_assert(req.result == 0);
15
s = req.ptr;
16
if (!(s->st_mode & S_IFREG)) {
17
- error("Not a regular file.\n");
17
+ netdata_log_error("Not a regular file.\n");
18
uv_fs_req_cleanup(&req);
19
return UV_EINVAL;
20
}
21
if (s->st_size < min_size) {
22
- error("File length is too short.\n");
22
+ netdata_log_error("File length is too short.\n");
23
uv_fs_req_cleanup(&req);
24
return UV_EINVAL;
25
}
@@ -56,9 +56,9 @@ int open_file_for_io(char *path, int flags, uv_file *file, int direct)
56
fd = uv_fs_open(NULL, &req, path, current_flags, S_IRUSR | S_IWUSR, NULL);
57
if (fd < 0) {
58
if ((direct) && (UV_EINVAL == fd)) {
59
- error("File \"%s\" does not support direct I/O, falling back to buffered I/O.", path);
59
+ netdata_log_error("File \"%s\" does not support direct I/O, falling back to buffered I/O.", path);
60
} else {
61
- error("Failed to open file \"%s\".", path);
61
+ netdata_log_error("Failed to open file \"%s\".", path);
62
--direct; /* break the loop */
63
}
64
} else {
@@ -107,7 +107,7 @@ int count_legacy_children(char *dbfiles_path)
107
ret = uv_fs_scandir(NULL, &req, dbfiles_path, 0, NULL);
108
if (ret < 0) {
109
uv_fs_req_cleanup(&req);
110
- error("uv_fs_scandir(%s): %s", dbfiles_path, uv_strerror(ret));
110
+ netdata_log_error("uv_fs_scandir(%s): %s", dbfiles_path, uv_strerror(ret));
111
return ret;
112
}
113
@@ -134,7 +134,7 @@ int compute_multidb_diskspace()
134
fclose(fp);
135
if (unlikely(rc != 1 || computed_multidb_disk_quota_mb < RRDENG_MIN_DISK_SPACE_MB)) {
136
errno = 0;
137
- error("File '%s' contains invalid input, it will be rebuild", multidb_disk_space_file);
137
+ netdata_log_error("File '%s' contains invalid input, it will be rebuild", multidb_disk_space_file);
138
computed_multidb_disk_quota_mb = -1;
139
}
140
}
@@ -151,7 +151,7 @@ int compute_multidb_diskspace()
151
netdata_log_info("Created file '%s' to store the computed value", multidb_disk_space_file);
152
fclose(fp);
153
} else
154
- error("Failed to store the default multidb disk quota size on '%s'", multidb_disk_space_file);
154
+ netdata_log_error("Failed to store the default multidb disk quota size on '%s'", multidb_disk_space_file);
155
}
156
else
157
computed_multidb_disk_quota_mb = default_rrdeng_disk_quota_mb;
database/engine/rrdenginelib.h
+1
-1
@@ -53,7 +53,7 @@ static inline void modify_bit(unsigned *x, unsigned pos, uint8_t val)
53
*x |= 1U << pos;
54
break;
55
default:
56
- error("modify_bit() called with invalid argument.");
56
+ netdata_log_error("modify_bit() called with invalid argument.");
57
break;
58
}
59
}
database/ram/rrddim_mem.c
+4
-4
@@ -283,7 +283,7 @@ static inline size_t rrddim_time2slot(STORAGE_METRIC_HANDLE *db_metric_handle, t
283
}
284
285
if(unlikely(ret >= entries)) {
286
- error("INTERNAL ERROR: rrddim_time2slot() on %s returns values outside entries", rrddim_name(rd));
286
+ netdata_log_error("INTERNAL ERROR: rrddim_time2slot() on %s returns values outside entries", rrddim_name(rd));
287
ret = entries - 1;
288
}
289
@@ -304,7 +304,7 @@ static inline time_t rrddim_slot2time(STORAGE_METRIC_HANDLE *db_metric_handle, s
304
size_t update_every = mh->update_every_s;
305
306
if(slot >= entries) {
307
- error("INTERNAL ERROR: caller of rrddim_slot2time() gives invalid slot %zu", slot);
307
+ netdata_log_error("INTERNAL ERROR: caller of rrddim_slot2time() gives invalid slot %zu", slot);
308
slot = entries - 1;
309
}
310
@@ -314,14 +314,14 @@ static inline time_t rrddim_slot2time(STORAGE_METRIC_HANDLE *db_metric_handle, s
314
ret = last_entry_s - (time_t)(update_every * (last_slot - slot));
315
316
if(unlikely(ret < first_entry_s)) {
317
- error("INTERNAL ERROR: rrddim_slot2time() on dimension '%s' of chart '%s' returned time (%ld) too far in the past (before first_entry_s %ld) for slot %zu",
317
+ netdata_log_error("INTERNAL ERROR: rrddim_slot2time() on dimension '%s' of chart '%s' returned time (%ld) too far in the past (before first_entry_s %ld) for slot %zu",
318
rrddim_name(rd), rrdset_id(rd->rrdset), ret, first_entry_s, slot);
319
320
ret = first_entry_s;
321
}
322
323
if(unlikely(ret > last_entry_s)) {
324
- error("INTERNAL ERROR: rrddim_slot2time() on dimension '%s' of chart '%s' returned time (%ld) too far into the future (after last_entry_s %ld) for slot %zu",
324
+ netdata_log_error("INTERNAL ERROR: rrddim_slot2time() on dimension '%s' of chart '%s' returned time (%ld) too far into the future (after last_entry_s %ld) for slot %zu",
325
rrddim_name(rd), rrdset_id(rd->rrdset), ret, last_entry_s, slot);
326
327
ret = last_entry_s;
database/rrd.c
+1
-1
@@ -148,7 +148,7 @@ char *rrdhost_cache_dir_for_rrdset_alloc(RRDHOST *host, const char *id) {
148
if(host->rrd_memory_mode == RRD_MEMORY_MODE_MAP || host->rrd_memory_mode == RRD_MEMORY_MODE_SAVE) {
149
int r = mkdir(ret, 0775);
150
if(r != 0 && errno != EEXIST)
151
- error("Cannot create directory '%s'", ret);
151
+ netdata_log_error("Cannot create directory '%s'", ret);
152
}
153
154
return ret;
database/rrdcalc.c
+12
-12
@@ -56,7 +56,7 @@ inline const char *rrdcalc_status2string(RRDCALC_STATUS status) {
56
return "CRITICAL";
57
58
default:
59
- error("Unknown alarm status %d", status);
59
+ netdata_log_error("Unknown alarm status %d", status);
60
return "UNKNOWN";
61
}
62
}
@@ -217,7 +217,7 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) {
217
netdata_rwlock_unlock(&st->alerts.rwlock);
218
219
if(rc->update_every < rc->rrdset->update_every) {
220
- error("Health alarm '%s.%s' has update every %d, less than chart update every %d. Setting alarm update frequency to %d.", rrdset_id(rc->rrdset), rrdcalc_name(rc), rc->update_every, rc->rrdset->update_every, rc->rrdset->update_every);
220
+ netdata_log_error("Health alarm '%s.%s' has update every %d, less than chart update every %d. Setting alarm update frequency to %d.", rrdset_id(rc->rrdset), rrdcalc_name(rc), rc->update_every, rc->rrdset->update_every, rc->rrdset->update_every);
221
rc->update_every = rc->rrdset->update_every;
222
}
223
@@ -318,7 +318,7 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
318
319
if(!st) {
320
debug(D_HEALTH, "Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc));
321
- error("Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc));
321
+ netdata_log_error("Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc));
322
return;
323
}
324
@@ -512,17 +512,17 @@ static void rrdcalc_rrdhost_insert_callback(const DICTIONARY_ITEM *item __maybe_
512
if(rt->calculation) {
513
rc->calculation = expression_parse(rt->calculation->source, NULL, NULL);
514
if(!rc->calculation)
515
- error("Health alarm '%s.%s': failed to parse calculation expression '%s'", rrdset_id(st), rrdcalctemplate_name(rt), rt->calculation->source);
515
+ netdata_log_error("Health alarm '%s.%s': failed to parse calculation expression '%s'", rrdset_id(st), rrdcalctemplate_name(rt), rt->calculation->source);
516
}
517
if(rt->warning) {
518
rc->warning = expression_parse(rt->warning->source, NULL, NULL);
519
if(!rc->warning)
520
- error("Health alarm '%s.%s': failed to re-parse warning expression '%s'", rrdset_id(st), rrdcalctemplate_name(rt), rt->warning->source);
520
+ netdata_log_error("Health alarm '%s.%s': failed to re-parse warning expression '%s'", rrdset_id(st), rrdcalctemplate_name(rt), rt->warning->source);
521
}
522
if(rt->critical) {
523
rc->critical = expression_parse(rt->critical->source, NULL, NULL);
524
if(!rc->critical)
525
- error("Health alarm '%s.%s': failed to re-parse critical expression '%s'", rrdset_id(st), rrdcalctemplate_name(rt), rt->critical->source);
525
+ netdata_log_error("Health alarm '%s.%s': failed to re-parse critical expression '%s'", rrdset_id(st), rrdcalctemplate_name(rt), rt->critical->source);
526
}
527
}
528
else if(ctr->from_config) {
@@ -703,23 +703,23 @@ void rrdcalc_add_from_rrdcalctemplate(RRDHOST *host, RRDCALCTEMPLATE *rt, RRDSET
703
704
dictionary_set_advanced(host->rrdcalc_root_index, key, (ssize_t)(key_len + 1), NULL, sizeof(RRDCALC), &tmp);
705
if(tmp.react_action != RRDCALC_REACT_NEW && tmp.existing_from_template == false)
706
- error("RRDCALC: from template '%s' on chart '%s' with key '%s', failed to be added to host '%s'. It is manually configured.",
706
+ netdata_log_error("RRDCALC: from template '%s' on chart '%s' with key '%s', failed to be added to host '%s'. It is manually configured.",
707
string2str(rt->name), rrdset_id(st), key, rrdhost_hostname(host));
708
}
709
710
int rrdcalc_add_from_config(RRDHOST *host, RRDCALC *rc) {
711
if(!rc->chart) {
712
- error("Health configuration for alarm '%s' does not have a chart", rrdcalc_name(rc));
712
+ netdata_log_error("Health configuration for alarm '%s' does not have a chart", rrdcalc_name(rc));
713
return 0;
714
}
715
716
if(!rc->update_every) {
717
- error("Health configuration for alarm '%s.%s' has no frequency (parameter 'every'). Ignoring it.", rrdcalc_chart_name(rc), rrdcalc_name(rc));
717
+ netdata_log_error("Health configuration for alarm '%s.%s' has no frequency (parameter 'every'). Ignoring it.", rrdcalc_chart_name(rc), rrdcalc_name(rc));
718
return 0;
719
}
720
721
if(!RRDCALC_HAS_DB_LOOKUP(rc) && !rc->calculation && !rc->warning && !rc->critical) {
722
- error("Health configuration for alarm '%s.%s' is useless (no db lookup, no calculation, no warning and no critical expressions)", rrdcalc_chart_name(rc), rrdcalc_name(rc));
722
+ netdata_log_error("Health configuration for alarm '%s.%s' is useless (no db lookup, no calculation, no warning and no critical expressions)", rrdcalc_chart_name(rc), rrdcalc_name(rc));
723
return 0;
724
}
725
@@ -750,7 +750,7 @@ int rrdcalc_add_from_config(RRDHOST *host, RRDCALC *rc) {
750
rrdset_foreach_done(st);
751
}
752
else {
753
- error(
753
+ netdata_log_error(
754
"RRDCALC: from config '%s' on chart '%s' failed to be added to host '%s'. It already exists.",
755
string2str(rc->name),
756
string2str(rc->chart),
@@ -811,7 +811,7 @@ void rrdcalc_unlink_all_rrdset_alerts(RRDSET *st) {
811
netdata_rwlock_wrlock(&st->alerts.rwlock);
812
while((rc = st->alerts.base)) {
813
if(last == rc) {
814
- error("RRDCALC: malformed list of alerts linked to chart - cannot cleanup - giving up.");
814
+ netdata_log_error("RRDCALC: malformed list of alerts linked to chart - cannot cleanup - giving up.");
815
break;
816
}
817
last = rc;
database/rrdcalctemplate.c
+3
-3
@@ -223,17 +223,17 @@ static size_t rrdcalctemplate_key(char *dst, size_t dst_len, const char *name, c
223
224
void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt) {
225
if(unlikely(!rt->context)) {
226
- error("Health configuration for template '%s' does not have a context", rrdcalctemplate_name(rt));
226
+ netdata_log_error("Health configuration for template '%s' does not have a context", rrdcalctemplate_name(rt));
227
return;
228
}
229
230
if(unlikely(!rt->update_every)) {
231
- error("Health configuration for template '%s' has no frequency (parameter 'every'). Ignoring it.", rrdcalctemplate_name(rt));
231
+ netdata_log_error("Health configuration for template '%s' has no frequency (parameter 'every'). Ignoring it.", rrdcalctemplate_name(rt));
232
return;
233
}
234
235
if(unlikely(!RRDCALCTEMPLATE_HAS_DB_LOOKUP(rt) && !rt->calculation && !rt->warning && !rt->critical)) {
236
- error("Health configuration for template '%s' is useless (no calculation, no warning and no critical evaluation)", rrdcalctemplate_name(rt));
236
+ netdata_log_error("Health configuration for template '%s' is useless (no calculation, no warning and no critical evaluation)", rrdcalctemplate_name(rt));
237
return;
238
}
239
database/rrddim.c
+8
-8
@@ -102,10 +102,10 @@ static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
102
}
103
104
if(!initialized)
105
- error("Failed to initialize all db tiers for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
105
+ netdata_log_error("Failed to initialize all db tiers for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
106
107
if(!rd->tiers[0].db_metric_handle)
108
- error("Failed to initialize the first db tier for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
108
+ netdata_log_error("Failed to initialize the first db tier for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
109
}
110
111
// initialize data collection for all tiers
@@ -120,7 +120,7 @@ static void rrddim_insert_callback(const DICTIONARY_ITEM *item __maybe_unused, v
120
}
121
122
if(!initialized)
123
- error("Failed to initialize data collection for all db tiers for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
123
+ netdata_log_error("Failed to initialize data collection for all db tiers for chart '%s', dimension '%s", rrdset_name(st), rrddim_name(rd));
124
}
125
126
if(rrdset_number_of_dimensions(st) != 0) {
@@ -499,7 +499,7 @@ int rrddim_hide(RRDSET *st, const char *id) {
499
500
RRDDIM *rd = rrddim_find(st, id);
501
if(unlikely(!rd)) {
502
- error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, rrdset_name(st), rrdset_id(st), rrdhost_hostname(host));
502
+ netdata_log_error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, rrdset_name(st), rrdset_id(st), rrdhost_hostname(host));
503
return 1;
504
}
505
if (!rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
@@ -518,7 +518,7 @@ int rrddim_unhide(RRDSET *st, const char *id) {
518
RRDHOST *host = st->rrdhost;
519
RRDDIM *rd = rrddim_find(st, id);
520
if(unlikely(!rd)) {
521
- error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, rrdset_name(st), rrdset_id(st), rrdhost_hostname(host));
521
+ netdata_log_error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, rrdset_name(st), rrdset_id(st), rrdhost_hostname(host));
522
return 1;
523
}
524
if (rrddim_flag_check(rd, RRDDIM_FLAG_META_HIDDEN)) {
@@ -582,7 +582,7 @@ collected_number rrddim_set(RRDSET *st, const char *id, collected_number value)
582
RRDHOST *host = st->rrdhost;
583
RRDDIM *rd = rrddim_find(st, id);
584
if(unlikely(!rd)) {
585
- error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, rrdset_name(st), rrdset_id(st), rrdhost_hostname(host));
585
+ netdata_log_error("Cannot find dimension with id '%s' on stats '%s' (%s) on host '%s'.", id, rrdset_name(st), rrdset_id(st), rrdhost_hostname(host));
586
return 0;
587
}
588
@@ -711,12 +711,12 @@ bool rrddim_memory_load_or_create_map_save(RRDSET *st, RRDDIM *rd, RRD_MEMORY_MO
711
reset = 1;
712
}
713
else if(rd_on_file->memsize != size) {
714
- error("File %s does not have the desired size, expected %lu but found %lu. Clearing it.", fullfilename, size, (unsigned long int) rd_on_file->memsize);
714
+ netdata_log_error("File %s does not have the desired size, expected %lu but found %lu. Clearing it.", fullfilename, size, (unsigned long int) rd_on_file->memsize);
715
memset(rd_on_file, 0, size);
716
reset = 1;
717
}
718
else if(rd_on_file->update_every != st->update_every) {
719
- error("File %s does not have the same update frequency, expected %d but found %d. Clearing it.", fullfilename, st->update_every, rd_on_file->update_every);
719
+ netdata_log_error("File %s does not have the same update frequency, expected %d but found %d. Clearing it.", fullfilename, st->update_every, rd_on_file->update_every);
720
memset(rd_on_file, 0, size);
721
reset = 1;
722
}
database/rrdhost.c
+60
-39
@@ -116,7 +116,8 @@ static inline RRDHOST *rrdhost_index_add_by_guid(RRDHOST *host) {
116
rrdhost_option_set(host, RRDHOST_OPTION_INDEXED_MACHINE_GUID);
117
else {
118
rrdhost_option_clear(host, RRDHOST_OPTION_INDEXED_MACHINE_GUID);
119
- error("RRDHOST: %s() host with machine guid '%s' is already indexed", __FUNCTION__, host->machine_guid);
119
+ netdata_log_error("RRDHOST: %s() host with machine guid '%s' is already indexed",
120
+ __FUNCTION__, host->machine_guid);
121
}
122
123
return host;
@@ -125,7 +126,8 @@ static inline RRDHOST *rrdhost_index_add_by_guid(RRDHOST *host) {
126
static void rrdhost_index_del_by_guid(RRDHOST *host) {
127
if(rrdhost_option_check(host, RRDHOST_OPTION_INDEXED_MACHINE_GUID)) {
128
if(!dictionary_del(rrdhost_root_index, host->machine_guid))
128
- error("RRDHOST: %s() failed to delete machine guid '%s' from index", __FUNCTION__, host->machine_guid);
129
+ netdata_log_error("RRDHOST: %s() failed to delete machine guid '%s' from index",
130
+ __FUNCTION__, host->machine_guid);
131
132
rrdhost_option_clear(host, RRDHOST_OPTION_INDEXED_MACHINE_GUID);
133
}
@@ -146,7 +148,8 @@ static inline void rrdhost_index_del_hostname(RRDHOST *host) {
148
149
if(rrdhost_option_check(host, RRDHOST_OPTION_INDEXED_HOSTNAME)) {
150
if(!dictionary_del(rrdhost_root_index_hostname, rrdhost_hostname(host)))
149
- error("RRDHOST: %s() failed to delete hostname '%s' from index", __FUNCTION__, rrdhost_hostname(host));
151
+ netdata_log_error("RRDHOST: %s() failed to delete hostname '%s' from index",
152
+ __FUNCTION__, rrdhost_hostname(host));
153
154
rrdhost_option_clear(host, RRDHOST_OPTION_INDEXED_HOSTNAME);
155
}
@@ -303,7 +306,8 @@ static RRDHOST *rrdhost_create(
306
debug(D_RRDHOST, "Host '%s': adding with guid '%s'", hostname, guid);
307
308
if(memory_mode == RRD_MEMORY_MODE_DBENGINE && !dbengine_enabled) {
306
- error("memory mode 'dbengine' is not enabled, but host '%s' is configured for it. Falling back to 'alloc'", hostname);
309
+ netdata_log_error("memory mode 'dbengine' is not enabled, but host '%s' is configured for it. Falling back to 'alloc'",
310
+ hostname);
311
memory_mode = RRD_MEMORY_MODE_ALLOC;
312
}
313
@@ -387,7 +391,7 @@ int is_legacy = 1;
391
(host->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE && is_legacy))) {
392
int r = mkdir(host->cache_dir, 0775);
393
if(r != 0 && errno != EEXIST)
390
- error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->cache_dir);
394
+ netdata_log_error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), host->cache_dir);
395
}
396
}
397
@@ -413,7 +417,7 @@ int is_legacy = 1;
417
ret = mkdir(dbenginepath, 0775);
418
419
if (ret != 0 && errno != EEXIST)
416
- error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), dbenginepath);
420
+ netdata_log_error("Host '%s': cannot create directory '%s'", rrdhost_hostname(host), dbenginepath);
421
else
422
ret = 0; // succeed
423
@@ -454,9 +458,8 @@ int is_legacy = 1;
458
}
459
460
if (ret) { // check legacy or multihost initialization success
457
- error(
458
- "Host '%s': cannot initialize host with machine guid '%s'. Failed to initialize DB engine at '%s'.",
459
- rrdhost_hostname(host), host->machine_guid, host->cache_dir);
461
+ netdata_log_error("Host '%s': cannot initialize host with machine guid '%s'. Failed to initialize DB engine at '%s'.",
462
+ rrdhost_hostname(host), host->machine_guid, host->cache_dir);
463
464
rrd_wrlock();
465
rrdhost_free___while_having_rrd_wrlock(host, true);
@@ -504,7 +507,8 @@ int is_legacy = 1;
507
508
RRDHOST *t = rrdhost_index_add_by_guid(host);
509
if(t != host) {
507
- error("Host '%s': cannot add host with machine guid '%s' to index. It already exists as host '%s' with machine guid '%s'.", rrdhost_hostname(host), host->machine_guid, rrdhost_hostname(t), t->machine_guid);
510
+ netdata_log_error("Host '%s': cannot add host with machine guid '%s' to index. It already exists as host '%s' with machine guid '%s'.",
511
+ rrdhost_hostname(host), host->machine_guid, rrdhost_hostname(t), t->machine_guid);
512
rrdhost_free___while_having_rrd_wrlock(host, true);
513
rrd_unlock();
514
return NULL;
@@ -633,19 +637,23 @@ static void rrdhost_update(RRDHOST *host
637
}
638
639
if(host->rrd_update_every != update_every)
636
- error("Host '%s' has an update frequency of %d seconds, but the wanted one is %d seconds. "
637
- "Restart netdata here to apply the new settings.",
638
- rrdhost_hostname(host), host->rrd_update_every, update_every);
640
+ netdata_log_error("Host '%s' has an update frequency of %d seconds, but the wanted one is %d seconds. "
641
+ "Restart netdata here to apply the new settings.",
642
+ rrdhost_hostname(host), host->rrd_update_every, update_every);
643
644
if(host->rrd_memory_mode != mode)
641
- error("Host '%s' has memory mode '%s', but the wanted one is '%s'. "
642
- "Restart netdata here to apply the new settings.",
643
- rrdhost_hostname(host), rrd_memory_mode_name(host->rrd_memory_mode), rrd_memory_mode_name(mode));
645
+ netdata_log_error("Host '%s' has memory mode '%s', but the wanted one is '%s'. "
646
+ "Restart netdata here to apply the new settings.",
647
+ rrdhost_hostname(host),
648
+ rrd_memory_mode_name(host->rrd_memory_mode),
649
+ rrd_memory_mode_name(mode));
650
651
else if(host->rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE && host->rrd_history_entries < history)
646
- error("Host '%s' has history of %d entries, but the wanted one is %ld entries. "
647
- "Restart netdata here to apply the new settings.",
648
- rrdhost_hostname(host), host->rrd_history_entries, history);
652
+ netdata_log_error("Host '%s' has history of %d entries, but the wanted one is %ld entries. "
653
+ "Restart netdata here to apply the new settings.",
654
+ rrdhost_hostname(host),
655
+ host->rrd_history_entries,
656
+ history);
657
658
// update host tags
659
rrdhost_init_tags(host, tags);
@@ -725,8 +733,10 @@ RRDHOST *rrdhost_find_or_create(
733
return host;
734
735
/* If a legacy memory mode instantiates all dbengine state must be discarded to avoid inconsistencies */
728
- error("Archived host '%s' has memory mode '%s', but the wanted one is '%s'. Discarding archived state.",
729
- rrdhost_hostname(host), rrd_memory_mode_name(host->rrd_memory_mode), rrd_memory_mode_name(mode));
736
+ netdata_log_error("Archived host '%s' has memory mode '%s', but the wanted one is '%s'. Discarding archived state.",
737
+ rrdhost_hostname(host),
738
+ rrd_memory_mode_name(host->rrd_memory_mode),
739
+ rrd_memory_mode_name(mode));
740
741
rrd_wrlock();
742
rrdhost_free___while_having_rrd_wrlock(host, true);
@@ -834,18 +844,18 @@ void dbengine_init(char *hostname) {
844
if (read_num > 0 && read_num <= MAX_PAGES_PER_EXTENT)
845
rrdeng_pages_per_extent = read_num;
846
else {
837
- error("Invalid dbengine pages per extent %u given. Using %u.", read_num, rrdeng_pages_per_extent);
847
+ netdata_log_error("Invalid dbengine pages per extent %u given. Using %u.", read_num, rrdeng_pages_per_extent);
848
config_set_number(CONFIG_SECTION_DB, "dbengine pages per extent", rrdeng_pages_per_extent);
849
}
850
851
storage_tiers = config_get_number(CONFIG_SECTION_DB, "storage tiers", storage_tiers);
852
if(storage_tiers < 1) {
843
- error("At least 1 storage tier is required. Assuming 1.");
853
+ netdata_log_error("At least 1 storage tier is required. Assuming 1.");
854
storage_tiers = 1;
855
config_set_number(CONFIG_SECTION_DB, "storage tiers", storage_tiers);
856
}
857
if(storage_tiers > RRD_STORAGE_TIERS) {
848
- error("Up to %d storage tier are supported. Assuming %d.", RRD_STORAGE_TIERS, RRD_STORAGE_TIERS);
858
+ netdata_log_error("Up to %d storage tier are supported. Assuming %d.", RRD_STORAGE_TIERS, RRD_STORAGE_TIERS);
859
storage_tiers = RRD_STORAGE_TIERS;
860
config_set_number(CONFIG_SECTION_DB, "storage tiers", storage_tiers);
861
}
@@ -867,7 +877,7 @@ void dbengine_init(char *hostname) {
877
878
int ret = mkdir(dbenginepath, 0775);
879
if (ret != 0 && errno != EEXIST) {
870
- error("DBENGINE on '%s': cannot create directory '%s'", hostname, dbenginepath);
880
+ netdata_log_error("DBENGINE on '%s': cannot create directory '%s'", hostname, dbenginepath);
881
break;
882
}
883
@@ -887,7 +897,9 @@ void dbengine_init(char *hostname) {
897
if(grouping_iterations < 2) {
898
grouping_iterations = 2;
899
config_set_number(CONFIG_SECTION_DB, dbengineconfig, grouping_iterations);
890
- error("DBENGINE on '%s': 'dbegnine tier %zu update every iterations' cannot be less than 2. Assuming 2.", hostname, tier);
900
+ netdata_log_error("DBENGINE on '%s': 'dbegnine tier %zu update every iterations' cannot be less than 2. Assuming 2.",
901
+ hostname,
902
+ tier);
903
}
904
905
snprintfz(dbengineconfig, 200, "dbengine tier %zu backfill", tier);
@@ -896,7 +908,7 @@ void dbengine_init(char *hostname) {
908
else if(strcmp(bf, "full") == 0) backfill = RRD_BACKFILL_FULL;
909
else if(strcmp(bf, "none") == 0) backfill = RRD_BACKFILL_NONE;
910
else {
899
- error("DBENGINE: unknown backfill value '%s', assuming 'new'", bf);
911
+ netdata_log_error("DBENGINE: unknown backfill value '%s', assuming 'new'", bf);
912
config_set(CONFIG_SECTION_DB, dbengineconfig, "new");
913
backfill = RRD_BACKFILL_NEW;
914
}
@@ -907,7 +919,10 @@ void dbengine_init(char *hostname) {
919
920
if(tier > 0 && get_tier_grouping(tier) > 65535) {
921
storage_tiers_grouping_iterations[tier] = 1;
910
- error("DBENGINE on '%s': dbengine tier %zu gives aggregation of more than 65535 points of tier 0. Disabling tiers above %zu", hostname, tier, tier);
922
+ netdata_log_error("DBENGINE on '%s': dbengine tier %zu gives aggregation of more than 65535 points of tier 0. Disabling tiers above %zu",
923
+ hostname,
924
+ tier,
925
+ tier);
926
break;
927
}
928
@@ -935,16 +950,21 @@ void dbengine_init(char *hostname) {
950
netdata_thread_join(tiers_init[tier].thread, &ptr);
951
952
if(tiers_init[tier].ret != 0) {
938
- error("DBENGINE on '%s': Failed to initialize multi-host database tier %zu on path '%s'",
939
- hostname, tiers_init[tier].tier, tiers_init[tier].path);
953
+ netdata_log_error("DBENGINE on '%s': Failed to initialize multi-host database tier %zu on path '%s'",
954
+ hostname,
955
+ tiers_init[tier].tier,
956
+ tiers_init[tier].path);
957
}
958
else if(created_tiers == tier)
959
created_tiers++;
960
}
961
962
if(created_tiers && created_tiers < storage_tiers) {
946
- error("DBENGINE on '%s': Managed to create %zu tiers instead of %zu. Continuing with %zu available.",
947
- hostname, created_tiers, storage_tiers, created_tiers);
963
+ netdata_log_error("DBENGINE on '%s': Managed to create %zu tiers instead of %zu. Continuing with %zu available.",
964
+ hostname,
965
+ created_tiers,
966
+ storage_tiers,
967
+ created_tiers);
968
storage_tiers = created_tiers;
969
}
970
else if(!created_tiers)
@@ -957,7 +977,7 @@ void dbengine_init(char *hostname) {
977
#else
978
storage_tiers = config_get_number(CONFIG_SECTION_DB, "storage tiers", 1);
979
if(storage_tiers != 1) {
960
- error("DBENGINE is not available on '%s', so only 1 database tier can be supported.", hostname);
980
+ netdata_log_error("DBENGINE is not available on '%s', so only 1 database tier can be supported.", hostname);
981
storage_tiers = 1;
982
config_set_number(CONFIG_SECTION_DB, "storage tiers", storage_tiers);
983
}
@@ -998,13 +1018,13 @@ int rrd_init(char *hostname, struct rrdhost_system_info *system_info, bool unitt
1018
1019
if (!dbengine_enabled) {
1020
if (storage_tiers > 1) {
1001
- error("dbengine is not enabled, but %zu tiers have been requested. Resetting tiers to 1",
1002
- storage_tiers);
1021
+ netdata_log_error("dbengine is not enabled, but %zu tiers have been requested. Resetting tiers to 1",
1022
+ storage_tiers);
1023
storage_tiers = 1;
1024
}
1025
1026
if (default_rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
1007
- error("dbengine is not enabled, but it has been given as the default db mode. Resetting db mode to alloc");
1027
+ netdata_log_error("dbengine is not enabled, but it has been given as the default db mode. Resetting db mode to alloc");
1028
default_rrd_memory_mode = RRD_MEMORY_MODE_ALLOC;
1029
}
1030
}
@@ -1412,7 +1432,7 @@ static void rrdhost_load_config_labels(void) {
1432
int status = config_load(NULL, 1, CONFIG_SECTION_HOST_LABEL);
1433
if(!status) {
1434
char *filename = CONFIG_DIR "/" CONFIG_FILENAME;
1415
- error("RRDLABEL: Cannot reload the configuration file '%s', using labels in memory", filename);
1435
+ netdata_log_error("RRDLABEL: Cannot reload the configuration file '%s', using labels in memory", filename);
1436
}
1437
1438
struct section *co = appconfig_get_section(&netdata_config, CONFIG_SECTION_HOST_LABEL);
@@ -1432,7 +1452,7 @@ static void rrdhost_load_kubernetes_labels(void) {
1452
sprintf(label_script, "%s/%s", netdata_configured_primary_plugins_dir, "get-kubernetes-labels.sh");
1453
1454
if (unlikely(access(label_script, R_OK) != 0)) {
1435
- error("Kubernetes pod label fetching script %s not found.",label_script);
1455
+ netdata_log_error("Kubernetes pod label fetching script %s not found.",label_script);
1456
return;
1457
}
1458
@@ -1450,7 +1470,8 @@ static void rrdhost_load_kubernetes_labels(void) {
1470
// Non-zero exit code means that all the script output is error messages. We've shown already any message that didn't include a ':'
1471
// Here we'll inform with an ERROR that the script failed, show whatever (if anything) was added to the list of labels, free the memory and set the return to null
1472
int rc = netdata_pclose(fp_child_input, fp_child_output, pid);
1453
- if(rc) error("%s exited abnormally. Failed to get kubernetes labels.", label_script);
1473
+ if(rc)
1474
+ netdata_log_error("%s exited abnormally. Failed to get kubernetes labels.", label_script);
1475
}
1476
1477
void reload_host_labels(void) {
database/rrdlabels.c
+3
-3
@@ -571,7 +571,7 @@ static void labels_add_already_sanitized(DICTIONARY *dict, const char *key, cons
571
572
void rrdlabels_add(DICTIONARY *dict, const char *name, const char *value, RRDLABEL_SRC ls) {
573
if(!dict) {
574
- error("%s(): called with NULL dictionary.", __FUNCTION__ );
574
+ netdata_log_error("%s(): called with NULL dictionary.", __FUNCTION__ );
575
return;
576
}
577
@@ -580,7 +580,7 @@ void rrdlabels_add(DICTIONARY *dict, const char *name, const char *value, RRDLAB
580
rrdlabels_sanitize_value(v, value, RRDLABELS_MAX_VALUE_LENGTH);
581
582
if(!*n) {
583
- error("%s: cannot add name '%s' (value '%s') which is sanitized as empty string", __FUNCTION__, name, value);
583
+ netdata_log_error("%s: cannot add name '%s' (value '%s') which is sanitized as empty string", __FUNCTION__, name, value);
584
return;
585
}
586
@@ -621,7 +621,7 @@ static const char *get_quoted_string_up_to(char *dst, size_t dst_size, const cha
621
622
void rrdlabels_add_pair(DICTIONARY *dict, const char *string, RRDLABEL_SRC ls) {
623
if(!dict) {
624
- error("%s(): called with NULL dictionary.", __FUNCTION__ );
624
+ netdata_log_error("%s(): called with NULL dictionary.", __FUNCTION__ );
625
return;
626
}
627
database/rrdset.c
+10
-10
@@ -842,10 +842,10 @@ void rrdset_delete_files(RRDSET *st) {
842
if(cache_filename) {
843
netdata_log_info("Deleting chart header file '%s'.", cache_filename);
844
if (unlikely(unlink(cache_filename) == -1))
845
- error("Cannot delete chart header file '%s'", cache_filename);
845
+ netdata_log_error("Cannot delete chart header file '%s'", cache_filename);
846
}
847
else
848
- error("Cannot find the cache filename of chart '%s'", rrdset_id(st));
848
+ netdata_log_error("Cannot find the cache filename of chart '%s'", rrdset_id(st));
849
}
850
851
rrddim_foreach_read(rd, st) {
@@ -854,7 +854,7 @@ void rrdset_delete_files(RRDSET *st) {
854
855
netdata_log_info("Deleting dimension file '%s'.", cache_filename);
856
if(unlikely(unlink(cache_filename) == -1))
857
- error("Cannot delete dimension file '%s'", cache_filename);
857
+ netdata_log_error("Cannot delete dimension file '%s'", cache_filename);
858
}
859
rrddim_foreach_done(rd);
860
@@ -873,7 +873,7 @@ void rrdset_delete_obsolete_dimensions(RRDSET *st) {
873
if(!cache_filename) continue;
874
netdata_log_info("Deleting dimension file '%s'.", cache_filename);
875
if(unlikely(unlink(cache_filename) == -1))
876
- error("Cannot delete dimension file '%s'", cache_filename);
876
+ netdata_log_error("Cannot delete dimension file '%s'", cache_filename);
877
}
878
}
879
rrddim_foreach_done(rd);
@@ -1538,7 +1538,7 @@ void rrdset_timed_done(RRDSET *st, struct timeval now, bool pending_rrdset_next)
1538
}
1539
1540
if (unlikely(rrdset_flags & RRDSET_FLAG_OBSOLETE)) {
1541
- error("Chart '%s' has the OBSOLETE flag set, but it is collected.", rrdset_id(st));
1541
+ netdata_log_error("Chart '%s' has the OBSOLETE flag set, but it is collected.", rrdset_id(st));
1542
rrdset_isnot_obsolete(st);
1543
}
1544
@@ -1685,7 +1685,7 @@ void rrdset_timed_done(RRDSET *st, struct timeval now, bool pending_rrdset_next)
1685
collected_total += rd->collector.collected_value;
1686
1687
if(unlikely(rrddim_flag_check(rd, RRDDIM_FLAG_OBSOLETE))) {
1688
- error("Dimension %s in chart '%s' has the OBSOLETE flag set, but it is collected.", rrddim_name(rd), rrdset_id(st));
1688
+ netdata_log_error("Dimension %s in chart '%s' has the OBSOLETE flag set, but it is collected.", rrddim_name(rd), rrdset_id(st));
1689
rrddim_isnot_obsolete(st, rd);
1690
}
1691
}
@@ -2166,15 +2166,15 @@ bool rrdset_memory_load_or_create_map_save(RRDSET *st, RRD_MEMORY_MODE memory_mo
2166
memset(st_on_file, 0, size);
2167
}
2168
else if(strncmp(st_on_file->id, rrdset_id(st), RRD_ID_LENGTH_MAX_V019) != 0) {
2169
- error("File '%s' contents are not for chart '%s'. Clearing it.", fullfilename, rrdset_id(st));
2169
+ netdata_log_error("File '%s' contents are not for chart '%s'. Clearing it.", fullfilename, rrdset_id(st));
2170
memset(st_on_file, 0, size);
2171
}
2172
else if(st_on_file->memsize != size || st_on_file->entries != st->db.entries) {
2173
- error("File '%s' does not have the desired size. Clearing it.", fullfilename);
2173
+ netdata_log_error("File '%s' does not have the desired size. Clearing it.", fullfilename);
2174
memset(st_on_file, 0, size);
2175
}
2176
else if(st_on_file->update_every != st->update_every) {
2177
- error("File '%s' does not have the desired granularity. Clearing it.", fullfilename);
2177
+ netdata_log_error("File '%s' does not have the desired granularity. Clearing it.", fullfilename);
2178
memset(st_on_file, 0, size);
2179
}
2180
else if((now_s - st_on_file->last_updated.tv_sec) > (long)st->update_every * (long)st->db.entries) {
@@ -2182,7 +2182,7 @@ bool rrdset_memory_load_or_create_map_save(RRDSET *st, RRD_MEMORY_MODE memory_mo
2182
memset(st_on_file, 0, size);
2183
}
2184
else if(st_on_file->last_updated.tv_sec > now_s + st->update_every) {
2185
- error("File '%s' refers to the future by %zd secs. Resetting it to now.", fullfilename, (ssize_t)(st_on_file->last_updated.tv_sec - now_s));
2185
+ netdata_log_error("File '%s' refers to the future by %zd secs. Resetting it to now.", fullfilename, (ssize_t)(st_on_file->last_updated.tv_sec - now_s));
2186
st_on_file->last_updated.tv_sec = now_s;
2187
}
2188
database/rrdsetvar.c
+7
-2
@@ -262,8 +262,13 @@ void rrdsetvar_custom_chart_variable_set(RRDSET *st, const RRDSETVAR_ACQUIRED *r
262
RRDSETVAR *rs = dictionary_acquired_item_value((const DICTIONARY_ITEM *)rsa);
263
264
if(rs->type != RRDVAR_TYPE_CALCULATED || !(rs->flags & RRDVAR_FLAG_CUSTOM_CHART_VAR) || !(rs->flags & RRDVAR_FLAG_ALLOCATED)) {
265
- error("RRDSETVAR: requested to set variable '%s' of chart '%s' on host '%s' to value " NETDATA_DOUBLE_FORMAT
266
- " but the variable is not a custom chart one (it has options 0x%x, value pointer %p). Ignoring request.", string2str(rs->name), rrdset_id(st), rrdhost_hostname(st->rrdhost), value, (uint32_t)rs->flags, rs->value);
265
+ netdata_log_error("RRDSETVAR: requested to set variable '%s' of chart '%s' on host '%s' to value " NETDATA_DOUBLE_FORMAT
266
+ " but the variable is not a custom chart one (it has options 0x%x, value pointer %p). Ignoring request.",
267
+ string2str(rs->name),
268
+ rrdset_id(st),
269
+ rrdhost_hostname(st->rrdhost),
270
+ value,
271
+ (uint32_t)rs->flags, rs->value);
272
}
273
else {
274
NETDATA_DOUBLE *v = rs->value;
database/rrdvar.c
+2
-2
@@ -175,7 +175,7 @@ void rrdvar_custom_host_variable_set(RRDHOST *host, const RRDVAR_ACQUIRED *rva,
175
if(unlikely(!host->rrdvars || !rva)) return; // when health is not enabled
176
177
if(rrdvar_type(rva) != RRDVAR_TYPE_CALCULATED || !(rrdvar_flags(rva) & (RRDVAR_FLAG_CUSTOM_HOST_VAR | RRDVAR_FLAG_ALLOCATED)))
178
- error("requested to set variable '%s' to value " NETDATA_DOUBLE_FORMAT " but the variable is not a custom one.", rrdvar_name(rva), value);
178
+ netdata_log_error("requested to set variable '%s' to value " NETDATA_DOUBLE_FORMAT " but the variable is not a custom one.", rrdvar_name(rva), value);
179
else {
180
RRDVAR *rv = dictionary_acquired_item_value((const DICTIONARY_ITEM *)rva);
181
NETDATA_DOUBLE *v = rv->value;
@@ -228,7 +228,7 @@ NETDATA_DOUBLE rrdvar2number(const RRDVAR_ACQUIRED *rva) {
228
}
229
230
default:
231
- error("I don't know how to convert RRDVAR type %u to NETDATA_DOUBLE", rv->type);
231
+ netdata_log_error("I don't know how to convert RRDVAR type %u to NETDATA_DOUBLE", rv->type);
232
return NAN;
233
}
234
}
database/sqlite/sqlite_aclk.c
+1
-1
@@ -257,7 +257,7 @@ static void sql_delete_aclk_table_list(char *host_guid)
257
258
rc = db_execute(db_meta, buffer_tostring(sql));
259
if (unlikely(rc))
260
- error("Failed to drop unused ACLK tables");
260
+ netdata_log_error("Failed to drop unused ACLK tables");
261
262
fail:
263
buffer_free(sql);
database/sqlite/sqlite_metadata.c
+4
-4
@@ -950,7 +950,7 @@ static void cleanup_finished_threads(struct host_context_load_thread *hclt, size
950
|| (wait && __atomic_load_n(&(hclt[index].busy), __ATOMIC_ACQUIRE))) {
951
int rc = uv_thread_join(&(hclt[index].thread));
952
if (rc)
953
- error("Failed to join thread, rc = %d",rc);
953
+ netdata_log_error("Failed to join thread, rc = %d",rc);
954
__atomic_store_n(&(hclt[index].busy), false, __ATOMIC_RELEASE);
955
__atomic_store_n(&(hclt[index].finished), false, __ATOMIC_RELEASE);
956
}
@@ -1244,21 +1244,21 @@ static void metadata_event_loop(void *arg)
1244
loop = wc->loop = mallocz(sizeof(uv_loop_t));
1245
ret = uv_loop_init(loop);
1246
if (ret) {
1247
- error("uv_loop_init(): %s", uv_strerror(ret));
1247
+ netdata_log_error("uv_loop_init(): %s", uv_strerror(ret));
1248
goto error_after_loop_init;
1249
}
1250
loop->data = wc;
1251
1252
ret = uv_async_init(wc->loop, &wc->async, async_cb);
1253
if (ret) {
1254
- error("uv_async_init(): %s", uv_strerror(ret));
1254
+ netdata_log_error("uv_async_init(): %s", uv_strerror(ret));
1255
goto error_after_async_init;
1256
}
1257
wc->async.data = wc;
1258
1259
ret = uv_timer_init(loop, &wc->timer_req);
1260
if (ret) {
1261
- error("uv_timer_init(): %s", uv_strerror(ret));
1261
+ netdata_log_error("uv_timer_init(): %s", uv_strerror(ret));
1262
goto error_after_timer_init;
1263
}
1264
wc->timer_req.data = wc;
exporting/aws_kinesis/aws_kinesis.c
+8
-6
@@ -54,7 +54,8 @@ int init_aws_kinesis_instance(struct instance *instance)
54
55
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
56
if (!instance->buffer) {
57
- error("EXPORTING: cannot create buffer for AWS Kinesis exporting connector instance %s", instance->config.name);
57
+ netdata_log_error("EXPORTING: cannot create buffer for AWS Kinesis exporting connector instance %s",
58
+ instance->config.name);
59
return 1;
60
}
61
if (uv_mutex_init(&instance->mutex))
@@ -72,7 +73,7 @@ int init_aws_kinesis_instance(struct instance *instance)
73
instance->connector_specific_data = (void *)connector_specific_data;
74
75
if (!strcmp(connector_specific_config->stream_name, "")) {
75
- error("stream name is a mandatory Kinesis parameter but it is not configured");
76
+ netdata_log_error("stream name is a mandatory Kinesis parameter but it is not configured");
77
return 1;
78
}
79
@@ -174,10 +175,11 @@ void aws_kinesis_connector_worker(void *instance_p)
175
if (unlikely(kinesis_get_result(
176
connector_specific_data->request_outcomes, error_message, &sent_bytes, &lost_bytes))) {
177
// oops! we couldn't send (all or some of the) data
177
- error("EXPORTING: %s", error_message);
178
- error(
179
- "EXPORTING: failed to write data to external database '%s'. Willing to write %zu bytes, wrote %zu bytes.",
180
- instance->config.destination, sent_bytes, sent_bytes - lost_bytes);
178
+ netdata_log_error("EXPORTING: %s", error_message);
179
+ netdata_log_error("EXPORTING: failed to write data to external database '%s'. Willing to write %zu bytes, wrote %zu bytes.",
180
+ instance->config.destination,
181
+ sent_bytes,
182
+ sent_bytes - lost_bytes);
183
184
stats->transmission_failures++;
185
stats->data_lost_events++;
exporting/exporting_engine.c
+1
-1
@@ -183,7 +183,7 @@ void *exporting_main(void *ptr)
183
}
184
185
if (init_connectors(engine) != 0) {
186
- error("EXPORTING: cannot initialize exporting connectors");
186
+ netdata_log_error("EXPORTING: cannot initialize exporting connectors");
187
send_statistics("EXPORTING_START", "FAIL", "-");
188
goto cleanup;
189
}
exporting/exporting_engine.h
+1
-1
@@ -307,7 +307,7 @@ static inline void disable_instance(struct instance *instance)
307
instance->disabled = 1;
308
instance->scheduled = 0;
309
uv_mutex_unlock(&instance->mutex);
310
- error("EXPORTING: Instance %s disabled", instance->config.name);
310
+ netdata_log_error("EXPORTING: Instance %s disabled", instance->config.name);
311
}
312
313
#include "exporting/prometheus/prometheus.h"
exporting/graphite/graphite.c
+1
-1
@@ -49,7 +49,7 @@ int init_graphite_instance(struct instance *instance)
49
50
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
51
if (!instance->buffer) {
52
- error("EXPORTING: cannot create buffer for graphite exporting connector instance %s", instance->config.name);
52
+ netdata_log_error("EXPORTING: cannot create buffer for graphite exporting connector instance %s", instance->config.name);
53
return 1;
54
}
55
exporting/init_connectors.c
+6
-6
@@ -85,14 +85,14 @@ int init_connectors(struct engine *engine)
85
#endif
86
break;
87
default:
88
- error("EXPORTING: unknown exporting connector type");
88
+ netdata_log_error("EXPORTING: unknown exporting connector type");
89
return 1;
90
}
91
92
// dispatch the instance worker thread
93
int error = uv_thread_create(&instance->thread, instance->worker, instance);
94
if (error) {
95
- error("EXPORTING: cannot create thread worker. uv_thread_create(): %s", uv_strerror(error));
95
+ netdata_log_error("EXPORTING: cannot create thread worker. uv_thread_create(): %s", uv_strerror(error));
96
return 1;
97
}
98
char threadname[NETDATA_THREAD_NAME_MAX + 1];
@@ -113,7 +113,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu
113
"abcdefghijklmnopqrstuvwxyz"
114
"0123456789+/";
115
if ((input_size / 3 + 1) * 4 >= output_size) {
116
- error("Output buffer for encoding size=%zu is not large enough for %zu-bytes input", output_size, input_size);
116
+ netdata_log_error("Output buffer for encoding size=%zu is not large enough for %zu-bytes input", output_size, input_size);
117
return 0;
118
}
119
size_t count = 0;
@@ -123,7 +123,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu
123
output[1] = lookup[(value >> 12) & 0x3f];
124
output[2] = lookup[(value >> 6) & 0x3f];
125
output[3] = lookup[value & 0x3f];
126
- //error("Base-64 encode (%04x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]);
126
+ //netdata_log_error("Base-64 encode (%04x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]);
127
output += 4;
128
input += 3;
129
input_size -= 3;
@@ -136,7 +136,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu
136
output[1] = lookup[(value >> 6) & 0x3f];
137
output[2] = lookup[value & 0x3f];
138
output[3] = '=';
139
- //error("Base-64 encode (%06x) -> %c %c %c %c\n", (value>>2)&0xffff, output[0], output[1], output[2], output[3]);
139
+ //netdata_log_error("Base-64 encode (%06x) -> %c %c %c %c\n", (value>>2)&0xffff, output[0], output[1], output[2], output[3]);
140
count += 4;
141
output[4] = '\0';
142
break;
@@ -146,7 +146,7 @@ static size_t base64_encode(unsigned char *input, size_t input_size, char *outpu
146
output[1] = lookup[value & 0x3f];
147
output[2] = '=';
148
output[3] = '=';
149
- //error("Base-64 encode (%06x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]);
149
+ //netdata_log_error("Base-64 encode (%06x) -> %c %c %c %c\n", value, output[0], output[1], output[2], output[3]);
150
count += 4;
151
output[4] = '\0';
152
break;
exporting/json/json.c
+1
-1
@@ -39,7 +39,7 @@ int init_json_instance(struct instance *instance)
39
40
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
41
if (!instance->buffer) {
42
- error("EXPORTING: cannot create buffer for json exporting connector instance %s", instance->config.name);
42
+ netdata_log_error("EXPORTING: cannot create buffer for json exporting connector instance %s", instance->config.name);
43
return 1;
44
}
45
exporting/mongodb/mongodb.c
+13
-11
@@ -18,21 +18,22 @@ int mongodb_init(struct instance *instance)
18
bson_error_t bson_error;
19
20
if (unlikely(!connector_specific_config->collection || !*connector_specific_config->collection)) {
21
- error("EXPORTING: collection name is a mandatory MongoDB parameter, but it is not configured");
21
+ netdata_log_error("EXPORTING: collection name is a mandatory MongoDB parameter, but it is not configured");
22
return 1;
23
}
24
25
uri = mongoc_uri_new_with_error(instance->config.destination, &bson_error);
26
if (unlikely(!uri)) {
27
- error(
28
- "EXPORTING: failed to parse URI: %s. Error message: %s", instance->config.destination, bson_error.message);
27
+ netdata_log_error("EXPORTING: failed to parse URI: %s. Error message: %s",
28
+ instance->config.destination,
29
+ bson_error.message);
30
return 1;
31
}
32
33
int32_t socket_timeout =
34
mongoc_uri_get_option_as_int32(uri, MONGOC_URI_SOCKETTIMEOUTMS, instance->config.timeoutms);
35
if (!mongoc_uri_set_option_as_int32(uri, MONGOC_URI_SOCKETTIMEOUTMS, socket_timeout)) {
35
- error("EXPORTING: failed to set %s to the value %d", MONGOC_URI_SOCKETTIMEOUTMS, socket_timeout);
36
+ netdata_log_error("EXPORTING: failed to set %s to the value %d", MONGOC_URI_SOCKETTIMEOUTMS, socket_timeout);
37
return 1;
38
};
39
@@ -41,12 +42,12 @@ int mongodb_init(struct instance *instance)
42
43
connector_specific_data->client = mongoc_client_new_from_uri(uri);
44
if (unlikely(!connector_specific_data->client)) {
44
- error("EXPORTING: failed to create a new client");
45
+ netdata_log_error("EXPORTING: failed to create a new client");
46
return 1;
47
}
48
49
if (!mongoc_client_set_appname(connector_specific_data->client, "netdata")) {
49
- error("EXPORTING: failed to set client appname");
50
+ netdata_log_error("EXPORTING: failed to set client appname");
51
};
52
53
connector_specific_data->collection = mongoc_client_get_collection(
@@ -108,7 +109,8 @@ int init_mongodb_instance(struct instance *instance)
109
110
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
111
if (!instance->buffer) {
111
- error("EXPORTING: cannot create buffer for MongoDB exporting connector instance %s", instance->config.name);
112
+ netdata_log_error("EXPORTING: cannot create buffer for MongoDB exporting connector instance %s",
113
+ instance->config.name);
114
return 1;
115
}
116
if (uv_mutex_init(&instance->mutex))
@@ -128,7 +130,7 @@ int init_mongodb_instance(struct instance *instance)
130
}
131
132
if (unlikely(mongodb_init(instance))) {
131
- error("EXPORTING: cannot initialize MongoDB exporting connector");
133
+ netdata_log_error("EXPORTING: cannot initialize MongoDB exporting connector");
134
return 1;
135
}
136
@@ -195,7 +197,7 @@ int format_batch_mongodb(struct instance *instance)
197
insert[documents_inserted] = bson_new_from_json((const uint8_t *)start, -1, &bson_error);
198
199
if (unlikely(!insert[documents_inserted])) {
198
- error(
200
+ netdata_log_error(
201
"EXPORTING: Failed creating a BSON document from a JSON string \"%s\" : %s", start, bson_error.message);
202
free_bson(insert, documents_inserted);
203
return 1;
@@ -350,8 +352,8 @@ void mongodb_connector_worker(void *instance_p)
352
stats->receptions++;
353
} else {
354
// oops! we couldn't send (all or some of the) data
353
- error("EXPORTING: %s", bson_error.message);
354
- error(
355
+ netdata_log_error("EXPORTING: %s", bson_error.message);
356
+ netdata_log_error(
357
"EXPORTING: failed to write data to the database '%s'. "
358
"Willing to write %zu bytes, wrote %zu bytes.",
359
instance->config.destination, data_size, 0UL);
exporting/opentsdb/opentsdb.c
+2
-2
@@ -46,7 +46,7 @@ int init_opentsdb_telnet_instance(struct instance *instance)
46
47
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
48
if (!instance->buffer) {
49
- error("EXPORTING: cannot create buffer for opentsdb telnet exporting connector instance %s", instance->config.name);
49
+ netdata_log_error("EXPORTING: cannot create buffer for opentsdb telnet exporting connector instance %s", instance->config.name);
50
return 1;
51
}
52
@@ -102,7 +102,7 @@ int init_opentsdb_http_instance(struct instance *instance)
102
103
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
104
if (!instance->buffer) {
105
- error("EXPORTING: cannot create buffer for opentsdb HTTP exporting connector instance %s", instance->config.name);
105
+ netdata_log_error("EXPORTING: cannot create buffer for opentsdb HTTP exporting connector instance %s", instance->config.name);
106
return 1;
107
}
108
exporting/process_data.c
+9
-9
@@ -170,7 +170,7 @@ void start_batch_formatting(struct engine *engine)
170
if (instance->scheduled) {
171
uv_mutex_lock(&instance->mutex);
172
if (instance->start_batch_formatting && instance->start_batch_formatting(instance) != 0) {
173
- error("EXPORTING: cannot start batch formatting for %s", instance->config.name);
173
+ netdata_log_error("EXPORTING: cannot start batch formatting for %s", instance->config.name);
174
disable_instance(instance);
175
}
176
}
@@ -189,7 +189,7 @@ void start_host_formatting(struct engine *engine, RRDHOST *host)
189
if (instance->scheduled) {
190
if (rrdhost_is_exportable(instance, host)) {
191
if (instance->start_host_formatting && instance->start_host_formatting(instance, host) != 0) {
192
- error("EXPORTING: cannot start host formatting for %s", instance->config.name);
192
+ netdata_log_error("EXPORTING: cannot start host formatting for %s", instance->config.name);
193
disable_instance(instance);
194
}
195
} else {
@@ -211,7 +211,7 @@ void start_chart_formatting(struct engine *engine, RRDSET *st)
211
if (instance->scheduled && !instance->skip_host) {
212
if (rrdset_is_exportable(instance, st)) {
213
if (instance->start_chart_formatting && instance->start_chart_formatting(instance, st) != 0) {
214
- error("EXPORTING: cannot start chart formatting for %s", instance->config.name);
214
+ netdata_log_error("EXPORTING: cannot start chart formatting for %s", instance->config.name);
215
disable_instance(instance);
216
}
217
} else {
@@ -232,7 +232,7 @@ void metric_formatting(struct engine *engine, RRDDIM *rd)
232
for (struct instance *instance = engine->instance_root; instance; instance = instance->next) {
233
if (instance->scheduled && !instance->skip_host && !instance->skip_chart) {
234
if (instance->metric_formatting && instance->metric_formatting(instance, rd) != 0) {
235
- error("EXPORTING: cannot format metric for %s", instance->config.name);
235
+ netdata_log_error("EXPORTING: cannot format metric for %s", instance->config.name);
236
disable_instance(instance);
237
continue;
238
}
@@ -252,7 +252,7 @@ void end_chart_formatting(struct engine *engine, RRDSET *st)
252
for (struct instance *instance = engine->instance_root; instance; instance = instance->next) {
253
if (instance->scheduled && !instance->skip_host && !instance->skip_chart) {
254
if (instance->end_chart_formatting && instance->end_chart_formatting(instance, st) != 0) {
255
- error("EXPORTING: cannot end chart formatting for %s", instance->config.name);
255
+ netdata_log_error("EXPORTING: cannot end chart formatting for %s", instance->config.name);
256
disable_instance(instance);
257
continue;
258
}
@@ -271,8 +271,8 @@ void variables_formatting(struct engine *engine, RRDHOST *host)
271
{
272
for (struct instance *instance = engine->instance_root; instance; instance = instance->next) {
273
if (instance->scheduled && !instance->skip_host && should_send_variables(instance)) {
274
- if (instance->variables_formatting && instance->variables_formatting(instance, host) != 0){
275
- error("EXPORTING: cannot format variables for %s", instance->config.name);
274
+ if (instance->variables_formatting && instance->variables_formatting(instance, host) != 0){
275
+ netdata_log_error("EXPORTING: cannot format variables for %s", instance->config.name);
276
disable_instance(instance);
277
continue;
278
}
@@ -293,7 +293,7 @@ void end_host_formatting(struct engine *engine, RRDHOST *host)
293
for (struct instance *instance = engine->instance_root; instance; instance = instance->next) {
294
if (instance->scheduled && !instance->skip_host) {
295
if (instance->end_host_formatting && instance->end_host_formatting(instance, host) != 0) {
296
- error("EXPORTING: cannot end host formatting for %s", instance->config.name);
296
+ netdata_log_error("EXPORTING: cannot end host formatting for %s", instance->config.name);
297
disable_instance(instance);
298
continue;
299
}
@@ -312,7 +312,7 @@ void end_batch_formatting(struct engine *engine)
312
for (struct instance *instance = engine->instance_root; instance; instance = instance->next) {
313
if (instance->scheduled) {
314
if (instance->end_batch_formatting && instance->end_batch_formatting(instance) != 0) {
315
- error("EXPORTING: cannot end batch formatting for %s", instance->config.name);
315
+ netdata_log_error("EXPORTING: cannot end batch formatting for %s", instance->config.name);
316
disable_instance(instance);
317
continue;
318
}
exporting/prometheus/remote_write/remote_write.c
+2
-2
@@ -386,7 +386,7 @@ int format_batch_prometheus_remote_write(struct instance *instance)
386
size_t data_size = get_write_request_size(connector_specific_data->write_request);
387
388
if (unlikely(!data_size)) {
389
- error("EXPORTING: write request size is out of range");
389
+ netdata_log_error("EXPORTING: write request size is out of range");
390
return 1;
391
}
392
@@ -394,7 +394,7 @@ int format_batch_prometheus_remote_write(struct instance *instance)
394
395
buffer_need_bytes(buffer, data_size);
396
if (unlikely(pack_and_clear_write_request(connector_specific_data->write_request, buffer->buffer, &data_size))) {
397
- error("EXPORTING: cannot pack write request");
397
+ netdata_log_error("EXPORTING: cannot pack write request");
398
return 1;
399
}
400
buffer->len = data_size;
exporting/pubsub/pubsub.c
+6
-6
@@ -32,7 +32,7 @@ int init_pubsub_instance(struct instance *instance)
32
33
instance->buffer = (void *)buffer_create(0, &netdata_buffers_statistics.buffers_exporters);
34
if (!instance->buffer) {
35
- error("EXPORTING: cannot create buffer for Pub/Sub exporting connector instance %s", instance->config.name);
35
+ netdata_log_error("EXPORTING: cannot create buffer for Pub/Sub exporting connector instance %s", instance->config.name);
36
return 1;
37
}
38
uv_mutex_init(&instance->mutex);
@@ -48,7 +48,7 @@ int init_pubsub_instance(struct instance *instance)
48
(void *)connector_specific_data, error_message, instance->config.destination,
49
connector_specific_config->credentials_file, connector_specific_config->project_id,
50
connector_specific_config->topic_id)) {
51
- error(
51
+ netdata_log_error(
52
"EXPORTING: Cannot initialize a Pub/Sub publisher for instance %s: %s",
53
instance->config.name, error_message);
54
return 1;
@@ -132,7 +132,7 @@ void pubsub_connector_worker(void *instance_p)
132
stats->buffered_bytes = buffer_len;
133
134
if (pubsub_add_message(instance->connector_specific_data, (char *)buffer_tostring(buffer))) {
135
- error("EXPORTING: Instance %s: Cannot add data to a message", instance->config.name);
135
+ netdata_log_error("EXPORTING: Instance %s: Cannot add data to a message", instance->config.name);
136
137
stats->data_lost_events++;
138
stats->lost_metrics += stats->buffered_metrics;
@@ -146,7 +146,7 @@ void pubsub_connector_worker(void *instance_p)
146
connector_specific_config->project_id, connector_specific_config->topic_id, buffer_len);
147
148
if (pubsub_publish((void *)connector_specific_data, error_message, stats->buffered_metrics, buffer_len)) {
149
- error("EXPORTING: Instance: %s: Cannot publish a message: %s", instance->config.name, error_message);
149
+ netdata_log_error("EXPORTING: Instance: %s: Cannot publish a message: %s", instance->config.name, error_message);
150
151
stats->transmission_failures++;
152
stats->data_lost_events++;
@@ -164,8 +164,8 @@ void pubsub_connector_worker(void *instance_p)
164
if (unlikely(pubsub_get_result(
165
connector_specific_data, error_message, &sent_metrics, &sent_bytes, &lost_metrics, &lost_bytes))) {
166
// oops! we couldn't send (all or some of the) data
167
- error("EXPORTING: %s", error_message);
168
- error(
167
+ netdata_log_error("EXPORTING: %s", error_message);
168
+ netdata_log_error(
169
"EXPORTING: failed to write data to service '%s'. Willing to write %zu bytes, wrote %zu bytes.",
170
instance->config.destination, lost_bytes, sent_bytes);
171
exporting/read_config.c
+6
-6
@@ -176,7 +176,7 @@ inline EXPORTING_OPTIONS exporting_parse_data_source(const char *data_source, EX
176
exporting_options |= EXPORTING_SOURCE_DATA_SUM;
177
exporting_options &= ~(EXPORTING_OPTIONS_SOURCE_BITS ^ EXPORTING_SOURCE_DATA_SUM);
178
} else {
179
- error("EXPORTING: invalid data data_source method '%s'.", data_source);
179
+ netdata_log_error("EXPORTING: invalid data data_source method '%s'.", data_source);
180
}
181
182
return exporting_options;
@@ -316,34 +316,34 @@ struct engine *read_exporting_config()
316
netdata_log_info("Instance %s on %s", tmp_ci_list->local_ci.instance_name, tmp_ci_list->local_ci.connector_name);
317
318
if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_UNKNOWN) {
319
- error("Unknown exporting connector type");
319
+ netdata_log_error("Unknown exporting connector type");
320
goto next_connector_instance;
321
}
322
323
#ifndef ENABLE_PROMETHEUS_REMOTE_WRITE
324
if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_PROMETHEUS_REMOTE_WRITE) {
325
- error("Prometheus Remote Write support isn't compiled");
325
+ netdata_log_error("Prometheus Remote Write support isn't compiled");
326
goto next_connector_instance;
327
}
328
#endif
329
330
#ifndef HAVE_KINESIS
331
if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_KINESIS) {
332
- error("AWS Kinesis support isn't compiled");
332
+ netdata_log_error("AWS Kinesis support isn't compiled");
333
goto next_connector_instance;
334
}
335
#endif
336
337
#ifndef ENABLE_EXPORTING_PUBSUB
338
if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_PUBSUB) {
339
- error("Google Cloud Pub/Sub support isn't compiled");
339
+ netdata_log_error("Google Cloud Pub/Sub support isn't compiled");
340
goto next_connector_instance;
341
}
342
#endif
343
344
#ifndef HAVE_MONGOC
345
if (tmp_ci_list->exporting_type == EXPORTING_CONNECTOR_TYPE_MONGODB) {
346
- error("MongoDB support isn't compiled");
346
+ netdata_log_error("MongoDB support isn't compiled");
347
goto next_connector_instance;
348
}
349
#endif
exporting/send_data.c
+6
-6
@@ -96,14 +96,14 @@ void simple_connector_receive_response(int *sock, struct instance *instance)
96
stats->receptions++;
97
}
98
else if (r == 0) {
99
- error("EXPORTING: '%s' closed the socket", instance->config.destination);
99
+ netdata_log_error("EXPORTING: '%s' closed the socket", instance->config.destination);
100
close(*sock);
101
*sock = -1;
102
}
103
else {
104
// failed to receive data
105
if (errno != EAGAIN && errno != EWOULDBLOCK) {
106
- error("EXPORTING: cannot receive data from '%s'.", instance->config.destination);
106
+ netdata_log_error("EXPORTING: cannot receive data from '%s'.", instance->config.destination);
107
}
108
}
109
@@ -182,7 +182,7 @@ void simple_connector_send_buffer(
182
buffer_flush(buffer);
183
} else {
184
// oops! we couldn't send (all or some of the) data
185
- error(
185
+ netdata_log_error(
186
"EXPORTING: failed to write data to '%s'. Willing to write %zu bytes, wrote %zd bytes. Will re-connect.",
187
instance->config.destination,
188
buffer_len,
@@ -299,7 +299,7 @@ void simple_connector_worker(void *instance_p)
299
if (exporting_tls_is_enabled(instance->config.type, options) && sock != -1) {
300
if (netdata_ssl_exporting_ctx) {
301
if (sock_delnonblock(sock) < 0)
302
- error("Exporting cannot remove the non-blocking flag from socket %d", sock);
302
+ netdata_log_error("Exporting cannot remove the non-blocking flag from socket %d", sock);
303
304
if(netdata_ssl_open(&connector_specific_data->ssl, netdata_ssl_exporting_ctx, sock)) {
305
if(netdata_ssl_connect(&connector_specific_data->ssl)) {
@@ -313,7 +313,7 @@ void simple_connector_worker(void *instance_p)
313
tv.tv_sec = 2;
314
315
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)))
316
- error("Cannot set timeout to socket %d, this can block communication", sock);
316
+ netdata_log_error("Cannot set timeout to socket %d, this can block communication", sock);
317
}
318
}
319
}
@@ -340,7 +340,7 @@ void simple_connector_worker(void *instance_p)
340
connector_specific_data->buffer,
341
buffered_metrics);
342
} else {
343
- error("EXPORTING: failed to update '%s'", instance->config.destination);
343
+ netdata_log_error("EXPORTING: failed to update '%s'", instance->config.destination);
344
stats->transmission_failures++;
345
346
// increment the counter we check for data loss
health/health.c
+12
-9
@@ -289,20 +289,20 @@ static void health_silencers_init(void) {
289
json_parse(str, NULL, health_silencers_json_read_callback);
290
netdata_log_info("Parsed health silencers file %s", silencers_filename);
291
} else {
292
- error("Cannot read the data from health silencers file %s", silencers_filename);
292
+ netdata_log_error("Cannot read the data from health silencers file %s", silencers_filename);
293
}
294
freez(str);
295
}
296
} else {
297
- error(
298
- "Health silencers file %s has the size %" PRId64 " that is out of range[ 1 , %d ]. Aborting read.",
299
- silencers_filename,
300
- (int64_t)length,
301
- HEALTH_SILENCERS_MAX_FILE_LEN);
297
+ netdata_log_error("Health silencers file %s has the size %" PRId64 " that is out of range[ 1 , %d ]. Aborting read.",
298
+ silencers_filename,
299
+ (int64_t)length,
300
+ HEALTH_SILENCERS_MAX_FILE_LEN);
301
}
302
fclose(fd);
303
} else {
305
- netdata_log_info("Cannot open the file %s, so Netdata will work with the default health configuration.",silencers_filename);
304
+ netdata_log_info("Cannot open the file %s, so Netdata will work with the default health configuration.",
305
+ silencers_filename);
306
}
307
}
308
@@ -589,7 +589,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
589
enqueue_alarm_notify_in_progress(ae);
590
health_alarm_log_save(host, ae);
591
} else {
592
- error("Failed to format command arguments");
592
+ netdata_log_error("Failed to format command arguments");
593
}
594
595
buffer_free(wb);
@@ -803,7 +803,10 @@ static void initialize_health(RRDHOST *host)
803
804
long n = config_get_number(CONFIG_SECTION_HEALTH, "in memory max health log entries", host->health_log.max);
805
if(n < 10) {
806
- error("Host '%s': health configuration has invalid max log entries %ld. Using default %u", rrdhost_hostname(host), n, host->health_log.max);
806
+ netdata_log_error("Host '%s': health configuration has invalid max log entries %ld. Using default %u",
807
+ rrdhost_hostname(host),
808
+ n,
809
+ host->health_log.max);
810
config_set_number(CONFIG_SECTION_HEALTH, "in memory max health log entries", (long)host->health_log.max);
811
}
812
else
health/health_config.c
+107
-103
@@ -61,36 +61,36 @@ static inline int health_parse_delay(
61
62
if(!strcasecmp(key, "up")) {
63
if (!config_parse_duration(value, delay_up_duration)) {
64
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
65
- line, filename, value, key);
64
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
65
+ line, filename, value, key);
66
}
67
else given_up = 1;
68
}
69
else if(!strcasecmp(key, "down")) {
70
if (!config_parse_duration(value, delay_down_duration)) {
71
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
72
- line, filename, value, key);
71
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
72
+ line, filename, value, key);
73
}
74
else given_down = 1;
75
}
76
else if(!strcasecmp(key, "multiplier")) {
77
*delay_multiplier = strtof(value, NULL);
78
if(isnan(*delay_multiplier) || isinf(*delay_multiplier) || islessequal(*delay_multiplier, 0)) {
79
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
80
- line, filename, value, key);
79
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
80
+ line, filename, value, key);
81
}
82
else given_multiplier = 1;
83
}
84
else if(!strcasecmp(key, "max")) {
85
if (!config_parse_duration(value, delay_max_duration)) {
86
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
87
- line, filename, value, key);
86
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
87
+ line, filename, value, key);
88
}
89
else given_max = 1;
90
}
91
else {
92
- error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
93
- line, filename, key);
92
+ netdata_log_error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
93
+ line, filename, key);
94
}
95
}
96
@@ -136,7 +136,7 @@ static inline uint32_t health_parse_options(const char *s) {
136
if(!strcasecmp(buf, "no-clear-notification") || !strcasecmp(buf, "no-clear"))
137
options |= RRDCALC_OPTION_NO_CLEAR_NOTIFICATION;
138
else
139
- error("Ignoring unknown alarm option '%s'", buf);
139
+ netdata_log_error("Ignoring unknown alarm option '%s'", buf);
140
}
141
}
142
@@ -171,14 +171,14 @@ static inline int health_parse_repeat(
171
}
172
if(!strcasecmp(key, "warning")) {
173
if (!config_parse_duration(value, (int*)warn_repeat_every)) {
174
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
175
- line, file, value, key);
174
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
175
+ line, file, value, key);
176
}
177
}
178
else if(!strcasecmp(key, "critical")) {
179
if (!config_parse_duration(value, (int*)crit_repeat_every)) {
180
- error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
181
- line, file, value, key);
180
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid value '%s' for '%s' keyword",
181
+ line, file, value, key);
182
}
183
}
184
}
@@ -326,14 +326,14 @@ static inline int health_parse_db_lookup(
326
while(*s && !isspace(*s)) s++;
327
while(*s && isspace(*s)) *s++ = '\0';
328
if(!*s) {
329
- error("Health configuration invalid chart calculation at line %zu of file '%s': expected group method followed by the 'after' time, but got '%s'",
330
- line, filename, key);
329
+ netdata_log_error("Health configuration invalid chart calculation at line %zu of file '%s': expected group method followed by the 'after' time, but got '%s'",
330
+ line, filename, key);
331
return 0;
332
}
333
334
if((*group_method = time_grouping_parse(key, RRDR_GROUPING_UNDEFINED)) == RRDR_GROUPING_UNDEFINED) {
335
- error("Health configuration at line %zu of file '%s': invalid group method '%s'",
336
- line, filename, key);
335
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid group method '%s'",
336
+ line, filename, key);
337
return 0;
338
}
339
@@ -343,8 +343,8 @@ static inline int health_parse_db_lookup(
343
while(*s && isspace(*s)) *s++ = '\0';
344
345
if(!config_parse_duration(key, after)) {
346
- error("Health configuration at line %zu of file '%s': invalid duration '%s' after group method",
347
- line, filename, key);
346
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid duration '%s' after group method",
347
+ line, filename, key);
348
return 0;
349
}
350
@@ -364,8 +364,8 @@ static inline int health_parse_db_lookup(
364
while(*s && isspace(*s)) *s++ = '\0';
365
366
if (!config_parse_duration(value, before)) {
367
- error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
368
- line, filename, value, key);
367
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
368
+ line, filename, value, key);
369
}
370
}
371
else if(!strcasecmp(key, HEALTH_EVERY_KEY)) {
@@ -374,8 +374,8 @@ static inline int health_parse_db_lookup(
374
while(*s && isspace(*s)) *s++ = '\0';
375
376
if (!config_parse_duration(value, every)) {
377
- error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
378
- line, filename, value, key);
377
+ netdata_log_error("Health configuration at line %zu of file '%s': invalid duration '%s' for '%s' keyword",
378
+ line, filename, value, key);
379
}
380
}
381
else if(!strcasecmp(key, "absolute") || !strcasecmp(key, "abs") || !strcasecmp(key, "absolute_sum")) {
@@ -422,8 +422,8 @@ static inline int health_parse_db_lookup(
422
break;
423
}
424
else {
425
- error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
426
- line, filename, key);
425
+ netdata_log_error("Health configuration at line %zu of file '%s': unknown keyword '%s'",
426
+ line, filename, key);
427
}
428
}
429
@@ -574,7 +574,7 @@ static int health_readfile(const char *filename, void *data) {
574
575
FILE *fp = fopen(filename, "r");
576
if(!fp) {
577
- error("Health configuration cannot read file '%s'.", filename);
577
+ netdata_log_error("Health configuration cannot read file '%s'.", filename);
578
return 0;
579
}
580
@@ -598,7 +598,8 @@ static int health_readfile(const char *filename, void *data) {
598
if(append < HEALTH_CONF_MAX_LINE)
599
continue;
600
else {
601
- error("Health configuration has too long multi-line at line %zu of file '%s'.", line, filename);
601
+ netdata_log_error("Health configuration has too long multi-line at line %zu of file '%s'.",
602
+ line, filename);
603
}
604
}
605
append = 0;
@@ -606,7 +607,8 @@ static int health_readfile(const char *filename, void *data) {
607
char *key = s;
608
while(*s && *s != ':') s++;
609
if(!*s) {
609
- error("Health configuration has invalid line %zu of file '%s'. It does not contain a ':'. Ignoring it.", line, filename);
610
+ netdata_log_error("Health configuration has invalid line %zu of file '%s'. It does not contain a ':'. Ignoring it.",
611
+ line, filename);
612
continue;
613
}
614
*s = '\0';
@@ -617,12 +619,14 @@ static int health_readfile(const char *filename, void *data) {
619
value = trim_all(value);
620
621
if(!key) {
620
- error("Health configuration has invalid line %zu of file '%s'. Keyword is empty. Ignoring it.", line, filename);
622
+ netdata_log_error("Health configuration has invalid line %zu of file '%s'. Keyword is empty. Ignoring it.",
623
+ line, filename);
624
continue;
625
}
626
627
if(!value) {
625
- error("Health configuration has invalid line %zu of file '%s'. value is empty. Ignoring it.", line, filename);
628
+ netdata_log_error("Health configuration has invalid line %zu of file '%s'. value is empty. Ignoring it.",
629
+ line, filename);
630
continue;
631
}
632
@@ -654,7 +658,7 @@ static int health_readfile(const char *filename, void *data) {
658
{
659
char *tmp = strdupz(value);
660
if(rrdvar_fix_name(tmp))
657
- error("Health configuration renamed alarm '%s' to '%s'", value, tmp);
661
+ netdata_log_error("Health configuration renamed alarm '%s' to '%s'", value, tmp);
662
663
rc->name = string_strdupz(tmp);
664
freez(tmp);
@@ -704,7 +708,7 @@ static int health_readfile(const char *filename, void *data) {
708
{
709
char *tmp = strdupz(value);
710
if(rrdvar_fix_name(tmp))
707
- error("Health configuration renamed template '%s' to '%s'", value, tmp);
711
+ netdata_log_error("Health configuration renamed template '%s' to '%s'", value, tmp);
712
713
rt->name = string_strdupz(tmp);
714
freez(tmp);
@@ -766,8 +770,8 @@ static int health_readfile(const char *filename, void *data) {
770
alert_cfg->on = string_strdupz(value);
771
if(rc->chart) {
772
if(strcmp(rrdcalc_chart_name(rc), value) != 0)
769
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
770
- line, filename, rrdcalc_name(rc), key, rrdcalc_chart_name(rc), value, value);
773
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
774
+ line, filename, rrdcalc_name(rc), key, rrdcalc_chart_name(rc), value, value);
775
776
string_freez(rc->chart);
777
}
@@ -779,8 +783,8 @@ static int health_readfile(const char *filename, void *data) {
783
alert_cfg->classification = string_strdupz(value);
784
if(rc->classification) {
785
if(strcmp(rrdcalc_classification(rc), value) != 0)
782
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
783
- line, filename, rrdcalc_name(rc), key, rrdcalc_classification(rc), value, value);
786
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
787
+ line, filename, rrdcalc_name(rc), key, rrdcalc_classification(rc), value, value);
788
789
string_freez(rc->classification);
790
}
@@ -792,7 +796,7 @@ static int health_readfile(const char *filename, void *data) {
796
alert_cfg->component = string_strdupz(value);
797
if(rc->component) {
798
if(strcmp(rrdcalc_component(rc), value) != 0)
795
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
799
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
800
line, filename, rrdcalc_name(rc), key, rrdcalc_component(rc), value, value);
801
802
string_freez(rc->component);
@@ -805,8 +809,8 @@ static int health_readfile(const char *filename, void *data) {
809
alert_cfg->type = string_strdupz(value);
810
if(rc->type) {
811
if(strcmp(rrdcalc_type(rc), value) != 0)
808
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
809
- line, filename, rrdcalc_name(rc), key, rrdcalc_type(rc), value, value);
812
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
813
+ line, filename, rrdcalc_name(rc), key, rrdcalc_type(rc), value, value);
814
815
string_freez(rc->type);
816
}
@@ -834,8 +838,8 @@ static int health_readfile(const char *filename, void *data) {
838
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
839
alert_cfg->every = string_strdupz(value);
840
if(!config_parse_duration(value, &rc->update_every))
837
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' cannot parse duration: '%s'.",
838
- line, filename, rrdcalc_name(rc), key, value);
841
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' cannot parse duration: '%s'.",
842
+ line, filename, rrdcalc_name(rc), key, value);
843
alert_cfg->p_update_every = rc->update_every;
844
}
845
else if(hash == hash_green && !strcasecmp(key, HEALTH_GREEN_KEY)) {
@@ -843,8 +847,8 @@ static int health_readfile(const char *filename, void *data) {
847
char *e;
848
rc->green = str2ndd(value, &e);
849
if(e && *e) {
846
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
847
- line, filename, rrdcalc_name(rc), key, e);
850
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
851
+ line, filename, rrdcalc_name(rc), key, e);
852
}
853
}
854
else if(hash == hash_red && !strcasecmp(key, HEALTH_RED_KEY)) {
@@ -852,8 +856,8 @@ static int health_readfile(const char *filename, void *data) {
856
char *e;
857
rc->red = str2ndd(value, &e);
858
if(e && *e) {
855
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
856
- line, filename, rrdcalc_name(rc), key, e);
859
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' leaves this string unmatched: '%s'.",
860
+ line, filename, rrdcalc_name(rc), key, e);
861
}
862
}
863
else if(hash == hash_calc && !strcasecmp(key, HEALTH_CALC_KEY)) {
@@ -862,8 +866,8 @@ static int health_readfile(const char *filename, void *data) {
866
int error = 0;
867
rc->calculation = expression_parse(value, &failed_at, &error);
868
if(!rc->calculation) {
865
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
866
- line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
869
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
870
+ line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
871
}
872
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
873
}
@@ -873,8 +877,8 @@ static int health_readfile(const char *filename, void *data) {
877
int error = 0;
878
rc->warning = expression_parse(value, &failed_at, &error);
879
if(!rc->warning) {
876
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
877
- line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
880
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
881
+ line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
882
}
883
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
884
}
@@ -884,8 +888,8 @@ static int health_readfile(const char *filename, void *data) {
888
int error = 0;
889
rc->critical = expression_parse(value, &failed_at, &error);
890
if(!rc->critical) {
887
- error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
888
- line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
891
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
892
+ line, filename, rrdcalc_name(rc), key, value, expression_strerror(error), failed_at);
893
}
894
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
895
}
@@ -893,8 +897,8 @@ static int health_readfile(const char *filename, void *data) {
897
alert_cfg->exec = string_strdupz(value);
898
if(rc->exec) {
899
if(strcmp(rrdcalc_exec(rc), value) != 0)
896
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
897
- line, filename, rrdcalc_name(rc), key, rrdcalc_exec(rc), value, value);
900
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
901
+ line, filename, rrdcalc_name(rc), key, rrdcalc_exec(rc), value, value);
902
903
string_freez(rc->exec);
904
}
@@ -904,8 +908,8 @@ static int health_readfile(const char *filename, void *data) {
908
alert_cfg->to = string_strdupz(value);
909
if(rc->recipient) {
910
if(strcmp(rrdcalc_recipient(rc), value) != 0)
907
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
908
- line, filename, rrdcalc_name(rc), key, rrdcalc_recipient(rc), value, value);
911
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
912
+ line, filename, rrdcalc_name(rc), key, rrdcalc_recipient(rc), value, value);
913
914
string_freez(rc->recipient);
915
}
@@ -917,8 +921,8 @@ static int health_readfile(const char *filename, void *data) {
921
alert_cfg->units = string_strdupz(value);
922
if(rc->units) {
923
if(strcmp(rrdcalc_units(rc), value) != 0)
920
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
921
- line, filename, rrdcalc_name(rc), key, rrdcalc_units(rc), value, value);
924
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
925
+ line, filename, rrdcalc_name(rc), key, rrdcalc_units(rc), value, value);
926
927
string_freez(rc->units);
928
}
@@ -930,8 +934,8 @@ static int health_readfile(const char *filename, void *data) {
934
alert_cfg->info = string_strdupz(value);
935
if(rc->info) {
936
if(strcmp(rrdcalc_info(rc), value) != 0)
933
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
934
- line, filename, rrdcalc_name(rc), key, rrdcalc_info(rc), value, value);
937
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
938
+ line, filename, rrdcalc_name(rc), key, rrdcalc_info(rc), value, value);
939
940
string_freez(rc->info);
941
string_freez(rc->original_info);
@@ -957,8 +961,8 @@ static int health_readfile(const char *filename, void *data) {
961
alert_cfg->host_labels = string_strdupz(value);
962
if(rc->host_labels) {
963
if(strcmp(rrdcalc_host_labels(rc), value) != 0)
960
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'.",
961
- line, filename, rrdcalc_name(rc), key, value, value);
964
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'.",
965
+ line, filename, rrdcalc_name(rc), key, value, value);
966
967
string_freez(rc->host_labels);
968
simple_pattern_free(rc->host_labels_pattern);
@@ -992,8 +996,8 @@ static int health_readfile(const char *filename, void *data) {
996
alert_cfg->chart_labels = string_strdupz(value);
997
if(rc->chart_labels) {
998
if(strcmp(rrdcalc_chart_labels(rc), value) != 0)
995
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'.",
996
- line, filename, rrdcalc_name(rc), key, value, value);
999
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'.",
1000
+ line, filename, rrdcalc_name(rc), key, value, value);
1001
1002
string_freez(rc->chart_labels);
1003
simple_pattern_free(rc->chart_labels_pattern);
@@ -1010,8 +1014,8 @@ static int health_readfile(const char *filename, void *data) {
1014
true);
1015
}
1016
else {
1013
- error("Health configuration at line %zu of file '%s' for alarm '%s' has unknown key '%s'.",
1014
- line, filename, rrdcalc_name(rc), key);
1017
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has unknown key '%s'.",
1018
+ line, filename, rrdcalc_name(rc), key);
1019
}
1020
}
1021
else if(rt) {
@@ -1019,8 +1023,8 @@ static int health_readfile(const char *filename, void *data) {
1023
alert_cfg->on = string_strdupz(value);
1024
if(rt->context) {
1025
if(strcmp(string2str(rt->context), value) != 0)
1022
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1023
- line, filename, rrdcalctemplate_name(rt), key, string2str(rt->context), value, value);
1026
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1027
+ line, filename, rrdcalctemplate_name(rt), key, string2str(rt->context), value, value);
1028
1029
string_freez(rt->context);
1030
}
@@ -1032,8 +1036,8 @@ static int health_readfile(const char *filename, void *data) {
1036
alert_cfg->classification = string_strdupz(value);
1037
if(rt->classification) {
1038
if(strcmp(rrdcalctemplate_classification(rt), value) != 0)
1035
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1036
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_classification(rt), value, value);
1039
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1040
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_classification(rt), value, value);
1041
1042
string_freez(rt->classification);
1043
}
@@ -1045,8 +1049,8 @@ static int health_readfile(const char *filename, void *data) {
1049
alert_cfg->component = string_strdupz(value);
1050
if(rt->component) {
1051
if(strcmp(rrdcalctemplate_component(rt), value) != 0)
1048
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1049
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_component(rt), value, value);
1052
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1053
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_component(rt), value, value);
1054
1055
string_freez(rt->component);
1056
}
@@ -1058,8 +1062,8 @@ static int health_readfile(const char *filename, void *data) {
1062
alert_cfg->type = string_strdupz(value);
1063
if(rt->type) {
1064
if(strcmp(rrdcalctemplate_type(rt), value) != 0)
1061
- error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1062
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_type(rt), value, value);
1065
+ netdata_log_error("Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1066
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_type(rt), value, value);
1067
1068
string_freez(rt->type);
1069
}
@@ -1125,8 +1129,8 @@ static int health_readfile(const char *filename, void *data) {
1129
else if(hash == hash_every && !strcasecmp(key, HEALTH_EVERY_KEY)) {
1130
alert_cfg->every = string_strdupz(value);
1131
if(!config_parse_duration(value, &rt->update_every))
1128
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' cannot parse duration: '%s'.",
1129
- line, filename, rrdcalctemplate_name(rt), key, value);
1132
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' cannot parse duration: '%s'.",
1133
+ line, filename, rrdcalctemplate_name(rt), key, value);
1134
alert_cfg->p_update_every = rt->update_every;
1135
}
1136
else if(hash == hash_green && !strcasecmp(key, HEALTH_GREEN_KEY)) {
@@ -1134,8 +1138,8 @@ static int health_readfile(const char *filename, void *data) {
1138
char *e;
1139
rt->green = str2ndd(value, &e);
1140
if(e && *e) {
1137
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
1138
- line, filename, rrdcalctemplate_name(rt), key, e);
1141
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
1142
+ line, filename, rrdcalctemplate_name(rt), key, e);
1143
}
1144
}
1145
else if(hash == hash_red && !strcasecmp(key, HEALTH_RED_KEY)) {
@@ -1143,8 +1147,8 @@ static int health_readfile(const char *filename, void *data) {
1147
char *e;
1148
rt->red = str2ndd(value, &e);
1149
if(e && *e) {
1146
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
1147
- line, filename, rrdcalctemplate_name(rt), key, e);
1150
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' leaves this string unmatched: '%s'.",
1151
+ line, filename, rrdcalctemplate_name(rt), key, e);
1152
}
1153
}
1154
else if(hash == hash_calc && !strcasecmp(key, HEALTH_CALC_KEY)) {
@@ -1153,8 +1157,8 @@ static int health_readfile(const char *filename, void *data) {
1157
int error = 0;
1158
rt->calculation = expression_parse(value, &failed_at, &error);
1159
if(!rt->calculation) {
1156
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
1157
- line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
1160
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
1161
+ line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
1162
}
1163
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
1164
}
@@ -1164,8 +1168,8 @@ static int health_readfile(const char *filename, void *data) {
1168
int error = 0;
1169
rt->warning = expression_parse(value, &failed_at, &error);
1170
if(!rt->warning) {
1167
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
1168
- line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
1171
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
1172
+ line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
1173
}
1174
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
1175
}
@@ -1175,8 +1179,8 @@ static int health_readfile(const char *filename, void *data) {
1179
int error = 0;
1180
rt->critical = expression_parse(value, &failed_at, &error);
1181
if(!rt->critical) {
1178
- error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
1179
- line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
1182
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' at key '%s' has unparse-able expression '%s': %s at '%s'",
1183
+ line, filename, rrdcalctemplate_name(rt), key, value, expression_strerror(error), failed_at);
1184
}
1185
parse_variables_and_store_in_health_rrdvars(value, HEALTH_CONF_MAX_LINE);
1186
}
@@ -1184,8 +1188,8 @@ static int health_readfile(const char *filename, void *data) {
1188
alert_cfg->exec = string_strdupz(value);
1189
if(rt->exec) {
1190
if(strcmp(rrdcalctemplate_exec(rt), value) != 0)
1187
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1188
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_exec(rt), value, value);
1191
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1192
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_exec(rt), value, value);
1193
1194
string_freez(rt->exec);
1195
}
@@ -1195,8 +1199,8 @@ static int health_readfile(const char *filename, void *data) {
1199
alert_cfg->to = string_strdupz(value);
1200
if(rt->recipient) {
1201
if(strcmp(rrdcalctemplate_recipient(rt), value) != 0)
1198
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1199
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_recipient(rt), value, value);
1202
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1203
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_recipient(rt), value, value);
1204
1205
string_freez(rt->recipient);
1206
}
@@ -1208,8 +1212,8 @@ static int health_readfile(const char *filename, void *data) {
1212
alert_cfg->units = string_strdupz(value);
1213
if(rt->units) {
1214
if(strcmp(rrdcalctemplate_units(rt), value) != 0)
1211
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1212
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_units(rt), value, value);
1215
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1216
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_units(rt), value, value);
1217
1218
string_freez(rt->units);
1219
}
@@ -1221,8 +1225,8 @@ static int health_readfile(const char *filename, void *data) {
1225
alert_cfg->info = string_strdupz(value);
1226
if(rt->info) {
1227
if(strcmp(rrdcalctemplate_info(rt), value) != 0)
1224
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1225
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_info(rt), value, value);
1228
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1229
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_info(rt), value, value);
1230
1231
string_freez(rt->info);
1232
}
@@ -1246,8 +1250,8 @@ static int health_readfile(const char *filename, void *data) {
1250
alert_cfg->host_labels = string_strdupz(value);
1251
if(rt->host_labels) {
1252
if(strcmp(rrdcalctemplate_host_labels(rt), value) != 0)
1249
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1250
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_host_labels(rt), value, value);
1253
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1254
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_host_labels(rt), value, value);
1255
1256
string_freez(rt->host_labels);
1257
simple_pattern_free(rt->host_labels_pattern);
@@ -1266,8 +1270,8 @@ static int health_readfile(const char *filename, void *data) {
1270
alert_cfg->chart_labels = string_strdupz(value);
1271
if(rt->chart_labels) {
1272
if(strcmp(rrdcalctemplate_chart_labels(rt), value) != 0)
1269
- error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1270
- line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_chart_labels(rt), value, value);
1273
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has key '%s' twice, once with value '%s' and later with value '%s'. Using ('%s').",
1274
+ line, filename, rrdcalctemplate_name(rt), key, rrdcalctemplate_chart_labels(rt), value, value);
1275
1276
string_freez(rt->chart_labels);
1277
simple_pattern_free(rt->chart_labels_pattern);
@@ -1284,13 +1288,13 @@ static int health_readfile(const char *filename, void *data) {
1288
SIMPLE_PATTERN_EXACT, true);
1289
}
1290
else {
1287
- error("Health configuration at line %zu of file '%s' for template '%s' has unknown key '%s'.",
1288
- line, filename, rrdcalctemplate_name(rt), key);
1291
+ netdata_log_error("Health configuration at line %zu of file '%s' for template '%s' has unknown key '%s'.",
1292
+ line, filename, rrdcalctemplate_name(rt), key);
1293
}
1294
}
1295
else {
1292
- error("Health configuration at line %zu of file '%s' has unknown key '%s'. Expected either '" HEALTH_ALARM_KEY "' or '" HEALTH_TEMPLATE_KEY "'.",
1293
- line, filename, key);
1296
+ netdata_log_error("Health configuration at line %zu of file '%s' has unknown key '%s'. Expected either '" HEALTH_ALARM_KEY "' or '" HEALTH_TEMPLATE_KEY "'.",
1297
+ line, filename, key);
1298
}
1299
}
1300
libnetdata/aral/aral.c
+3
-3
@@ -194,7 +194,7 @@ static void aral_delete_leftover_files(const char *name, const char *path, const
194
snprintfz(full_path, FILENAME_MAX, "%s/%s", path, de->d_name);
195
netdata_log_info("ARAL: '%s' removing left-over file '%s'", name, full_path);
196
if(unlikely(unlink(full_path) == -1))
197
- error("ARAL: '%s' cannot delete file '%s'", name, full_path);
197
+ netdata_log_error("ARAL: '%s' cannot delete file '%s'", name, full_path);
198
}
199
200
closedir(dir);
@@ -324,7 +324,7 @@ void aral_del_page___no_lock_needed(ARAL *ar, ARAL_PAGE *page TRACE_ALLOCATIONS_
324
netdata_munmap(page->data, page->size);
325
326
if (unlikely(unlink(page->filename) == 1))
327
- error("Cannot delete file '%s'", page->filename);
327
+ netdata_log_error("Cannot delete file '%s'", page->filename);
328
329
freez((void *)page->filename);
330
@@ -764,7 +764,7 @@ ARAL *aral_create(const char *name, size_t element_size, size_t initial_page_ele
764
ar->config.initial_page_elements = 2;
765
766
if(ar->config.mmap.enabled && (!ar->config.mmap.cache_dir || !*ar->config.mmap.cache_dir)) {
767
- error("ARAL: '%s' mmap cache directory is not configured properly, disabling mmap.", ar->config.name);
767
+ netdata_log_error("ARAL: '%s' mmap cache directory is not configured properly, disabling mmap.", ar->config.name);
768
ar->config.mmap.enabled = false;
769
internal_fatal(true, "ARAL: '%s' mmap cache directory is not configured properly", ar->config.name);
770
}
libnetdata/buffer/buffer.c
+8
-8
@@ -367,8 +367,8 @@ static int buffer_expect(BUFFER *wb, const char *expected) {
367
const char *generated = buffer_tostring(wb);
368
369
if(strcmp(generated, expected) != 0) {
370
- error("BUFFER: mismatch.\nGenerated:\n%s\nExpected:\n%s\n",
371
- generated, expected);
370
+ netdata_log_error("BUFFER: mismatch.\nGenerated:\n%s\nExpected:\n%s\n",
371
+ generated, expected);
372
return 1;
373
}
374
@@ -385,8 +385,8 @@ static int buffer_uint64_roundtrip(BUFFER *wb, NUMBER_ENCODING encoding, uint64_
385
386
uint64_t v = str2ull_encoded(buffer_tostring(wb));
387
if(v != value) {
388
- error("BUFFER: string '%s' does resolves to %llu, expected %llu",
389
- buffer_tostring(wb), (unsigned long long)v, (unsigned long long)value);
388
+ netdata_log_error("BUFFER: string '%s' does resolves to %llu, expected %llu",
389
+ buffer_tostring(wb), (unsigned long long)v, (unsigned long long)value);
390
errors++;
391
}
392
buffer_flush(wb);
@@ -403,8 +403,8 @@ static int buffer_int64_roundtrip(BUFFER *wb, NUMBER_ENCODING encoding, int64_t
403
404
int64_t v = str2ll_encoded(buffer_tostring(wb));
405
if(v != value) {
406
- error("BUFFER: string '%s' does resolves to %lld, expected %lld",
407
- buffer_tostring(wb), (long long)v, (long long)value);
406
+ netdata_log_error("BUFFER: string '%s' does resolves to %lld, expected %lld",
407
+ buffer_tostring(wb), (long long)v, (long long)value);
408
errors++;
409
}
410
buffer_flush(wb);
@@ -421,8 +421,8 @@ static int buffer_double_roundtrip(BUFFER *wb, NUMBER_ENCODING encoding, NETDATA
421
422
NETDATA_DOUBLE v = str2ndd_encoded(buffer_tostring(wb), NULL);
423
if(v != value) {
424
- error("BUFFER: string '%s' does resolves to %.12f, expected %.12f",
425
- buffer_tostring(wb), v, value);
424
+ netdata_log_error("BUFFER: string '%s' does resolves to %.12f, expected %.12f",
425
+ buffer_tostring(wb), v, value);
426
errors++;
427
}
428
buffer_flush(wb);
libnetdata/clocks/clocks.c
+22
-25
@@ -14,7 +14,7 @@ usec_t clock_realtime_resolution = 1000;
14
inline int clock_gettime(clockid_t clk_id __maybe_unused, struct timespec *ts) {
15
struct timeval tv;
16
if(unlikely(gettimeofday(&tv, NULL) == -1)) {
17
- error("gettimeofday() failed.");
17
+ netdata_log_error("gettimeofday() failed.");
18
return -1;
19
}
20
ts->tv_sec = tv.tv_sec;
@@ -79,7 +79,7 @@ void clocks_init(void) {
79
inline time_t now_sec(clockid_t clk_id) {
80
struct timespec ts;
81
if(unlikely(clock_gettime(clk_id, &ts) == -1)) {
82
- error("clock_gettime(%d, ×pec) failed.", clk_id);
82
+ netdata_log_error("clock_gettime(%d, ×pec) failed.", clk_id);
83
return 0;
84
}
85
return ts.tv_sec;
@@ -88,7 +88,7 @@ inline time_t now_sec(clockid_t clk_id) {
88
inline usec_t now_usec(clockid_t clk_id) {
89
struct timespec ts;
90
if(unlikely(clock_gettime(clk_id, &ts) == -1)) {
91
- error("clock_gettime(%d, ×pec) failed.", clk_id);
91
+ netdata_log_error("clock_gettime(%d, ×pec) failed.", clk_id);
92
return 0;
93
}
94
return (usec_t)ts.tv_sec * USEC_PER_SEC + (ts.tv_nsec % NSEC_PER_SEC) / NSEC_PER_USEC;
@@ -98,7 +98,7 @@ inline int now_timeval(clockid_t clk_id, struct timeval *tv) {
98
struct timespec ts;
99
100
if(unlikely(clock_gettime(clk_id, &ts) == -1)) {
101
- error("clock_gettime(%d, ×pec) failed.", clk_id);
101
+ netdata_log_error("clock_gettime(%d, ×pec) failed.", clk_id);
102
tv->tv_sec = 0;
103
tv->tv_usec = 0;
104
return -1;
@@ -200,30 +200,27 @@ void sleep_to_absolute_time(usec_t usec) {
200
if (ret == EINVAL) {
201
if (!einval_printed) {
202
einval_printed++;
203
- error(
204
- "Invalid time given to clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
205
- clock,
206
- (long long)req.tv_sec,
207
- req.tv_nsec);
203
+ netdata_log_error("Invalid time given to clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
204
+ clock,
205
+ (long long)req.tv_sec,
206
+ req.tv_nsec);
207
}
208
} else if (ret == ENOTSUP) {
209
if (!enotsup_printed) {
210
enotsup_printed++;
212
- error(
213
- "Invalid clock id given to clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
214
- clock,
215
- (long long)req.tv_sec,
216
- req.tv_nsec);
211
+ netdata_log_error("Invalid clock id given to clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
212
+ clock,
213
+ (long long)req.tv_sec,
214
+ req.tv_nsec);
215
}
216
} else {
217
if (!eunknown_printed) {
218
eunknown_printed++;
221
- error(
222
- "Unknown return value %d from clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
223
- ret,
224
- clock,
225
- (long long)req.tv_sec,
226
- req.tv_nsec);
219
+ netdata_log_error("Unknown return value %d from clock_nanosleep(): clockid = %d, tv_sec = %lld, tv_nsec = %ld",
220
+ ret,
221
+ clock,
222
+ (long long)req.tv_sec,
223
+ req.tv_nsec);
224
}
225
}
226
sleep_usec(usec);
@@ -384,7 +381,7 @@ void sleep_usec_with_now(usec_t usec, usec_t started_ut) {
381
}
382
}
383
else {
387
- error("Cannot nanosleep() for %llu microseconds.", usec);
384
+ netdata_log_error("Cannot nanosleep() for %llu microseconds.", usec);
385
break;
386
}
387
}
@@ -394,7 +391,7 @@ static inline collected_number uptime_from_boottime(void) {
391
#ifdef CLOCK_BOOTTIME_IS_AVAILABLE
392
return (collected_number)(now_boottime_usec() / USEC_PER_MS);
393
#else
397
- error("uptime cannot be read from CLOCK_BOOTTIME on this system.");
394
+ netdata_log_error("uptime cannot be read from CLOCK_BOOTTIME on this system.");
395
return 0;
396
#endif
397
}
@@ -410,11 +407,11 @@ static inline collected_number read_proc_uptime(char *filename) {
407
if(unlikely(!read_proc_uptime_ff)) return 0;
408
409
if(unlikely(procfile_lines(read_proc_uptime_ff) < 1)) {
413
- error("/proc/uptime has no lines.");
410
+ netdata_log_error("/proc/uptime has no lines.");
411
return 0;
412
}
413
if(unlikely(procfile_linewords(read_proc_uptime_ff, 0) < 1)) {
417
- error("/proc/uptime has less than 1 word in it.");
414
+ netdata_log_error("/proc/uptime has less than 1 word in it.");
415
return 0;
416
}
417
@@ -441,7 +438,7 @@ inline collected_number uptime_msec(char *filename){
438
use_boottime = 0;
439
}
440
else {
444
- error("Cannot find any way to read uptime on this system.");
441
+ netdata_log_error("Cannot find any way to read uptime on this system.");
442
return 1;
443
}
444
}
libnetdata/config/appconfig.c
+19
-19
@@ -62,7 +62,7 @@ int is_valid_connector(char *type, int check_reserved)
62
}
63
// else {
64
// if (unlikely(is_valid_connector(type,1))) {
65
-// error("Section %s invalid -- reserved name", type);
65
+// netdata_log_error("Section %s invalid -- reserved name", type);
66
// return 0;
67
// }
68
// }
@@ -174,7 +174,7 @@ static inline struct section *appconfig_section_create(struct config *root, cons
174
avl_init_lock(&co->values_index, appconfig_option_compare);
175
176
if(unlikely(appconfig_index_add(root, co) != co))
177
- error("INTERNAL ERROR: indexing of section '%s', already exists.", co->name);
177
+ netdata_log_error("INTERNAL ERROR: indexing of section '%s', already exists.", co->name);
178
179
appconfig_wrlock(root);
180
struct section *co2 = root->last_section;
@@ -198,7 +198,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti
198
199
co = appconfig_section_find(root, section);
200
if(!co) {
201
- error("Could not destroy section '%s'. Not found.", section);
201
+ netdata_log_error("Could not destroy section '%s'. Not found.", section);
202
return;
203
}
204
@@ -213,7 +213,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti
213
for(cv = co->values ; cv ; cv = cv_next) {
214
cv_next = cv->next;
215
if(unlikely(!appconfig_option_index_del(co, cv)))
216
- error("Cannot remove config option '%s' from section '%s'.", cv->name, co->name);
216
+ netdata_log_error("Cannot remove config option '%s' from section '%s'.", cv->name, co->name);
217
freez(cv->value);
218
freez(cv->name);
219
freez(cv);
@@ -222,7 +222,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti
222
config_section_unlock(co);
223
224
if (unlikely(!appconfig_index_del(root, co))) {
225
- error("Cannot remove section '%s' from config.", section);
225
+ netdata_log_error("Cannot remove section '%s' from config.", section);
226
return;
227
}
228
@@ -264,7 +264,7 @@ void appconfig_section_option_destroy_non_loaded(struct config *root, const char
264
struct section *co;
265
co = appconfig_section_find(root, section);
266
if (!co) {
267
- error("Could not destroy section option '%s -> %s'. The section not found.", section, name);
267
+ netdata_log_error("Could not destroy section option '%s -> %s'. The section not found.", section, name);
268
return;
269
}
270
@@ -281,7 +281,7 @@ void appconfig_section_option_destroy_non_loaded(struct config *root, const char
281
282
if (unlikely(!(cv && appconfig_option_index_del(co, cv)))) {
283
config_section_unlock(co);
284
- error("Could not destroy section option '%s -> %s'. The option not found.", section, name);
284
+ netdata_log_error("Could not destroy section option '%s -> %s'. The option not found.", section, name);
285
return;
286
}
287
@@ -319,7 +319,7 @@ static inline struct config_option *appconfig_value_create(struct section *co, c
319
320
struct config_option *found = appconfig_option_index_add(co, cv);
321
if(found != cv) {
322
- error("indexing of config '%s' in section '%s': already exists - using the existing one.", cv->name, co->name);
322
+ netdata_log_error("indexing of config '%s' in section '%s': already exists - using the existing one.", cv->name, co->name);
323
freez(cv->value);
324
freez(cv->name);
325
freez(cv);
@@ -375,7 +375,7 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
375
if(cv_new) goto cleanup;
376
377
if(unlikely(appconfig_option_index_del(co_old, cv_old) != cv_old))
378
- error("INTERNAL ERROR: deletion of config '%s' from section '%s', deleted the wrong config entry.", cv_old->name, co_old->name);
378
+ netdata_log_error("INTERNAL ERROR: deletion of config '%s' from section '%s', deleted the wrong config entry.", cv_old->name, co_old->name);
379
380
if(co_old->values == cv_old) {
381
co_old->values = cv_old->next;
@@ -384,7 +384,7 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
384
struct config_option *t;
385
for(t = co_old->values; t && t->next != cv_old ;t = t->next) ;
386
if(!t || t->next != cv_old)
387
- error("INTERNAL ERROR: cannot find variable '%s' in section '%s' of the config - but it should be there.", cv_old->name, co_old->name);
387
+ netdata_log_error("INTERNAL ERROR: cannot find variable '%s' in section '%s' of the config - but it should be there.", cv_old->name, co_old->name);
388
else
389
t->next = cv_old->next;
390
}
@@ -398,7 +398,7 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
398
co_new->values = cv_new;
399
400
if(unlikely(appconfig_option_index_add(co_new, cv_old) != cv_old))
401
- error("INTERNAL ERROR: re-indexing of config '%s' in section '%s', already exists.", cv_old->name, co_new->name);
401
+ netdata_log_error("INTERNAL ERROR: re-indexing of config '%s' in section '%s', already exists.", cv_old->name, co_new->name);
402
403
ret = 0;
404
@@ -618,7 +618,7 @@ int appconfig_get_duration(struct config *root, const char *section, const char
618
if(!s) goto fallback;
619
620
if(!config_parse_duration(s, &result)) {
621
- error("config option '[%s].%s = %s' is configured with an valid duration", section, name, s);
621
+ netdata_log_error("config option '[%s].%s = %s' is configured with an valid duration", section, name, s);
622
goto fallback;
623
}
624
@@ -626,7 +626,7 @@ int appconfig_get_duration(struct config *root, const char *section, const char
626
627
fallback:
628
if(!config_parse_duration(value, &result))
629
- error("INTERNAL ERROR: default duration supplied for option '[%s].%s = %s' is not a valid duration", section, name, value);
629
+ netdata_log_error("INTERNAL ERROR: default duration supplied for option '[%s].%s = %s' is not a valid duration", section, name, value);
630
631
return result;
632
}
@@ -696,13 +696,13 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
696
strncpyz(working_instance, s, CONFIG_MAX_NAME);
697
working_connector_section = NULL;
698
if (unlikely(appconfig_section_find(root, working_instance))) {
699
- error("Instance (%s) already exists", working_instance);
699
+ netdata_log_error("Instance (%s) already exists", working_instance);
700
co = NULL;
701
continue;
702
}
703
} else {
704
co = NULL;
705
- error("Section (%s) does not specify a valid connector", s);
705
+ netdata_log_error("Section (%s) does not specify a valid connector", s);
706
continue;
707
}
708
}
@@ -718,7 +718,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
718
struct config_option *save = cv2->next;
719
struct config_option *found = appconfig_option_index_del(co, cv2);
720
if(found != cv2)
721
- error("INTERNAL ERROR: Cannot remove '%s' from section '%s', it was not inserted before.",
721
+ netdata_log_error("INTERNAL ERROR: Cannot remove '%s' from section '%s', it was not inserted before.",
722
cv2->name, co->name);
723
724
freez(cv2->name);
@@ -735,7 +735,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
735
736
if(!co) {
737
// line outside a section
738
- error("CONFIG: ignoring line %d ('%s') of file '%s', it is outside all sections.", line, s, filename);
738
+ netdata_log_error("CONFIG: ignoring line %d ('%s') of file '%s', it is outside all sections.", line, s, filename);
739
continue;
740
}
741
@@ -746,7 +746,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
746
char *name = s;
747
char *value = strchr(s, '=');
748
if(!value) {
749
- error("CONFIG: ignoring line %d ('%s') of file '%s', there is no = in it.", line, s, filename);
749
+ netdata_log_error("CONFIG: ignoring line %d ('%s') of file '%s', there is no = in it.", line, s, filename);
750
continue;
751
}
752
*value = '\0';
@@ -756,7 +756,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
756
value = trim(value);
757
758
if(!name || *name == '#') {
759
- error("CONFIG: ignoring line %d of file '%s', name is empty.", line, filename);
759
+ netdata_log_error("CONFIG: ignoring line %d of file '%s', name is empty.", line, filename);
760
continue;
761
}
762
libnetdata/dictionary/dictionary.c
+14
-11
@@ -952,7 +952,7 @@ static int item_check_and_acquire_advanced(DICTIONARY *dict, DICTIONARY_ITEM *it
952
if (having_index_lock) {
953
// delete it from the hashtable
954
if(hashtable_delete_unsafe(dict, item_get_name(item), item->key_len, item) == 0)
955
- error("DICTIONARY: INTERNAL ERROR VIEW: tried to delete item with name '%s', name_len %u that is not in the index", item_get_name(item), (KEY_LEN_TYPE)(item->key_len - 1));
955
+ netdata_log_error("DICTIONARY: INTERNAL ERROR VIEW: tried to delete item with name '%s', name_len %u that is not in the index", item_get_name(item), (KEY_LEN_TYPE)(item->key_len - 1));
956
else
957
pointer_del(dict, item);
958
@@ -1065,8 +1065,8 @@ static size_t hashtable_destroy_unsafe(DICTIONARY *dict) {
1065
JError_t J_Error;
1066
Word_t ret = JudyHSFreeArray(&dict->index.JudyHSArray, &J_Error);
1067
if(unlikely(ret == (Word_t) JERR)) {
1068
- error("DICTIONARY: Cannot destroy JudyHS, JU_ERRNO_* == %u, ID == %d",
1069
- JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
1068
+ netdata_log_error("DICTIONARY: Cannot destroy JudyHS, JU_ERRNO_* == %u, ID == %d",
1069
+ JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
1070
}
1071
1072
debug(D_DICTIONARY, "Dictionary: hash table freed %lu bytes", ret);
@@ -1079,8 +1079,8 @@ static inline void **hashtable_insert_unsafe(DICTIONARY *dict, const char *name,
1079
JError_t J_Error;
1080
Pvoid_t *Rc = JudyHSIns(&dict->index.JudyHSArray, (void *)name, name_len, &J_Error);
1081
if (unlikely(Rc == PJERR)) {
1082
- error("DICTIONARY: Cannot insert entry with name '%s' to JudyHS, JU_ERRNO_* == %u, ID == %d",
1083
- name, JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
1082
+ netdata_log_error("DICTIONARY: Cannot insert entry with name '%s' to JudyHS, JU_ERRNO_* == %u, ID == %d",
1083
+ name, JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
1084
}
1085
1086
// if *Rc == 0, new item added to the array
@@ -1100,8 +1100,9 @@ static inline int hashtable_delete_unsafe(DICTIONARY *dict, const char *name, si
1100
JError_t J_Error;
1101
int ret = JudyHSDel(&dict->index.JudyHSArray, (void *)name, name_len, &J_Error);
1102
if(unlikely(ret == JERR)) {
1103
- error("DICTIONARY: Cannot delete entry with name '%s' from JudyHS, JU_ERRNO_* == %u, ID == %d", name,
1104
- JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
1103
+ netdata_log_error("DICTIONARY: Cannot delete entry with name '%s' from JudyHS, JU_ERRNO_* == %u, ID == %d",
1104
+ name,
1105
+ JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
1106
return 0;
1107
}
1108
@@ -1573,7 +1574,9 @@ static bool dict_item_del(DICTIONARY *dict, const char *name, ssize_t name_len)
1574
}
1575
else {
1576
if(hashtable_delete_unsafe(dict, name, name_len, item) == 0)
1576
- error("DICTIONARY: INTERNAL ERROR: tried to delete item with name '%s', name_len %zd that is not in the index", name, name_len - 1);
1577
+ netdata_log_error("DICTIONARY: INTERNAL ERROR: tried to delete item with name '%s', name_len %zd that is not in the index",
1578
+ name,
1579
+ name_len - 1);
1580
else
1581
pointer_del(dict, item);
1582
@@ -1668,7 +1671,7 @@ static DICTIONARY_ITEM *dict_item_add_or_reset_value_and_acquire(DICTIONARY *dic
1671
// view dictionary
1672
// the item is already there and can be used
1673
if(item->shared != master_item->shared)
1671
- error("DICTIONARY: changing the master item on a view is not supported. The previous item will remain. To change the key of an item in a view, delete it and add it again.");
1674
+ netdata_log_error("DICTIONARY: changing the master item on a view is not supported. The previous item will remain. To change the key of an item in a view, delete it and add it again.");
1675
}
1676
else {
1677
// master dictionary
@@ -2555,8 +2558,8 @@ void thread_cache_destroy(void) {
2558
JError_t J_Error;
2559
Word_t ret = JudyHSFreeArray(&thread_cache_judy_array, &J_Error);
2560
if(unlikely(ret == (Word_t) JERR)) {
2558
- error("THREAD_CACHE: Cannot destroy JudyHS, JU_ERRNO_* == %u, ID == %d",
2559
- JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
2561
+ netdata_log_error("THREAD_CACHE: Cannot destroy JudyHS, JU_ERRNO_* == %u, ID == %d",
2562
+ JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
2563
}
2564
2565
internal_error(true, "THREAD_CACHE: hash table freed %lu bytes", ret);
libnetdata/ebpf/ebpf.c
+7
-7
@@ -477,7 +477,7 @@ void ebpf_update_kernel_memory(ebpf_plugin_stats_t *report, ebpf_local_maps_t *m
477
snprintfz(filename, FILENAME_MAX, "/proc/self/fdinfo/%d", map->map_fd);
478
procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
479
if(unlikely(!ff)) {
480
- error("Cannot open %s", filename);
480
+ netdata_log_error("Cannot open %s", filename);
481
return;
482
}
483
@@ -613,7 +613,7 @@ void ebpf_update_map_size(struct bpf_map *map, ebpf_local_maps_t *lmap, ebpf_mod
613
void ebpf_update_map_type(struct bpf_map *map, ebpf_local_maps_t *w)
614
{
615
if (bpf_map__set_type(map, w->map_type)) {
616
- error("Cannot modify map type for %s", w->name);
616
+ netdata_log_error("Cannot modify map type for %s", w->name);
617
}
618
}
619
@@ -794,7 +794,7 @@ void ebpf_update_controller(int fd, ebpf_module_t *em)
794
for (key = NETDATA_CONTROLLER_APPS_ENABLED; key < end; key++) {
795
int ret = bpf_map_update_elem(fd, &key, &values[key], 0);
796
if (ret)
797
- error("Add key(%u) for controller table failed.", key);
797
+ netdata_log_error("Add key(%u) for controller table failed.", key);
798
}
799
}
800
@@ -867,7 +867,7 @@ struct bpf_link **ebpf_load_program(char *plugins_dir, ebpf_module_t *em, int kv
867
ebpf_update_legacy_map(*obj, em);
868
869
if (bpf_object__load(*obj)) {
870
- error("ERROR: loading BPF object file failed %s\n", lpath);
870
+ netdata_log_error("ERROR: loading BPF object file failed %s\n", lpath);
871
bpf_object__close(*obj);
872
return NULL;
873
}
@@ -891,7 +891,7 @@ char *ebpf_find_symbol(char *search)
891
snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, NETDATA_KALLSYMS);
892
procfile *ff = procfile_open(filename, " \t", PROCFILE_FLAG_DEFAULT);
893
if(unlikely(!ff)) {
894
- error("Cannot open %s%s", netdata_configured_host_prefix, NETDATA_KALLSYMS);
894
+ netdata_log_error("Cannot open %s%s", netdata_configured_host_prefix, NETDATA_KALLSYMS);
895
return ret;
896
}
897
@@ -1295,7 +1295,7 @@ void ebpf_update_module(ebpf_module_t *em, struct btf *btf_file, int kver, int i
1295
if (!ebpf_load_config(em->cfg, filename)) {
1296
ebpf_mount_config_name(filename, FILENAME_MAX, ebpf_stock_config_dir, em->config_file);
1297
if (!ebpf_load_config(em->cfg, filename)) {
1298
- error("Cannot load the ebpf configuration file %s", em->config_file);
1298
+ netdata_log_error("Cannot load the ebpf configuration file %s", em->config_file);
1299
return;
1300
}
1301
// If user defined data globally, we will have here EBPF_LOADED_FROM_USER, we need to consider this, to avoid
@@ -1512,7 +1512,7 @@ int ebpf_is_tracepoint_enabled(char *subsys, char *eventname)
1512
static int ebpf_change_tracing_values(char *subsys, char *eventname, char *value)
1513
{
1514
if (strcmp("0", value) && strcmp("1", value)) {
1515
- error("Invalid value given to either enable or disable a tracepoint.");
1515
+ netdata_log_error("Invalid value given to either enable or disable a tracepoint.");
1516
return -1;
1517
}
1518
libnetdata/eval/eval.c
+2
-2
@@ -1129,14 +1129,14 @@ EVAL_EXPRESSION *expression_parse(const char *string, const char **failed_at, in
1129
1130
if(!op) {
1131
unsigned long pos = s - string + 1;
1132
- error("failed to parse expression '%s': %s at character %lu (i.e.: '%s').", string, expression_strerror(err), pos, s);
1132
+ netdata_log_error("failed to parse expression '%s': %s at character %lu (i.e.: '%s').", string, expression_strerror(err), pos, s);
1133
return NULL;
1134
}
1135
1136
BUFFER *out = buffer_create(1024, NULL);
1137
print_parsed_as_node(out, op, &err);
1138
if(err != EVAL_ERROR_OK) {
1139
- error("failed to re-generate expression '%s' with reason: %s", string, expression_strerror(err));
1139
+ netdata_log_error("failed to re-generate expression '%s' with reason: %s", string, expression_strerror(err));
1140
eval_node_free(op);
1141
buffer_free(out);
1142
return NULL;
libnetdata/health/health.c
+1
-1
@@ -73,7 +73,7 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
73
) {
74
silencer = create_silencer();
75
if(!silencer) {
76
- error("Cannot add a new silencer to Netdata");
76
+ netdata_log_error("Cannot add a new silencer to Netdata");
77
return NULL;
78
}
79
}
libnetdata/json/json.c
+5
-5
@@ -22,13 +22,13 @@ int json_tokens = JSON_TOKENS;
22
#ifdef ENABLE_JSONC
23
json_object *json_tokenise(char *js) {
24
if(!js) {
25
- error("JSON: json string is empty.");
25
+ netdata_log_error("JSON: json string is empty.");
26
return NULL;
27
}
28
29
json_object *token = json_tokener_parse(js);
30
if(!token) {
31
- error("JSON: Invalid json string.");
31
+ netdata_log_error("JSON: Invalid json string.");
32
return NULL;
33
}
34
@@ -39,7 +39,7 @@ jsmntok_t *json_tokenise(char *js, size_t len, size_t *count)
39
{
40
int n = json_tokens;
41
if(!js || !len) {
42
- error("JSON: json string is empty.");
42
+ netdata_log_error("JSON: json string is empty.");
43
return NULL;
44
}
45
@@ -62,12 +62,12 @@ jsmntok_t *json_tokenise(char *js, size_t len, size_t *count)
62
}
63
64
if (ret == JSMN_ERROR_INVAL) {
65
- error("JSON: Invalid json string.");
65
+ netdata_log_error("JSON: Invalid json string.");
66
freez(tokens);
67
return NULL;
68
}
69
else if (ret == JSMN_ERROR_PART) {
70
- error("JSON: Truncated JSON string.");
70
+ netdata_log_error("JSON: Truncated JSON string.");
71
freez(tokens);
72
return NULL;
73
}
libnetdata/libnetdata.c
+35
-25
@@ -370,7 +370,7 @@ static struct malloc_header *malloc_get_header(void *ptr, const char *caller, co
370
struct malloc_header *t = (struct malloc_header *)ret;
371
372
if(t->signature.magic != 0x0BADCAFE) {
373
- error("pointer %p is not our pointer (called %s() from %zu@%s, %s()).", ptr, caller, line, file, function);
373
+ netdata_log_error("pointer %p is not our pointer (called %s() from %zu@%s, %s()).", ptr, caller, line, file, function);
374
return NULL;
375
}
376
@@ -1050,13 +1050,16 @@ static int memory_file_open(const char *filename, size_t size) {
1050
if (lseek(fd, size, SEEK_SET) == (off_t) size) {
1051
if (write(fd, "", 1) == 1) {
1052
if (ftruncate(fd, size))
1053
- error("Cannot truncate file '%s' to size %zu. Will use the larger file.", filename, size);
1053
+ netdata_log_error("Cannot truncate file '%s' to size %zu. Will use the larger file.", filename, size);
1054
}
1055
- else error("Cannot write to file '%s' at position %zu.", filename, size);
1055
+ else
1056
+ netdata_log_error("Cannot write to file '%s' at position %zu.", filename, size);
1057
}
1057
- else error("Cannot seek file '%s' to size %zu.", filename, size);
1058
+ else
1059
+ netdata_log_error("Cannot seek file '%s' to size %zu.", filename, size);
1060
}
1059
- else error("Cannot create/open file '%s'.", filename);
1061
+ else
1062
+ netdata_log_error("Cannot create/open file '%s'.", filename);
1063
1064
return fd;
1065
}
@@ -1065,7 +1068,8 @@ inline int madvise_sequential(void *mem, size_t len) {
1068
static int logger = 1;
1069
int ret = madvise(mem, len, MADV_SEQUENTIAL);
1070
1068
- if (ret != 0 && logger-- > 0) error("madvise(MADV_SEQUENTIAL) failed.");
1071
+ if (ret != 0 && logger-- > 0)
1072
+ netdata_log_error("madvise(MADV_SEQUENTIAL) failed.");
1073
return ret;
1074
}
1075
@@ -1073,7 +1077,8 @@ inline int madvise_random(void *mem, size_t len) {
1077
static int logger = 1;
1078
int ret = madvise(mem, len, MADV_RANDOM);
1079
1076
- if (ret != 0 && logger-- > 0) error("madvise(MADV_RANDOM) failed.");
1080
+ if (ret != 0 && logger-- > 0)
1081
+ netdata_log_error("madvise(MADV_RANDOM) failed.");
1082
return ret;
1083
}
1084
@@ -1081,7 +1086,8 @@ inline int madvise_dontfork(void *mem, size_t len) {
1086
static int logger = 1;
1087
int ret = madvise(mem, len, MADV_DONTFORK);
1088
1084
- if (ret != 0 && logger-- > 0) error("madvise(MADV_DONTFORK) failed.");
1089
+ if (ret != 0 && logger-- > 0)
1090
+ netdata_log_error("madvise(MADV_DONTFORK) failed.");
1091
return ret;
1092
}
1093
@@ -1089,7 +1095,8 @@ inline int madvise_willneed(void *mem, size_t len) {
1095
static int logger = 1;
1096
int ret = madvise(mem, len, MADV_WILLNEED);
1097
1092
- if (ret != 0 && logger-- > 0) error("madvise(MADV_WILLNEED) failed.");
1098
+ if (ret != 0 && logger-- > 0)
1099
+ netdata_log_error("madvise(MADV_WILLNEED) failed.");
1100
return ret;
1101
}
1102
@@ -1097,7 +1104,8 @@ inline int madvise_dontneed(void *mem, size_t len) {
1104
static int logger = 1;
1105
int ret = madvise(mem, len, MADV_DONTNEED);
1106
1100
- if (ret != 0 && logger-- > 0) error("madvise(MADV_DONTNEED) failed.");
1107
+ if (ret != 0 && logger-- > 0)
1108
+ netdata_log_error("madvise(MADV_DONTNEED) failed.");
1109
return ret;
1110
}
1111
@@ -1106,7 +1114,8 @@ inline int madvise_dontdump(void *mem __maybe_unused, size_t len __maybe_unused)
1114
static int logger = 1;
1115
int ret = madvise(mem, len, MADV_DONTDUMP);
1116
1109
- if (ret != 0 && logger-- > 0) error("madvise(MADV_DONTDUMP) failed.");
1117
+ if (ret != 0 && logger-- > 0)
1118
+ netdata_log_error("madvise(MADV_DONTDUMP) failed.");
1119
return ret;
1120
#else
1121
return 0;
@@ -1118,7 +1127,8 @@ inline int madvise_mergeable(void *mem __maybe_unused, size_t len __maybe_unused
1127
static int logger = 1;
1128
int ret = madvise(mem, len, MADV_MERGEABLE);
1129
1121
- if (ret != 0 && logger-- > 0) error("madvise(MADV_MERGEABLE) failed.");
1130
+ if (ret != 0 && logger-- > 0)
1131
+ netdata_log_error("madvise(MADV_MERGEABLE) failed.");
1132
return ret;
1133
#else
1134
return 0;
@@ -1215,12 +1225,12 @@ int memory_file_save(const char *filename, void *mem, size_t size) {
1225
1226
int fd = open(tmpfilename, O_RDWR | O_CREAT | O_NOATIME, 0664);
1227
if (fd < 0) {
1218
- error("Cannot create/open file '%s'.", filename);
1228
+ netdata_log_error("Cannot create/open file '%s'.", filename);
1229
return -1;
1230
}
1231
1232
if (write(fd, mem, size) != (ssize_t) size) {
1223
- error("Cannot write to file '%s' %ld bytes.", filename, (long) size);
1233
+ netdata_log_error("Cannot write to file '%s' %ld bytes.", filename, (long) size);
1234
close(fd);
1235
return -1;
1236
}
@@ -1228,7 +1238,7 @@ int memory_file_save(const char *filename, void *mem, size_t size) {
1238
close(fd);
1239
1240
if (rename(tmpfilename, filename)) {
1231
- error("Cannot rename '%s' to '%s'", tmpfilename, filename);
1241
+ netdata_log_error("Cannot rename '%s' to '%s'", tmpfilename, filename);
1242
return -1;
1243
}
1244
@@ -1298,7 +1308,7 @@ unsigned long end_tsc(void) {
1308
int recursively_delete_dir(const char *path, const char *reason) {
1309
DIR *dir = opendir(path);
1310
if(!dir) {
1301
- error("Cannot read %s directory to be deleted '%s'", reason?reason:"", path);
1311
+ netdata_log_error("Cannot read %s directory to be deleted '%s'", reason?reason:"", path);
1312
return -1;
1313
}
1314
@@ -1323,14 +1333,14 @@ int recursively_delete_dir(const char *path, const char *reason) {
1333
1334
netdata_log_info("Deleting %s file '%s'", reason?reason:"", fullpath);
1335
if(unlikely(unlink(fullpath) == -1))
1326
- error("Cannot delete %s file '%s'", reason?reason:"", fullpath);
1336
+ netdata_log_error("Cannot delete %s file '%s'", reason?reason:"", fullpath);
1337
else
1338
ret++;
1339
}
1340
1341
netdata_log_info("Deleting empty directory '%s'", path);
1342
if(unlikely(rmdir(path) == -1))
1333
- error("Cannot delete empty directory '%s'", path);
1343
+ netdata_log_error("Cannot delete empty directory '%s'", path);
1344
else
1345
ret++;
1346
@@ -1404,7 +1414,7 @@ int verify_netdata_host_prefix() {
1414
return 0;
1415
1416
failed:
1407
- error("Ignoring host prefix '%s': path '%s' %s", netdata_configured_host_prefix, path, reason);
1417
+ netdata_log_error("Ignoring host prefix '%s': path '%s' %s", netdata_configured_host_prefix, path, reason);
1418
netdata_configured_host_prefix = "";
1419
return -1;
1420
}
@@ -1512,7 +1522,7 @@ int path_is_file(const char *path, const char *subpath) {
1522
1523
void recursive_config_double_dir_load(const char *user_path, const char *stock_path, const char *subpath, int (*callback)(const char *filename, void *data), void *data, size_t depth) {
1524
if(depth > 3) {
1515
- error("CONFIG: Max directory depth reached while reading user path '%s', stock path '%s', subpath '%s'", user_path, stock_path, subpath);
1525
+ netdata_log_error("CONFIG: Max directory depth reached while reading user path '%s', stock path '%s', subpath '%s'", user_path, stock_path, subpath);
1526
return;
1527
}
1528
@@ -1523,7 +1533,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
1533
1534
DIR *dir = opendir(udir);
1535
if (!dir) {
1526
- error("CONFIG cannot open user-config directory '%s'.", udir);
1536
+ netdata_log_error("CONFIG cannot open user-config directory '%s'.", udir);
1537
}
1538
else {
1539
struct dirent *de = NULL;
@@ -1565,7 +1575,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
1575
1576
dir = opendir(sdir);
1577
if (!dir) {
1568
- error("CONFIG cannot open stock config directory '%s'.", sdir);
1578
+ netdata_log_error("CONFIG cannot open stock config directory '%s'.", sdir);
1579
}
1580
else {
1581
if (strcmp(udir, sdir)) {
@@ -1741,7 +1751,7 @@ bool run_command_and_copy_output_to_stdout(const char *command, int max_line_len
1751
fprintf(stdout, "%s", buffer);
1752
}
1753
else {
1744
- error("Failed to execute command '%s'.", command);
1754
+ netdata_log_error("Failed to execute command '%s'.", command);
1755
return false;
1756
}
1757
@@ -1759,7 +1769,7 @@ void for_each_open_fd(OPEN_FD_ACTION action, OPEN_FD_EXCLUDE excluded_fds){
1769
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDERR)) (void)close(STDERR_FILENO);
1770
#if defined(HAVE_CLOSE_RANGE)
1771
if(close_range(STDERR_FILENO + 1, ~0U, 0) == 0) return;
1762
- error("close_range() failed, will try to close fds one by one");
1772
+ netdata_log_error("close_range() failed, will try to close fds one by one");
1773
#endif
1774
break;
1775
case OPEN_FD_ACTION_FD_CLOEXEC:
@@ -1768,7 +1778,7 @@ void for_each_open_fd(OPEN_FD_ACTION action, OPEN_FD_EXCLUDE excluded_fds){
1778
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDERR)) (void)fcntl(STDERR_FILENO, F_SETFD, FD_CLOEXEC);
1779
#if defined(HAVE_CLOSE_RANGE) && defined(CLOSE_RANGE_CLOEXEC) // Linux >= 5.11, FreeBSD >= 13.1
1780
if(close_range(STDERR_FILENO + 1, ~0U, CLOSE_RANGE_CLOEXEC) == 0) return;
1771
- error("close_range() failed, will try to mark fds for closing one by one");
1781
+ netdata_log_error("close_range() failed, will try to mark fds for closing one by one");
1782
#endif
1783
break;
1784
default:
libnetdata/libnetdata.h
+1
-1
@@ -601,7 +601,7 @@ char *find_and_replace(const char *src, const char *find, const char *replace, c
601
#define UNUSED_FUNCTION(x) UNUSED_##x
602
#endif
603
604
-#define error_report(x, args...) do { errno = 0; error(x, ##args); } while(0)
604
+#define error_report(x, args...) do { errno = 0; netdata_log_error(x, ##args); } while(0)
605
606
// Taken from linux kernel
607
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
libnetdata/locks/locks.c
+21
-18
@@ -33,7 +33,7 @@ inline void netdata_thread_disable_cancelability(void) {
33
int ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
34
35
if(ret != 0)
36
- error("THREAD_CANCELABILITY: pthread_setcancelstate() on thread %s returned error %d",
36
+ netdata_log_error("THREAD_CANCELABILITY: pthread_setcancelstate() on thread %s returned error %d",
37
netdata_thread_tag(), ret);
38
39
netdata_thread_first_cancelability = old;
@@ -46,9 +46,9 @@ inline void netdata_thread_enable_cancelability(void) {
46
if(unlikely(netdata_thread_nested_disables < 1)) {
47
internal_fatal(true, "THREAD_CANCELABILITY: trying to enable cancelability, but it was not not disabled");
48
49
- error("THREAD_CANCELABILITY: netdata_thread_enable_cancelability(): invalid thread cancelability count %d "
50
- "on thread %s - results will be undefined - please report this!",
51
- netdata_thread_nested_disables, netdata_thread_tag());
49
+ netdata_log_error("THREAD_CANCELABILITY: netdata_thread_enable_cancelability(): invalid thread cancelability count %d "
50
+ "on thread %s - results will be undefined - please report this!",
51
+ netdata_thread_nested_disables, netdata_thread_tag());
52
53
netdata_thread_nested_disables = 1;
54
}
@@ -57,15 +57,18 @@ inline void netdata_thread_enable_cancelability(void) {
57
int old = 1;
58
int ret = pthread_setcancelstate(netdata_thread_first_cancelability, &old);
59
if(ret != 0)
60
- error("THREAD_CANCELABILITY: pthread_setcancelstate() on thread %s returned error %d", netdata_thread_tag(), ret);
60
+ netdata_log_error("THREAD_CANCELABILITY: pthread_setcancelstate() on thread %s returned error %d",
61
+ netdata_thread_tag(),
62
+ ret);
63
else {
64
if(old != PTHREAD_CANCEL_DISABLE) {
65
internal_fatal(true, "THREAD_CANCELABILITY: invalid old state cancelability");
66
65
- error("THREAD_CANCELABILITY: netdata_thread_enable_cancelability(): old thread cancelability "
66
- "on thread %s was changed, expected DISABLED (%d), found %s (%d) - please report this!",
67
- netdata_thread_tag(), PTHREAD_CANCEL_DISABLE,
68
- (old == PTHREAD_CANCEL_ENABLE) ? "ENABLED" : "UNKNOWN", old);
67
+ netdata_log_error("THREAD_CANCELABILITY: netdata_thread_enable_cancelability(): old thread cancelability "
68
+ "on thread %s was changed, expected DISABLED (%d), found %s (%d) - please report this!",
69
+ netdata_thread_tag(), PTHREAD_CANCEL_DISABLE,
70
+ (old == PTHREAD_CANCEL_ENABLE) ? "ENABLED" : "UNKNOWN",
71
+ old);
72
}
73
}
74
}
@@ -79,14 +82,14 @@ inline void netdata_thread_enable_cancelability(void) {
82
int __netdata_mutex_init(netdata_mutex_t *mutex) {
83
int ret = pthread_mutex_init(mutex, NULL);
84
if(unlikely(ret != 0))
82
- error("MUTEX_LOCK: failed to initialize (code %d).", ret);
85
+ netdata_log_error("MUTEX_LOCK: failed to initialize (code %d).", ret);
86
return ret;
87
}
88
89
int __netdata_mutex_destroy(netdata_mutex_t *mutex) {
90
int ret = pthread_mutex_destroy(mutex);
91
if(unlikely(ret != 0))
89
- error("MUTEX_LOCK: failed to destroy (code %d).", ret);
92
+ netdata_log_error("MUTEX_LOCK: failed to destroy (code %d).", ret);
93
return ret;
94
}
95
@@ -96,7 +99,7 @@ int __netdata_mutex_lock(netdata_mutex_t *mutex) {
99
int ret = pthread_mutex_lock(mutex);
100
if(unlikely(ret != 0)) {
101
netdata_thread_enable_cancelability();
99
- error("MUTEX_LOCK: failed to get lock (code %d)", ret);
102
+ netdata_log_error("MUTEX_LOCK: failed to get lock (code %d)", ret);
103
}
104
else
105
netdata_locks_acquired_mutexes++;
@@ -119,7 +122,7 @@ int __netdata_mutex_trylock(netdata_mutex_t *mutex) {
122
int __netdata_mutex_unlock(netdata_mutex_t *mutex) {
123
int ret = pthread_mutex_unlock(mutex);
124
if(unlikely(ret != 0))
122
- error("MUTEX_LOCK: failed to unlock (code %d).", ret);
125
+ netdata_log_error("MUTEX_LOCK: failed to unlock (code %d).", ret);
126
else {
127
netdata_locks_acquired_mutexes--;
128
netdata_thread_enable_cancelability();
@@ -211,14 +214,14 @@ int netdata_mutex_unlock_debug(const char *file __maybe_unused, const char *func
214
int __netdata_rwlock_destroy(netdata_rwlock_t *rwlock) {
215
int ret = pthread_rwlock_destroy(&rwlock->rwlock_t);
216
if(unlikely(ret != 0))
214
- error("RW_LOCK: failed to destroy lock (code %d)", ret);
217
+ netdata_log_error("RW_LOCK: failed to destroy lock (code %d)", ret);
218
return ret;
219
}
220
221
int __netdata_rwlock_init(netdata_rwlock_t *rwlock) {
222
int ret = pthread_rwlock_init(&rwlock->rwlock_t, NULL);
223
if(unlikely(ret != 0))
221
- error("RW_LOCK: failed to initialize lock (code %d)", ret);
224
+ netdata_log_error("RW_LOCK: failed to initialize lock (code %d)", ret);
225
return ret;
226
}
227
@@ -228,7 +231,7 @@ int __netdata_rwlock_rdlock(netdata_rwlock_t *rwlock) {
231
int ret = pthread_rwlock_rdlock(&rwlock->rwlock_t);
232
if(unlikely(ret != 0)) {
233
netdata_thread_enable_cancelability();
231
- error("RW_LOCK: failed to obtain read lock (code %d)", ret);
234
+ netdata_log_error("RW_LOCK: failed to obtain read lock (code %d)", ret);
235
}
236
else
237
netdata_locks_acquired_rwlocks++;
@@ -241,7 +244,7 @@ int __netdata_rwlock_wrlock(netdata_rwlock_t *rwlock) {
244
245
int ret = pthread_rwlock_wrlock(&rwlock->rwlock_t);
246
if(unlikely(ret != 0)) {
244
- error("RW_LOCK: failed to obtain write lock (code %d)", ret);
247
+ netdata_log_error("RW_LOCK: failed to obtain write lock (code %d)", ret);
248
netdata_thread_enable_cancelability();
249
}
250
else
@@ -253,7 +256,7 @@ int __netdata_rwlock_wrlock(netdata_rwlock_t *rwlock) {
256
int __netdata_rwlock_unlock(netdata_rwlock_t *rwlock) {
257
int ret = pthread_rwlock_unlock(&rwlock->rwlock_t);
258
if(unlikely(ret != 0))
256
- error("RW_LOCK: failed to release lock (code %d)", ret);
259
+ netdata_log_error("RW_LOCK: failed to release lock (code %d)", ret);
260
else {
261
netdata_thread_enable_cancelability();
262
netdata_locks_acquired_rwlocks--;
libnetdata/log/log.c
+4
-4
@@ -530,7 +530,7 @@ static FILE *open_log_file(int fd, FILE *fp, const char *filename, int *enabled_
530
else {
531
f = open(filename, O_WRONLY | O_APPEND | O_CREAT, 0664);
532
if(f == -1) {
533
- error("Cannot open file '%s'. Leaving %d to its default.", filename, fd);
533
+ netdata_log_error("Cannot open file '%s'. Leaving %d to its default.", filename, fd);
534
if(fd_ptr) *fd_ptr = fd;
535
return fp;
536
}
@@ -550,7 +550,7 @@ static FILE *open_log_file(int fd, FILE *fp, const char *filename, int *enabled_
550
// it automatically closes
551
int t = dup2(f, fd);
552
if (t == -1) {
553
- error("Cannot dup2() new fd %d to old fd %d for '%s'", f, fd, filename);
553
+ netdata_log_error("Cannot dup2() new fd %d to old fd %d for '%s'", f, fd, filename);
554
close(f);
555
if(fd_ptr) *fd_ptr = fd;
556
return fp;
@@ -563,10 +563,10 @@ static FILE *open_log_file(int fd, FILE *fp, const char *filename, int *enabled_
563
if(!fp) {
564
fp = fdopen(fd, "a");
565
if (!fp)
566
- error("Cannot fdopen() fd %d ('%s')", fd, filename);
566
+ netdata_log_error("Cannot fdopen() fd %d ('%s')", fd, filename);
567
else {
568
if (setvbuf(fp, NULL, _IOLBF, 0) != 0)
569
- error("Cannot set line buffering on fd %d ('%s')", fd, filename);
569
+ netdata_log_error("Cannot set line buffering on fd %d ('%s')", fd, filename);
570
}
571
}
572
libnetdata/log/log.h
+1
-1
@@ -121,7 +121,7 @@ typedef struct error_with_limit {
121
#define netdata_log_info(args...) info_int(0, __FILE__, __FUNCTION__, __LINE__, ##args)
122
#define collector_info(args...) info_int(1, __FILE__, __FUNCTION__, __LINE__, ##args)
123
#define infoerr(args...) error_int(0, "INFO", __FILE__, __FUNCTION__, __LINE__, ##args)
124
-#define error(args...) error_int(0, "ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
124
+#define netdata_log_error(args...) error_int(0, "ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
125
#define collector_infoerr(args...) error_int(1, "INFO", __FILE__, __FUNCTION__, __LINE__, ##args)
126
#define collector_error(args...) error_int(1, "ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
127
#define error_limit(erl, args...) error_limit_int(erl, "ERROR", __FILE__, __FUNCTION__, __LINE__, ##args)
libnetdata/onewayalloc/onewayalloc.c
+1
-1
@@ -176,7 +176,7 @@ void onewayalloc_freez(ONEWAYALLOC *owa __maybe_unused, const void *ptr __maybe_
176
177
// not found - it is not ours
178
// let's free it with the system allocator
179
- error("ONEWAYALLOC: request to free address 0x%p that is not allocated by this OWA", ptr);
179
+ netdata_log_error("ONEWAYALLOC: request to free address 0x%p that is not allocated by this OWA", ptr);
180
#endif
181
182
return;
libnetdata/os.c
+18
-18
@@ -28,7 +28,7 @@ long get_system_cpus_with_cache(bool cache, bool for_netdata) {
28
bool error = false;
29
30
if (unlikely(GETSYSCTL_BY_NAME(HW_CPU_NAME, tmp_processors)))
31
- error = true;
31
+ netdata_log_error = true;
32
else
33
processors[index] = tmp_processors;
34
@@ -36,7 +36,7 @@ long get_system_cpus_with_cache(bool cache, bool for_netdata) {
36
processors[index] = 1;
37
38
if(error)
39
- error("Assuming system has %d processors.", processors[index]);
39
+ netdata_log_error("Assuming system has %d processors.", processors[index]);
40
}
41
42
return processors[index];
@@ -49,14 +49,14 @@ long get_system_cpus_with_cache(bool cache, bool for_netdata) {
49
procfile *ff = procfile_open(filename, NULL, PROCFILE_FLAG_DEFAULT);
50
if(!ff) {
51
processors[index] = 1;
52
- error("Cannot open file '%s'. Assuming system has %ld processors.", filename, processors[index]);
52
+ netdata_log_error("Cannot open file '%s'. Assuming system has %ld processors.", filename, processors[index]);
53
return processors[index];
54
}
55
56
ff = procfile_readall(ff);
57
if(!ff) {
58
processors[index] = 1;
59
- error("Cannot open file '%s'. Assuming system has %ld processors.", filename, processors[index]);
59
+ netdata_log_error("Cannot open file '%s'. Assuming system has %ld processors.", filename, processors[index]);
60
return processors[index];
61
}
62
@@ -93,7 +93,7 @@ pid_t get_system_pid_max(void) {
93
94
if (unlikely(GETSYSCTL_BY_NAME("kern.pid_max", tmp_pid_max))) {
95
pid_max = 99999;
96
- error("Assuming system's maximum pid is %d.", pid_max);
96
+ netdata_log_error("Assuming system's maximum pid is %d.", pid_max);
97
} else {
98
pid_max = tmp_pid_max;
99
}
@@ -110,12 +110,12 @@ pid_t get_system_pid_max(void) {
110
111
unsigned long long max = 0;
112
if(read_single_number_file(filename, &max) != 0) {
113
- error("Cannot open file '%s'. Assuming system supports %d pids.", filename, pid_max);
113
+ netdata_log_error("Cannot open file '%s'. Assuming system supports %d pids.", filename, pid_max);
114
return pid_max;
115
}
116
117
if(!max) {
118
- error("Cannot parse file '%s'. Assuming system supports %d pids.", filename, pid_max);
118
+ netdata_log_error("Cannot parse file '%s'. Assuming system supports %d pids.", filename, pid_max);
119
return pid_max;
120
}
121
@@ -130,7 +130,7 @@ void get_system_HZ(void) {
130
long ticks;
131
132
if ((ticks = sysconf(_SC_CLK_TCK)) == -1) {
133
- error("Cannot get system clock ticks");
133
+ netdata_log_error("Cannot get system clock ticks");
134
}
135
136
system_hz = (unsigned int) ticks;
@@ -197,11 +197,11 @@ int getsysctl_by_name(const char *name, void *ptr, size_t len) {
197
size_t nlen = len;
198
199
if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) {
200
- error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
200
+ netdata_log_error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
201
return 1;
202
}
203
if (unlikely(nlen != len)) {
204
- error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
204
+ netdata_log_error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
205
return 1;
206
}
207
return 0;
@@ -215,11 +215,11 @@ int getsysctl_simple(const char *name, int *mib, size_t miblen, void *ptr, size_
215
return 1;
216
217
if (unlikely(sysctl(mib, miblen, ptr, &nlen, NULL, 0) == -1)) {
218
- error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
218
+ netdata_log_error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
219
return 1;
220
}
221
if (unlikely(nlen != len)) {
222
- error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
222
+ netdata_log_error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
223
return 1;
224
}
225
@@ -234,11 +234,11 @@ int getsysctl(const char *name, int *mib, size_t miblen, void *ptr, size_t *len)
234
return 1;
235
236
if (unlikely(sysctl(mib, miblen, ptr, len, NULL, 0) == -1)) {
237
- error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
237
+ netdata_log_error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
238
return 1;
239
}
240
if (unlikely(ptr != NULL && nlen != *len)) {
241
- error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)*len, (unsigned long)nlen);
241
+ netdata_log_error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)*len, (unsigned long)nlen);
242
return 1;
243
}
244
@@ -249,11 +249,11 @@ int getsysctl_mib(const char *name, int *mib, size_t len) {
249
size_t nlen = len;
250
251
if (unlikely(sysctlnametomib(name, mib, &nlen) == -1)) {
252
- error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
252
+ netdata_log_error("FREEBSD: sysctl(%s...) failed: %s", name, strerror(errno));
253
return 1;
254
}
255
if (unlikely(nlen != len)) {
256
- error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
256
+ netdata_log_error("FREEBSD: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
257
return 1;
258
}
259
return 0;
@@ -274,11 +274,11 @@ int getsysctl_by_name(const char *name, void *ptr, size_t len) {
274
size_t nlen = len;
275
276
if (unlikely(sysctlbyname(name, ptr, &nlen, NULL, 0) == -1)) {
277
- error("MACOS: sysctl(%s...) failed: %s", name, strerror(errno));
277
+ netdata_log_error("MACOS: sysctl(%s...) failed: %s", name, strerror(errno));
278
return 1;
279
}
280
if (unlikely(nlen != len)) {
281
- error("MACOS: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
281
+ netdata_log_error("MACOS: sysctl(%s...) expected %lu, got %lu", name, (unsigned long)len, (unsigned long)nlen);
282
return 1;
283
}
284
return 0;
libnetdata/popen/popen.c
+24
-24
@@ -55,7 +55,7 @@ static void netdata_popen_tracking_del_pid(pid_t pid) {
55
freez(mp);
56
}
57
else
58
- error("POPEN: Cannot find pid %d.", pid);
58
+ netdata_log_error("POPEN: Cannot find pid %d.", pid);
59
60
netdata_popen_tracking_unlock();
61
}
@@ -156,33 +156,33 @@ static int popene_internal(volatile pid_t *pidptr, char **env, uint8_t flags, FI
156
unsigned int fds_to_exclude_from_closing = OPEN_FD_EXCLUDE_STDERR;
157
158
if(posix_spawn_file_actions_init(&fa)) {
159
- error("POPEN: posix_spawn_file_actions_init() failed.");
159
+ netdata_log_error("POPEN: posix_spawn_file_actions_init() failed.");
160
ret = -1;
161
goto set_return_values_and_return;
162
}
163
164
if(fpp_child_stdin) {
165
if (pipe(pipefd_stdin) == -1) {
166
- error("POPEN: stdin pipe() failed");
166
+ netdata_log_error("POPEN: stdin pipe() failed");
167
ret = -1;
168
goto cleanup_and_return;
169
}
170
171
if ((fp_child_stdin = fdopen(pipefd_stdin[PIPE_WRITE], "w")) == NULL) {
172
- error("POPEN: fdopen() stdin failed");
172
+ netdata_log_error("POPEN: fdopen() stdin failed");
173
ret = -1;
174
goto cleanup_and_return;
175
}
176
177
if(posix_spawn_file_actions_adddup2(&fa, pipefd_stdin[PIPE_READ], STDIN_FILENO)) {
178
- error("POPEN: posix_spawn_file_actions_adddup2() on stdin failed.");
178
+ netdata_log_error("POPEN: posix_spawn_file_actions_adddup2() on stdin failed.");
179
ret = -1;
180
goto cleanup_and_return;
181
}
182
}
183
else {
184
if (posix_spawn_file_actions_addopen(&fa, STDIN_FILENO, "/dev/null", O_RDONLY, 0)) {
185
- error("POPEN: posix_spawn_file_actions_addopen() on stdin to /dev/null failed.");
185
+ netdata_log_error("POPEN: posix_spawn_file_actions_addopen() on stdin to /dev/null failed.");
186
// this is not a fatal error
187
fds_to_exclude_from_closing |= OPEN_FD_EXCLUDE_STDIN;
188
}
@@ -190,26 +190,26 @@ static int popene_internal(volatile pid_t *pidptr, char **env, uint8_t flags, FI
190
191
if (fpp_child_stdout) {
192
if (pipe(pipefd_stdout) == -1) {
193
- error("POPEN: stdout pipe() failed");
193
+ netdata_log_error("POPEN: stdout pipe() failed");
194
ret = -1;
195
goto cleanup_and_return;
196
}
197
198
if ((fp_child_stdout = fdopen(pipefd_stdout[PIPE_READ], "r")) == NULL) {
199
- error("POPEN: fdopen() stdout failed");
199
+ netdata_log_error("POPEN: fdopen() stdout failed");
200
ret = -1;
201
goto cleanup_and_return;
202
}
203
204
if(posix_spawn_file_actions_adddup2(&fa, pipefd_stdout[PIPE_WRITE], STDOUT_FILENO)) {
205
- error("POPEN: posix_spawn_file_actions_adddup2() on stdout failed.");
205
+ netdata_log_error("POPEN: posix_spawn_file_actions_adddup2() on stdout failed.");
206
ret = -1;
207
goto cleanup_and_return;
208
}
209
}
210
else {
211
if (posix_spawn_file_actions_addopen(&fa, STDOUT_FILENO, "/dev/null", O_WRONLY, 0)) {
212
- error("POPEN: posix_spawn_file_actions_addopen() on stdout to /dev/null failed.");
212
+ netdata_log_error("POPEN: posix_spawn_file_actions_addopen() on stdout to /dev/null failed.");
213
// this is not a fatal error
214
fds_to_exclude_from_closing |= OPEN_FD_EXCLUDE_STDOUT;
215
}
@@ -223,20 +223,20 @@ static int popene_internal(volatile pid_t *pidptr, char **env, uint8_t flags, FI
223
attr_rc = posix_spawnattr_init(&attr);
224
if(attr_rc) {
225
// failed
226
- error("POPEN: posix_spawnattr_init() failed.");
226
+ netdata_log_error("POPEN: posix_spawnattr_init() failed.");
227
}
228
else {
229
// success
230
// reset all signals in the child
231
232
if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF))
233
- error("POPEN: posix_spawnattr_setflags() failed.");
233
+ netdata_log_error("POPEN: posix_spawnattr_setflags() failed.");
234
235
sigset_t mask;
236
sigemptyset(&mask);
237
238
if (posix_spawnattr_setsigmask(&attr, &mask))
239
- error("POPEN: posix_spawnattr_setsigmask() failed.");
239
+ netdata_log_error("POPEN: posix_spawnattr_setsigmask() failed.");
240
}
241
242
// Take the lock while we fork to ensure we don't race with SIGCHLD
@@ -251,7 +251,7 @@ static int popene_internal(volatile pid_t *pidptr, char **env, uint8_t flags, FI
251
else {
252
// failure
253
netdata_popen_tracking_unlock();
254
- error("POPEN: failed to spawn command: \"%s\" from parent pid %d.", command_to_be_logged, getpid());
254
+ netdata_log_error("POPEN: failed to spawn command: \"%s\" from parent pid %d.", command_to_be_logged, getpid());
255
ret = -1;
256
goto cleanup_and_return;
257
}
@@ -263,11 +263,11 @@ cleanup_and_return:
263
if(!attr_rc) {
264
// posix_spawnattr_init() succeeded
265
if (posix_spawnattr_destroy(&attr))
266
- error("POPEN: posix_spawnattr_destroy() failed");
266
+ netdata_log_error("POPEN: posix_spawnattr_destroy() failed");
267
}
268
269
if (posix_spawn_file_actions_destroy(&fa))
270
- error("POPEN: posix_spawn_file_actions_destroy() failed");
270
+ netdata_log_error("POPEN: posix_spawn_file_actions_destroy() failed");
271
272
// the child end - close it
273
if(pipefd_stdin[PIPE_READ] != -1)
@@ -401,7 +401,7 @@ int netdata_pclose(FILE *fp_child_input, FILE *fp_child_output, pid_t pid) {
401
switch (info.si_code) {
402
case CLD_EXITED:
403
if(info.si_status)
404
- error("child pid %d exited with code %d.", info.si_pid, info.si_status);
404
+ netdata_log_error("child pid %d exited with code %d.", info.si_pid, info.si_status);
405
return(info.si_status);
406
407
case CLD_KILLED:
@@ -414,33 +414,33 @@ int netdata_pclose(FILE *fp_child_input, FILE *fp_child_output, pid_t pid) {
414
return(0);
415
}
416
else {
417
- error("child pid %d killed by signal %d.", info.si_pid, info.si_status);
417
+ netdata_log_error("child pid %d killed by signal %d.", info.si_pid, info.si_status);
418
return(-1);
419
}
420
421
case CLD_DUMPED:
422
- error("child pid %d core dumped by signal %d.", info.si_pid, info.si_status);
422
+ netdata_log_error("child pid %d core dumped by signal %d.", info.si_pid, info.si_status);
423
return(-2);
424
425
case CLD_STOPPED:
426
- error("child pid %d stopped by signal %d.", info.si_pid, info.si_status);
426
+ netdata_log_error("child pid %d stopped by signal %d.", info.si_pid, info.si_status);
427
return(0);
428
429
case CLD_TRAPPED:
430
- error("child pid %d trapped by signal %d.", info.si_pid, info.si_status);
430
+ netdata_log_error("child pid %d trapped by signal %d.", info.si_pid, info.si_status);
431
return(-4);
432
433
case CLD_CONTINUED:
434
- error("child pid %d continued by signal %d.", info.si_pid, info.si_status);
434
+ netdata_log_error("child pid %d continued by signal %d.", info.si_pid, info.si_status);
435
return(0);
436
437
default:
438
- error("child pid %d gave us a SIGCHLD with code %d and status %d.", info.si_pid, info.si_code, info.si_status);
438
+ netdata_log_error("child pid %d gave us a SIGCHLD with code %d and status %d.", info.si_pid, info.si_code, info.si_status);
439
return(-5);
440
}
441
}
442
else
443
- error("Cannot waitid() for pid %d", pid);
443
+ netdata_log_error("Cannot waitid() for pid %d", pid);
444
445
return 0;
446
}
libnetdata/procfile/procfile.c
+6
-3
@@ -297,7 +297,8 @@ procfile *procfile_readall(procfile *ff) {
297
r = read(ff->fd, &ff->data[s], ff->size - s);
298
if(unlikely(r == -1)) {
299
if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
300
- else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG)) error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
300
+ else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG))
301
+ netdata_log_error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
302
procfile_close(ff);
303
return NULL;
304
}
@@ -308,7 +309,8 @@ procfile *procfile_readall(procfile *ff) {
309
// debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);
310
if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) {
311
if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
311
- else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG)) error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
312
+ else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG))
313
+ netdata_log_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
314
procfile_close(ff);
315
return NULL;
316
}
@@ -406,7 +408,8 @@ procfile *procfile_open(const char *filename, const char *separators, uint32_t f
408
int fd = open(filename, procfile_open_flags, 0666);
409
if(unlikely(fd == -1)) {
410
if(unlikely(!(flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot open file '%s'", filename);
409
- else if(unlikely(flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG)) error(PF_PREFIX ": Cannot open file '%s'", filename);
411
+ else if(unlikely(flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG))
412
+ netdata_log_error(PF_PREFIX ": Cannot open file '%s'", filename);
413
return NULL;
414
}
415
libnetdata/socket/security.c
+6
-6
@@ -429,7 +429,7 @@ void netdata_ssl_initialize_openssl() {
429
#else
430
431
if (OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL) != 1) {
432
- error("SSL library cannot be initialized.");
432
+ netdata_log_error("SSL library cannot be initialized.");
433
}
434
435
#endif
@@ -516,7 +516,7 @@ static SSL_CTX * netdata_ssl_create_server_ctx(unsigned long mode) {
516
#if OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_110
517
ctx = SSL_CTX_new(SSLv23_server_method());
518
if (!ctx) {
519
- error("Cannot create a new SSL context, netdata won't encrypt communication");
519
+ netdata_log_error("Cannot create a new SSL context, netdata won't encrypt communication");
520
return NULL;
521
}
522
@@ -524,7 +524,7 @@ static SSL_CTX * netdata_ssl_create_server_ctx(unsigned long mode) {
524
#else
525
ctx = SSL_CTX_new(TLS_server_method());
526
if (!ctx) {
527
- error("Cannot create a new SSL context, netdata won't encrypt communication");
527
+ netdata_log_error("Cannot create a new SSL context, netdata won't encrypt communication");
528
return NULL;
529
}
530
@@ -539,7 +539,7 @@ static SSL_CTX * netdata_ssl_create_server_ctx(unsigned long mode) {
539
540
if(tls_ciphers && strcmp(tls_ciphers, "none") != 0) {
541
if (!SSL_CTX_set_cipher_list(ctx, tls_ciphers)) {
542
- error("SSL error. cannot set the cipher list");
542
+ netdata_log_error("SSL error. cannot set the cipher list");
543
}
544
}
545
#endif
@@ -548,7 +548,7 @@ static SSL_CTX * netdata_ssl_create_server_ctx(unsigned long mode) {
548
549
if (!SSL_CTX_check_private_key(ctx)) {
550
ERR_error_string_n(ERR_get_error(),lerror,sizeof(lerror));
551
- error("SSL cannot check the private key: %s",lerror);
551
+ netdata_log_error("SSL cannot check the private key: %s",lerror);
552
SSL_CTX_free(ctx);
553
return NULL;
554
}
@@ -680,7 +680,7 @@ int security_test_certificate(SSL *ssl) {
680
{
681
char error[512];
682
ERR_error_string_n(ERR_get_error(), error, sizeof(error));
683
- error("SSL RFC4158 check: We have a invalid certificate, the tests result with %ld and message %s", status, error);
683
+ netdata_log_error("SSL RFC4158 check: We have a invalid certificate, the tests result with %ld and message %s", status, error);
684
ret = -1;
685
} else {
686
ret = 0;
libnetdata/socket/socket.c
+55
-55
@@ -124,7 +124,7 @@ int sock_setnonblock(int fd) {
124
125
int ret = fcntl(fd, F_SETFL, flags);
126
if(ret < 0)
127
- error("Failed to set O_NONBLOCK on socket %d", fd);
127
+ netdata_log_error("Failed to set O_NONBLOCK on socket %d", fd);
128
129
return ret;
130
}
@@ -137,7 +137,7 @@ int sock_delnonblock(int fd) {
137
138
int ret = fcntl(fd, F_SETFL, flags);
139
if(ret < 0)
140
- error("Failed to remove O_NONBLOCK on socket %d", fd);
140
+ netdata_log_error("Failed to remove O_NONBLOCK on socket %d", fd);
141
142
return ret;
143
}
@@ -146,7 +146,7 @@ int sock_setreuse(int fd, int reuse) {
146
int ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
147
148
if(ret == -1)
149
- error("Failed to set SO_REUSEADDR on socket %d", fd);
149
+ netdata_log_error("Failed to set SO_REUSEADDR on socket %d", fd);
150
151
return ret;
152
}
@@ -157,7 +157,7 @@ int sock_setreuse_port(int fd, int reuse) {
157
#ifdef SO_REUSEPORT
158
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse));
159
if(ret == -1 && errno != ENOPROTOOPT)
160
- error("failed to set SO_REUSEPORT on socket %d", fd);
160
+ netdata_log_error("failed to set SO_REUSEPORT on socket %d", fd);
161
#else
162
ret = -1;
163
#endif
@@ -171,7 +171,7 @@ int sock_enlarge_in(int fd) {
171
ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &bs, sizeof(bs));
172
173
if(ret == -1)
174
- error("Failed to set SO_RCVBUF on socket %d", fd);
174
+ netdata_log_error("Failed to set SO_RCVBUF on socket %d", fd);
175
176
return ret;
177
}
@@ -181,7 +181,7 @@ int sock_enlarge_out(int fd) {
181
ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &bs, sizeof(bs));
182
183
if(ret == -1)
184
- error("Failed to set SO_SNDBUF on socket %d", fd);
184
+ netdata_log_error("Failed to set SO_SNDBUF on socket %d", fd);
185
186
return ret;
187
}
@@ -220,7 +220,7 @@ int create_listen_socket_unix(const char *path, int listen_backlog) {
220
221
sock = socket(AF_UNIX, SOCK_STREAM, 0);
222
if(sock < 0) {
223
- error("LISTENER: UNIX socket() on path '%s' failed.", path);
223
+ netdata_log_error("LISTENER: UNIX socket() on path '%s' failed.", path);
224
return -1;
225
}
226
@@ -234,22 +234,22 @@ int create_listen_socket_unix(const char *path, int listen_backlog) {
234
235
errno = 0;
236
if (unlink(path) == -1 && errno != ENOENT)
237
- error("LISTENER: failed to remove existing (probably obsolete or left-over) file on UNIX socket path '%s'.", path);
237
+ netdata_log_error("LISTENER: failed to remove existing (probably obsolete or left-over) file on UNIX socket path '%s'.", path);
238
239
if(bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
240
close(sock);
241
- error("LISTENER: UNIX bind() on path '%s' failed.", path);
241
+ netdata_log_error("LISTENER: UNIX bind() on path '%s' failed.", path);
242
return -1;
243
}
244
245
// we have to chmod this to 0777 so that the client will be able
246
// to read from and write to this socket.
247
if(chmod(path, 0777) == -1)
248
- error("LISTENER: failed to chmod() socket file '%s'.", path);
248
+ netdata_log_error("LISTENER: failed to chmod() socket file '%s'.", path);
249
250
if(listen(sock, listen_backlog) < 0) {
251
close(sock);
252
- error("LISTENER: UNIX listen() on path '%s' failed.", path);
252
+ netdata_log_error("LISTENER: UNIX listen() on path '%s' failed.", path);
253
return -1;
254
}
255
@@ -264,7 +264,7 @@ int create_listen_socket4(int socktype, const char *ip, uint16_t port, int liste
264
265
sock = socket(AF_INET, socktype, 0);
266
if(sock < 0) {
267
- error("LISTENER: IPv4 socket() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
267
+ netdata_log_error("LISTENER: IPv4 socket() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
268
return -1;
269
}
270
@@ -280,20 +280,20 @@ int create_listen_socket4(int socktype, const char *ip, uint16_t port, int liste
280
281
int ret = inet_pton(AF_INET, ip, (void *)&name.sin_addr.s_addr);
282
if(ret != 1) {
283
- error("LISTENER: Failed to convert IP '%s' to a valid IPv4 address.", ip);
283
+ netdata_log_error("LISTENER: Failed to convert IP '%s' to a valid IPv4 address.", ip);
284
close(sock);
285
return -1;
286
}
287
288
if(bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
289
close(sock);
290
- error("LISTENER: IPv4 bind() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
290
+ netdata_log_error("LISTENER: IPv4 bind() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
291
return -1;
292
}
293
294
if(socktype == SOCK_STREAM && listen(sock, listen_backlog) < 0) {
295
close(sock);
296
- error("LISTENER: IPv4 listen() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
296
+ netdata_log_error("LISTENER: IPv4 listen() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
297
return -1;
298
}
299
@@ -309,7 +309,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
309
310
sock = socket(AF_INET6, socktype, 0);
311
if (sock < 0) {
312
- error("LISTENER: IPv6 socket() on ip '%s' port %d, socktype %d, failed.", ip, port, socktype);
312
+ netdata_log_error("LISTENER: IPv6 socket() on ip '%s' port %d, socktype %d, failed.", ip, port, socktype);
313
return -1;
314
}
315
@@ -320,7 +320,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
320
321
/* IPv6 only */
322
if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&ipv6only, sizeof(ipv6only)) != 0)
323
- error("LISTENER: Cannot set IPV6_V6ONLY on ip '%s' port %d, socktype %d.", ip, port, socktype);
323
+ netdata_log_error("LISTENER: Cannot set IPV6_V6ONLY on ip '%s' port %d, socktype %d.", ip, port, socktype);
324
325
struct sockaddr_in6 name;
326
memset(&name, 0, sizeof(struct sockaddr_in6));
@@ -330,7 +330,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
330
331
int ret = inet_pton(AF_INET6, ip, (void *)&name.sin6_addr.s6_addr);
332
if(ret != 1) {
333
- error("LISTENER: Failed to convert IP '%s' to a valid IPv6 address.", ip);
333
+ netdata_log_error("LISTENER: Failed to convert IP '%s' to a valid IPv6 address.", ip);
334
close(sock);
335
return -1;
336
}
@@ -339,13 +339,13 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
339
340
if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
341
close(sock);
342
- error("LISTENER: IPv6 bind() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
342
+ netdata_log_error("LISTENER: IPv6 bind() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
343
return -1;
344
}
345
346
if (socktype == SOCK_STREAM && listen(sock, listen_backlog) < 0) {
347
close(sock);
348
- error("LISTENER: IPv6 listen() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
348
+ netdata_log_error("LISTENER: IPv6 listen() on ip '%s' port %d, socktype %d failed.", ip, port, socktype);
349
return -1;
350
}
351
@@ -355,7 +355,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
355
356
static inline int listen_sockets_add(LISTEN_SOCKETS *sockets, int fd, int family, int socktype, const char *protocol, const char *ip, uint16_t port, int acl_flags) {
357
if(sockets->opened >= MAX_LISTEN_FDS) {
358
- error("LISTENER: Too many listening sockets. Failed to add listening %s socket at ip '%s' port %d, protocol %s, socktype %d", protocol, ip, port, protocol, socktype);
358
+ netdata_log_error("LISTENER: Too many listening sockets. Failed to add listening %s socket at ip '%s' port %d, protocol %s, socktype %d", protocol, ip, port, protocol, socktype);
359
close(fd);
360
return -1;
361
}
@@ -485,7 +485,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
485
protocol_str = "unix";
486
int fd = create_listen_socket_unix(path, listen_backlog);
487
if (fd == -1) {
488
- error("LISTENER: Cannot create unix socket '%s'", path);
488
+ netdata_log_error("LISTENER: Cannot create unix socket '%s'", path);
489
sockets->failed++;
490
} else {
491
acl_flags = WEB_CLIENT_ACL_DASHBOARD | WEB_CLIENT_ACL_REGISTRY | WEB_CLIENT_ACL_BADGE | WEB_CLIENT_ACL_MGMT | WEB_CLIENT_ACL_NETDATACONF | WEB_CLIENT_ACL_STREAMING | WEB_CLIENT_ACL_SSL_DEFAULT;
@@ -551,7 +551,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
551
if(*interface) {
552
scope_id = if_nametoindex(interface);
553
if(!scope_id)
554
- error("LISTENER: Cannot find a network interface named '%s'. Continuing with limiting the network interface", interface);
554
+ netdata_log_error("LISTENER: Cannot find a network interface named '%s'. Continuing with limiting the network interface", interface);
555
}
556
557
if(!*ip || *ip == '*' || !strcmp(ip, "any") || !strcmp(ip, "all"))
@@ -571,7 +571,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
571
572
int r = getaddrinfo(ip, port, &hints, &result);
573
if (r != 0) {
574
- error("LISTENER: getaddrinfo('%s', '%s'): %s\n", ip, port, gai_strerror(r));
574
+ netdata_log_error("LISTENER: getaddrinfo('%s', '%s'): %s\n", ip, port, gai_strerror(r));
575
return -1;
576
}
577
@@ -608,7 +608,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
608
}
609
610
if (fd == -1) {
611
- error("LISTENER: Cannot bind to ip '%s', port %d", rip, rport);
611
+ netdata_log_error("LISTENER: Cannot bind to ip '%s', port %d", rip, rport);
612
sockets->failed++;
613
}
614
else {
@@ -630,7 +630,7 @@ int listen_sockets_setup(LISTEN_SOCKETS *sockets) {
630
long long int old_port = sockets->default_port;
631
long long int new_port = appconfig_get_number(sockets->config, sockets->config_section, "default port", sockets->default_port);
632
if(new_port < 1 || new_port > 65535) {
633
- error("LISTENER: Invalid listen port %lld given. Defaulting to %lld.", new_port, old_port);
633
+ netdata_log_error("LISTENER: Invalid listen port %lld given. Defaulting to %lld.", new_port, old_port);
634
sockets->default_port = (uint16_t) appconfig_set_number(sockets->config, sockets->config_section, "default port", old_port);
635
}
636
else sockets->default_port = (uint16_t)new_port;
@@ -677,13 +677,13 @@ int listen_sockets_setup(LISTEN_SOCKETS *sockets) {
677
static inline int connect_to_unix(const char *path, struct timeval *timeout) {
678
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
679
if(fd == -1) {
680
- error("Failed to create UNIX socket() for '%s'", path);
680
+ netdata_log_error("Failed to create UNIX socket() for '%s'", path);
681
return -1;
682
}
683
684
if(timeout) {
685
if(setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *) timeout, sizeof(struct timeval)) < 0)
686
- error("Failed to set timeout on UNIX socket '%s'", path);
686
+ netdata_log_error("Failed to set timeout on UNIX socket '%s'", path);
687
}
688
689
struct sockaddr_un addr;
@@ -692,7 +692,7 @@ static inline int connect_to_unix(const char *path, struct timeval *timeout) {
692
strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1);
693
694
if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
695
- error("Cannot connect to UNIX socket on path '%s'.", path);
695
+ netdata_log_error("Cannot connect to UNIX socket on path '%s'.", path);
696
close(fd);
697
return -1;
698
}
@@ -723,7 +723,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
723
724
int ai_err = getaddrinfo(host, service, &hints, &ai_head);
725
if (ai_err != 0) {
726
- error("Cannot resolve host '%s', port '%s': %s", host, service, gai_strerror(ai_err));
726
+ netdata_log_error("Cannot resolve host '%s', port '%s': %s", host, service, gai_strerror(ai_err));
727
return -1;
728
}
729
@@ -804,7 +804,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
804
if(fd != -1) {
805
if(timeout) {
806
if(setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *) timeout, sizeof(struct timeval)) < 0)
807
- error("Failed to set timeout on the socket to ip '%s' port '%s'", hostBfr, servBfr);
807
+ netdata_log_error("Failed to set timeout on the socket to ip '%s' port '%s'", hostBfr, servBfr);
808
}
809
810
errno = 0;
@@ -828,26 +828,26 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
828
}
829
else {
830
// This means that the socket is in error. We will close it and set fd to -1
831
- error("Failed to connect to '%s', port '%s'.", hostBfr, servBfr);
831
+ netdata_log_error("Failed to connect to '%s', port '%s'.", hostBfr, servBfr);
832
close(fd);
833
fd = -1;
834
}
835
}
836
else if (ret == 0) {
837
// poll() timed out, the connection is not established within the specified timeout.
838
- error("Timed out while connecting to '%s', port '%s'.", hostBfr, servBfr);
838
+ netdata_log_error("Timed out while connecting to '%s', port '%s'.", hostBfr, servBfr);
839
close(fd);
840
fd = -1;
841
}
842
else {
843
// poll() returned an error.
844
- error("Failed to connect to '%s', port '%s'. poll() returned %d", hostBfr, servBfr, ret);
844
+ netdata_log_error("Failed to connect to '%s', port '%s'. poll() returned %d", hostBfr, servBfr, ret);
845
close(fd);
846
fd = -1;
847
}
848
}
849
else {
850
- error("Failed to connect to '%s', port '%s'", hostBfr, servBfr);
850
+ netdata_log_error("Failed to connect to '%s', port '%s'", hostBfr, servBfr);
851
close(fd);
852
fd = -1;
853
}
@@ -933,14 +933,14 @@ int connect_to_this(const char *definition, int default_port, struct timeval *ti
933
debug(D_CONNECT_TO, "Attempting connection to host = '%s', service = '%s', interface = '%s', protocol = %d (tcp = %d, udp = %d)", host, service, interface, protocol, IPPROTO_TCP, IPPROTO_UDP);
934
935
if(!*host) {
936
- error("Definition '%s' does not specify a host.", definition);
936
+ netdata_log_error("Definition '%s' does not specify a host.", definition);
937
return -1;
938
}
939
940
if(*interface) {
941
scope_id = if_nametoindex(interface);
942
if(!scope_id)
943
- error("Cannot find a network interface named '%s'. Continuing with limiting the network interface", interface);
943
+ netdata_log_error("Cannot find a network interface named '%s'. Continuing with limiting the network interface", interface);
944
}
945
946
if(!*service)
@@ -1125,7 +1125,7 @@ ssize_t send_timeout(int sockfd, void *buf, size_t len, int flags, int timeout)
1125
return netdata_ssl_write(ssl, buf, len);
1126
}
1127
else {
1128
- error("cannot write to SSL connection - connection is not ready.");
1128
+ netdata_log_error("cannot write to SSL connection - connection is not ready.");
1129
return -1;
1130
}
1131
}
@@ -1204,7 +1204,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi
1204
if (err != 0 ||
1205
(err = getnameinfo((struct sockaddr *)&sadr, addrlen, client_host, (socklen_t)hostsize,
1206
NULL, 0, NI_NAMEREQD)) != 0) {
1207
- error("Incoming %s on '%s' does not match a numeric pattern, and host could not be resolved (err=%s)",
1207
+ netdata_log_error("Incoming %s on '%s' does not match a numeric pattern, and host could not be resolved (err=%s)",
1208
patname, client_ip, gai_strerror(err));
1209
if (hostsize >= 8)
1210
strcpy(client_host,"UNKNOWN");
@@ -1212,7 +1212,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi
1212
}
1213
struct addrinfo *addr_infos = NULL;
1214
if (getaddrinfo(client_host, NULL, NULL, &addr_infos) !=0 ) {
1215
- error("LISTENER: cannot validate hostname '%s' from '%s' by resolving it",
1215
+ netdata_log_error("LISTENER: cannot validate hostname '%s' from '%s' by resolving it",
1216
client_host, client_ip);
1217
if (hostsize >= 8)
1218
strcpy(client_host,"UNKNOWN");
@@ -1240,7 +1240,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi
1240
scan = scan->ai_next;
1241
}
1242
if (!validated) {
1243
- error("LISTENER: Cannot validate '%s' as ip of '%s', not listed in DNS", client_ip, client_host);
1243
+ netdata_log_error("LISTENER: Cannot validate '%s' as ip of '%s', not listed in DNS", client_ip, client_host);
1244
if (hostsize >= 8)
1245
strcpy(client_host,"UNKNOWN");
1246
}
@@ -1266,7 +1266,7 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien
1266
if (likely(nfd >= 0)) {
1267
if (getnameinfo((struct sockaddr *)&sadr, addrlen, client_ip, (socklen_t)ipsize,
1268
client_port, (socklen_t)portsize, NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
1269
- error("LISTENER: cannot getnameinfo() on received client connection.");
1269
+ netdata_log_error("LISTENER: cannot getnameinfo() on received client connection.");
1270
strncpyz(client_ip, "UNKNOWN", ipsize);
1271
strncpyz(client_port, "UNKNOWN", portsize);
1272
}
@@ -1308,7 +1308,7 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien
1308
}
1309
if (!connection_allowed(nfd, client_ip, client_host, hostsize, access_list, "connection", allow_dns)) {
1310
errno = 0;
1311
- error("Permission denied for client '%s', port '%s'", client_ip, client_port);
1311
+ netdata_log_error("Permission denied for client '%s', port '%s'", client_ip, client_port);
1312
close(nfd);
1313
nfd = -1;
1314
errno = EPERM;
@@ -1316,7 +1316,7 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien
1316
}
1317
#ifdef HAVE_ACCEPT4
1318
else if (errno == ENOSYS)
1319
- error("netdata has been compiled with the assumption that the system has the accept4() call, but it is not here. Recompile netdata like this: ./configure --disable-accept4 ...");
1319
+ netdata_log_error("netdata has been compiled with the assumption that the system has the accept4() call, but it is not here. Recompile netdata like this: ./configure --disable-accept4 ...");
1320
#endif
1321
1322
return nfd;
@@ -1457,7 +1457,7 @@ inline void poll_close_fd(POLLINFO *pi) {
1457
1458
if(likely(!(pi->flags & POLLINFO_FLAG_DONT_CLOSE))) {
1459
if(close(pf->fd) == -1)
1460
- error("Failed to close() poll_events() socket %d", pf->fd);
1460
+ netdata_log_error("Failed to close() poll_events() socket %d", pf->fd);
1461
}
1462
}
1463
@@ -1507,14 +1507,14 @@ void *poll_default_add_callback(POLLINFO *pi, short int *events, void *data) {
1507
(void)events;
1508
(void)data;
1509
1510
- // error("POLLFD: internal error: poll_default_add_callback() called");
1510
+ // netdata_log_error("POLLFD: internal error: poll_default_add_callback() called");
1511
1512
return NULL;
1513
}
1514
1515
void poll_default_del_callback(POLLINFO *pi) {
1516
if(pi->data)
1517
- error("POLLFD: internal error: del_callback_default() called with data pointer - possible memory leak");
1517
+ netdata_log_error("POLLFD: internal error: del_callback_default() called with data pointer - possible memory leak");
1518
}
1519
1520
int poll_default_rcv_callback(POLLINFO *pi, short int *events) {
@@ -1528,7 +1528,7 @@ int poll_default_rcv_callback(POLLINFO *pi, short int *events) {
1528
if (rc < 0) {
1529
// read failed
1530
if (errno != EWOULDBLOCK && errno != EAGAIN) {
1531
- error("POLLFD: poll_default_rcv_callback(): recv() failed with %zd.", rc);
1531
+ netdata_log_error("POLLFD: poll_default_rcv_callback(): recv() failed with %zd.", rc);
1532
return -1;
1533
}
1534
} else if (rc) {
@@ -1565,7 +1565,7 @@ static void poll_events_cleanup(void *data) {
1565
}
1566
1567
static int poll_process_error(POLLINFO *pi, struct pollfd *pf, short int revents) {
1568
- error("POLLFD: LISTENER: received %s %s %s on socket at slot %zu (fd %d) client '%s' port '%s' expecting %s %s %s, having %s %s %s"
1568
+ netdata_log_error("POLLFD: LISTENER: received %s %s %s on socket at slot %zu (fd %d) client '%s' port '%s' expecting %s %s %s, having %s %s %s"
1569
, revents & POLLERR ? "POLLERR" : ""
1570
, revents & POLLHUP ? "POLLHUP" : ""
1571
, revents & POLLNVAL ? "POLLNVAL" : ""
@@ -1673,7 +1673,7 @@ static int poll_process_new_tcp_connection(POLLJOB *p, POLLINFO *pi, struct poll
1673
p->used, p->limit);
1674
}
1675
else if(unlikely(errno != EWOULDBLOCK && errno != EAGAIN))
1676
- error("POLLFD: LISTENER: accept() failed.");
1676
+ netdata_log_error("POLLFD: LISTENER: accept() failed.");
1677
1678
}
1679
else {
@@ -1720,7 +1720,7 @@ void poll_events(LISTEN_SOCKETS *sockets
1720
, size_t max_tcp_sockets
1721
) {
1722
if(!sockets || !sockets->opened) {
1723
- error("POLLFD: internal error: no listening sockets are opened");
1723
+ netdata_log_error("POLLFD: internal error: no listening sockets are opened");
1724
return;
1725
}
1726
@@ -1827,7 +1827,7 @@ void poll_events(LISTEN_SOCKETS *sockets
1827
time_t now = now_boottime_sec();
1828
1829
if(unlikely(retval == -1)) {
1830
- error("POLLFD: LISTENER: poll() failed while waiting on %zu sockets.", p.max + 1);
1830
+ netdata_log_error("POLLFD: LISTENER: poll() failed while waiting on %zu sockets.", p.max + 1);
1831
break;
1832
}
1833
else if(unlikely(!retval)) {
@@ -1885,7 +1885,7 @@ void poll_events(LISTEN_SOCKETS *sockets
1885
conns[conns_max++] = i;
1886
}
1887
else
1888
- error("POLLFD: LISTENER: server slot %zu (fd %d) connection from %s port %s using unhandled socket type %d."
1888
+ netdata_log_error("POLLFD: LISTENER: server slot %zu (fd %d) connection from %s port %s using unhandled socket type %d."
1889
, i
1890
, pi->fd
1891
, pi->client_ip ? pi->client_ip : "<undefined-ip>"
@@ -1894,7 +1894,7 @@ void poll_events(LISTEN_SOCKETS *sockets
1894
);
1895
}
1896
else
1897
- error("POLLFD: LISTENER: client slot %zu (fd %d) data from %s port %s using flags %08X is neither client nor server."
1897
+ netdata_log_error("POLLFD: LISTENER: client slot %zu (fd %d) data from %s port %s using flags %08X is neither client nor server."
1898
, i
1899
, pi->fd
1900
, pi->client_ip ? pi->client_ip : "<undefined-ip>"
@@ -1903,7 +1903,7 @@ void poll_events(LISTEN_SOCKETS *sockets
1903
);
1904
}
1905
else
1906
- error("POLLFD: LISTENER: socket slot %zu (fd %d) client %s port %s unhandled event id %d."
1906
+ netdata_log_error("POLLFD: LISTENER: socket slot %zu (fd %d) client %s port %s unhandled event id %d."
1907
, i
1908
, pi->fd
1909
, pi->client_ip ? pi->client_ip : "<undefined-ip>"
libnetdata/storage_number/storage_number.c
+1
-1
@@ -121,7 +121,7 @@ storage_number pack_storage_number(NETDATA_DOUBLE value, SN_FLAGS flags) {
121
122
if(n > (NETDATA_DOUBLE)0x00ffffff) {
123
#ifdef NETDATA_INTERNAL_CHECKS
124
- error("Number " NETDATA_DOUBLE_FORMAT " is too big.", value);
124
+ netdata_log_error("Number " NETDATA_DOUBLE_FORMAT " is too big.", value);
125
#endif
126
r += 0x00ffffff;
127
return r;
libnetdata/string/string.c
+2
-2
@@ -240,7 +240,7 @@ static inline void string_index_delete(STRING *string) {
240
JError_t J_Error;
241
int ret = JudyHSDel(&string_base.JudyHSArray, (void *)string->str, string->length, &J_Error);
242
if (unlikely(ret == JERR)) {
243
- error(
243
+ netdata_log_error(
244
"STRING: Cannot delete entry with name '%s' from JudyHS, JU_ERRNO_* == %u, ID == %d",
245
string->str,
246
JU_ERRNO(&J_Error),
@@ -250,7 +250,7 @@ static inline void string_index_delete(STRING *string) {
250
}
251
252
if (unlikely(!deleted))
253
- error("STRING: tried to delete '%s' that is not in the index. Ignoring it.", string->str);
253
+ netdata_log_error("STRING: tried to delete '%s' that is not in the index. Ignoring it.", string->str);
254
else {
255
size_t mem_size = sizeof(STRING) + string->length;
256
string_base.deletes++;
libnetdata/threads/threads.c
+12
-12
@@ -150,12 +150,12 @@ void netdata_threads_init_after_fork(size_t stacksize) {
150
if(netdata_threads_attr && stacksize > (size_t)PTHREAD_STACK_MIN) {
151
i = pthread_attr_setstacksize(netdata_threads_attr, stacksize);
152
if(i != 0)
153
- error("pthread_attr_setstacksize() to %zu bytes, failed with code %d.", stacksize, i);
153
+ netdata_log_error("pthread_attr_setstacksize() to %zu bytes, failed with code %d.", stacksize, i);
154
else
155
netdata_log_info("Set threads stack size to %zu bytes", stacksize);
156
}
157
else
158
- error("Invalid pthread stacksize %zu", stacksize);
158
+ netdata_log_error("Invalid pthread stacksize %zu", stacksize);
159
}
160
161
// ----------------------------------------------------------------------------
@@ -169,7 +169,7 @@ void service_exits(void);
169
static void thread_cleanup(void *ptr) {
170
if(netdata_thread != ptr) {
171
NETDATA_THREAD *info = (NETDATA_THREAD *)ptr;
172
- error("THREADS: internal error - thread local variable does not match the one passed to this function. Expected thread '%s', passed thread '%s'", netdata_thread->tag, info->tag);
172
+ netdata_log_error("THREADS: internal error - thread local variable does not match the one passed to this function. Expected thread '%s', passed thread '%s'", netdata_thread->tag, info->tag);
173
}
174
175
if(!(netdata_thread->options & NETDATA_THREAD_OPTION_DONT_LOG_CLEANUP))
@@ -205,7 +205,7 @@ static void thread_set_name_np(NETDATA_THREAD *nt) {
205
#endif
206
207
if (ret != 0)
208
- error("cannot set pthread name of %d to %s. ErrCode: %d", gettid(), threadname, ret);
208
+ netdata_log_error("cannot set pthread name of %d to %s. ErrCode: %d", gettid(), threadname, ret);
209
else
210
netdata_log_info("set name of thread %d to %s", gettid(), threadname);
211
@@ -250,10 +250,10 @@ static void *netdata_thread_init(void *ptr) {
250
netdata_log_info("thread created with task id %d", gettid());
251
252
if(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) != 0)
253
- error("cannot set pthread cancel type to DEFERRED.");
253
+ netdata_log_error("cannot set pthread cancel type to DEFERRED.");
254
255
if(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) != 0)
256
- error("cannot set pthread cancel state to ENABLE.");
256
+ netdata_log_error("cannot set pthread cancel state to ENABLE.");
257
258
thread_set_name_np(ptr);
259
@@ -275,13 +275,13 @@ int netdata_thread_create(netdata_thread_t *thread, const char *tag, NETDATA_THR
275
276
int ret = pthread_create(thread, netdata_threads_attr, netdata_thread_init, info);
277
if(ret != 0)
278
- error("failed to create new thread for %s. pthread_create() failed with code %d", tag, ret);
278
+ netdata_log_error("failed to create new thread for %s. pthread_create() failed with code %d", tag, ret);
279
280
else {
281
if (!(options & NETDATA_THREAD_OPTION_JOINABLE)) {
282
int ret2 = pthread_detach(*thread);
283
if (ret2 != 0)
284
- error("cannot request detach of newly created %s thread. pthread_detach() failed with code %d", tag, ret2);
284
+ netdata_log_error("cannot request detach of newly created %s thread. pthread_detach() failed with code %d", tag, ret2);
285
}
286
}
287
@@ -298,9 +298,9 @@ int netdata_thread_cancel(netdata_thread_t thread) {
298
int ret = pthread_cancel(thread);
299
if(ret != 0)
300
#ifdef NETDATA_INTERNAL_CHECKS
301
- error("cannot cancel thread. pthread_cancel() failed with code %d at %d@%s, function %s()", ret, line, file, function);
301
+ netdata_log_error("cannot cancel thread. pthread_cancel() failed with code %d at %d@%s, function %s()", ret, line, file, function);
302
#else
303
- error("cannot cancel thread. pthread_cancel() failed with code %d.", ret);
303
+ netdata_log_error("cannot cancel thread. pthread_cancel() failed with code %d.", ret);
304
#endif
305
306
return ret;
@@ -312,7 +312,7 @@ int netdata_thread_cancel(netdata_thread_t thread) {
312
int netdata_thread_join(netdata_thread_t thread, void **retval) {
313
int ret = pthread_join(thread, retval);
314
if(ret != 0)
315
- error("cannot join thread. pthread_join() failed with code %d.", ret);
315
+ netdata_log_error("cannot join thread. pthread_join() failed with code %d.", ret);
316
317
return ret;
318
}
@@ -320,7 +320,7 @@ int netdata_thread_join(netdata_thread_t thread, void **retval) {
320
int netdata_thread_detach(pthread_t thread) {
321
int ret = pthread_detach(thread);
322
if(ret != 0)
323
- error("cannot detach thread. pthread_detach() failed with code %d.", ret);
323
+ netdata_log_error("cannot detach thread. pthread_detach() failed with code %d.", ret);
324
325
return ret;
326
}
libnetdata/worker_utilization/worker_utilization.c
+2
-2
@@ -118,7 +118,7 @@ void worker_register_job_custom_metric(size_t job_id, const char *name, const ch
118
if(unlikely(!worker)) return;
119
120
if(unlikely(job_id >= WORKER_UTILIZATION_MAX_JOB_TYPES)) {
121
- error("WORKER_UTILIZATION: job_id %zu is too big. Max is %zu", job_id, (size_t)(WORKER_UTILIZATION_MAX_JOB_TYPES - 1));
121
+ netdata_log_error("WORKER_UTILIZATION: job_id %zu is too big. Max is %zu", job_id, (size_t)(WORKER_UTILIZATION_MAX_JOB_TYPES - 1));
122
return;
123
}
124
@@ -127,7 +127,7 @@ void worker_register_job_custom_metric(size_t job_id, const char *name, const ch
127
128
if(worker->per_job_type[job_id].name) {
129
if(strcmp(string2str(worker->per_job_type[job_id].name), name) != 0 || worker->per_job_type[job_id].type != type || strcmp(string2str(worker->per_job_type[job_id].units), units) != 0)
130
- error("WORKER_UTILIZATION: duplicate job registration: worker '%s' job id %zu is '%s', ignoring the later '%s'", worker->workname, job_id, string2str(worker->per_job_type[job_id].name), name);
130
+ netdata_log_error("WORKER_UTILIZATION: duplicate job registration: worker '%s' job id %zu is '%s', ignoring the later '%s'", worker->workname, job_id, string2str(worker->per_job_type[job_id].name), name);
131
return;
132
}
133
ml/Config.cc
+1
-1
@@ -83,7 +83,7 @@ void ml_config_load(ml_config_t *cfg) {
83
*/
84
85
if (min_train_samples >= max_train_samples) {
86
- error("invalid min/max train samples found (%u >= %u)", min_train_samples, max_train_samples);
86
+ netdata_log_error("invalid min/max train samples found (%u >= %u)", min_train_samples, max_train_samples);
87
88
min_train_samples = 1 * 3600;
89
max_train_samples = 6 * 3600;
ml/ml.cc
+3
-3
@@ -1390,7 +1390,7 @@ void ml_host_get_models(RRDHOST *rh, BUFFER *wb)
1390
UNUSED(wb);
1391
1392
// TODO: To be implemented
1393
- error("Fetching KMeans models is not supported yet");
1393
+ netdata_log_error("Fetching KMeans models is not supported yet");
1394
}
1395
1396
void ml_chart_new(RRDSET *rs)
@@ -1519,11 +1519,11 @@ static void ml_flush_pending_models(ml_training_thread_t *training_thread) {
1519
1520
// try to rollback transaction if we got any failures
1521
if (rc) {
1522
- error("Trying to rollback ML transaction because it failed with rc=%d, op_no=%d", rc, op_no);
1522
+ netdata_log_error("Trying to rollback ML transaction because it failed with rc=%d, op_no=%d", rc, op_no);
1523
op_no++;
1524
rc = db_execute(db, "ROLLBACK;");
1525
if (rc)
1526
- error("ML transaction rollback failed with rc=%d", rc);
1526
+ netdata_log_error("ML transaction rollback failed with rc=%d", rc);
1527
}
1528
1529
training_thread->pending_model_info.clear();
registry/registry_db.c
+19
-19
@@ -122,7 +122,7 @@ int registry_db_save(void) {
122
debug(D_REGISTRY, "Registry: Creating file '%s'", tmp_filename);
123
FILE *fp = fopen(tmp_filename, "w");
124
if(!fp) {
125
- error("Registry: Cannot create file: %s", tmp_filename);
125
+ netdata_log_error("Registry: Cannot create file: %s", tmp_filename);
126
error_log_limit_reset();
127
return -1;
128
}
@@ -132,7 +132,7 @@ int registry_db_save(void) {
132
debug(D_REGISTRY, "Saving all machines");
133
int bytes1 = dictionary_walkthrough_read(registry.machines, registry_machine_save, fp);
134
if(bytes1 < 0) {
135
- error("Registry: Cannot save registry machines - return value %d", bytes1);
135
+ netdata_log_error("Registry: Cannot save registry machines - return value %d", bytes1);
136
fclose(fp);
137
error_log_limit_reset();
138
return bytes1;
@@ -142,7 +142,7 @@ int registry_db_save(void) {
142
debug(D_REGISTRY, "Saving all persons");
143
int bytes2 = dictionary_walkthrough_read(registry.persons, registry_person_save, fp);
144
if(bytes2 < 0) {
145
- error("Registry: Cannot save registry persons - return value %d", bytes2);
145
+ netdata_log_error("Registry: Cannot save registry persons - return value %d", bytes2);
146
fclose(fp);
147
error_log_limit_reset();
148
return bytes2;
@@ -166,34 +166,34 @@ int registry_db_save(void) {
166
// remove the .old db
167
debug(D_REGISTRY, "Registry: Removing old db '%s'", old_filename);
168
if(unlink(old_filename) == -1 && errno != ENOENT)
169
- error("Registry: cannot remove old registry file '%s'", old_filename);
169
+ netdata_log_error("Registry: cannot remove old registry file '%s'", old_filename);
170
171
// rename the db to .old
172
debug(D_REGISTRY, "Registry: Link current db '%s' to .old: '%s'", registry.db_filename, old_filename);
173
if(link(registry.db_filename, old_filename) == -1 && errno != ENOENT)
174
- error("Registry: cannot move file '%s' to '%s'. Saving registry DB failed!", registry.db_filename, old_filename);
174
+ netdata_log_error("Registry: cannot move file '%s' to '%s'. Saving registry DB failed!", registry.db_filename, old_filename);
175
176
else {
177
// remove the database (it is saved in .old)
178
debug(D_REGISTRY, "Registry: removing db '%s'", registry.db_filename);
179
if (unlink(registry.db_filename) == -1 && errno != ENOENT)
180
- error("Registry: cannot remove old registry file '%s'", registry.db_filename);
180
+ netdata_log_error("Registry: cannot remove old registry file '%s'", registry.db_filename);
181
182
// move the .tmp to make it active
183
debug(D_REGISTRY, "Registry: linking tmp db '%s' to active db '%s'", tmp_filename, registry.db_filename);
184
if (link(tmp_filename, registry.db_filename) == -1) {
185
- error("Registry: cannot move file '%s' to '%s'. Saving registry DB failed!", tmp_filename,
185
+ netdata_log_error("Registry: cannot move file '%s' to '%s'. Saving registry DB failed!", tmp_filename,
186
registry.db_filename);
187
188
// move the .old back
189
debug(D_REGISTRY, "Registry: linking old db '%s' to active db '%s'", old_filename, registry.db_filename);
190
if(link(old_filename, registry.db_filename) == -1)
191
- error("Registry: cannot move file '%s' to '%s'. Recovering the old registry DB failed!", old_filename, registry.db_filename);
191
+ netdata_log_error("Registry: cannot move file '%s' to '%s'. Recovering the old registry DB failed!", old_filename, registry.db_filename);
192
}
193
else {
194
debug(D_REGISTRY, "Registry: removing tmp db '%s'", tmp_filename);
195
if(unlink(tmp_filename) == -1)
196
- error("Registry: cannot remove tmp registry file '%s'", tmp_filename);
196
+ netdata_log_error("Registry: cannot remove tmp registry file '%s'", tmp_filename);
197
198
// it has been moved successfully
199
// discard the current registry log
@@ -221,7 +221,7 @@ size_t registry_db_load(void) {
221
debug(D_REGISTRY, "Registry: loading active db from: '%s'", registry.db_filename);
222
FILE *fp = fopen(registry.db_filename, "r");
223
if(!fp) {
224
- error("Registry: cannot open registry file: '%s'", registry.db_filename);
224
+ netdata_log_error("Registry: cannot open registry file: '%s'", registry.db_filename);
225
return 0;
226
}
227
@@ -234,7 +234,7 @@ size_t registry_db_load(void) {
234
switch(*s) {
235
case 'T': // totals
236
if(unlikely(len != 103 || s[1] != '\t' || s[18] != '\t' || s[35] != '\t' || s[52] != '\t' || s[69] != '\t' || s[86] != '\t' || s[103] != '\0')) {
237
- error("Registry totals line %zu is wrong (len = %zu).", line, len);
237
+ netdata_log_error("Registry totals line %zu is wrong (len = %zu).", line, len);
238
continue;
239
}
240
registry.persons_count = strtoull(&s[2], NULL, 16);
@@ -249,7 +249,7 @@ size_t registry_db_load(void) {
249
m = NULL;
250
// verify it is valid
251
if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
252
- error("Registry person line %zu is wrong (len = %zu).", line, len);
252
+ netdata_log_error("Registry person line %zu is wrong (len = %zu).", line, len);
253
continue;
254
}
255
@@ -264,7 +264,7 @@ size_t registry_db_load(void) {
264
p = NULL;
265
// verify it is valid
266
if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
267
- error("Registry person line %zu is wrong (len = %zu).", line, len);
267
+ netdata_log_error("Registry person line %zu is wrong (len = %zu).", line, len);
268
continue;
269
}
270
@@ -277,13 +277,13 @@ size_t registry_db_load(void) {
277
278
case 'U': // person URL
279
if(unlikely(!p)) {
280
- error("Registry: ignoring line %zu, no person loaded: %s", line, s);
280
+ netdata_log_error("Registry: ignoring line %zu, no person loaded: %s", line, s);
281
continue;
282
}
283
284
// verify it is valid
285
if(len < 69 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t' || s[68] != '\t') {
286
- error("Registry person URL line %zu is wrong (len = %zu).", line, len);
286
+ netdata_log_error("Registry person URL line %zu is wrong (len = %zu).", line, len);
287
continue;
288
}
289
@@ -293,7 +293,7 @@ size_t registry_db_load(void) {
293
char *url = &s[69];
294
while(*url && *url != '\t') url++;
295
if(!*url) {
296
- error("Registry person URL line %zu does not have a url.", line);
296
+ netdata_log_error("Registry person URL line %zu does not have a url.", line);
297
continue;
298
}
299
*url++ = '\0';
@@ -315,13 +315,13 @@ size_t registry_db_load(void) {
315
316
case 'V': // machine URL
317
if(unlikely(!m)) {
318
- error("Registry: ignoring line %zu, no machine loaded: %s", line, s);
318
+ netdata_log_error("Registry: ignoring line %zu, no machine loaded: %s", line, s);
319
continue;
320
}
321
322
// verify it is valid
323
if(len < 32 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t') {
324
- error("Registry person URL line %zu is wrong (len = %zu).", line, len);
324
+ netdata_log_error("Registry person URL line %zu is wrong (len = %zu).", line, len);
325
continue;
326
}
327
@@ -337,7 +337,7 @@ size_t registry_db_load(void) {
337
break;
338
339
default:
340
- error("Registry: ignoring line %zu of filename '%s': %s.", line, registry.db_filename, s);
340
+ netdata_log_error("Registry: ignoring line %zu of filename '%s': %s.", line, registry.db_filename, s);
341
break;
342
}
343
}
registry/registry_internals.c
+3
-3
@@ -270,7 +270,7 @@ static inline int is_machine_guid_blacklisted(const char *guid) {
270
if(!strcmp(guid, "8a795b0c-2311-11e6-8563-000c295076a6")
271
|| !strcmp(guid, "4aed1458-1c3e-11e6-a53f-000c290fc8f5")
272
) {
273
- error("Blacklisted machine GUID '%s' found.", guid);
273
+ netdata_log_error("Blacklisted machine GUID '%s' found.", guid);
274
return 1;
275
}
276
@@ -292,11 +292,11 @@ char *registry_get_this_machine_guid(void) {
292
if(fd != -1) {
293
char buf[GUID_LEN + 1];
294
if(read(fd, buf, GUID_LEN) != GUID_LEN)
295
- error("Failed to read machine GUID from '%s'", registry.machine_guid_filename);
295
+ netdata_log_error("Failed to read machine GUID from '%s'", registry.machine_guid_filename);
296
else {
297
buf[GUID_LEN] = '\0';
298
if(regenerate_guid(buf, guid) == -1) {
299
- error("Failed to validate machine GUID '%s' from '%s'. Ignoring it - this might mean this netdata will appear as duplicate in the registry.",
299
+ netdata_log_error("Failed to validate machine GUID '%s' from '%s'. Ignoring it - this might mean this netdata will appear as duplicate in the registry.",
300
buf, registry.machine_guid_filename);
301
302
guid[0] = '\0';
registry/registry_log.c
+9
-8
@@ -12,7 +12,7 @@ void registry_log(char action, REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY
12
m->guid,
13
name,
14
u->url) < 0))
15
- error("Registry: failed to save log. Registry data may be lost in case of abnormal restart.");
15
+ netdata_log_error("Registry: failed to save log. Registry data may be lost in case of abnormal restart.");
16
17
// we increase the counter even on failures
18
// so that the registry will be saved periodically
@@ -33,11 +33,11 @@ int registry_log_open(void) {
33
registry.log_fp = fopen(registry.log_filename, "a");
34
if(registry.log_fp) {
35
if (setvbuf(registry.log_fp, NULL, _IOLBF, 0) != 0)
36
- error("Cannot set line buffering on registry log file.");
36
+ netdata_log_error("Cannot set line buffering on registry log file.");
37
return 0;
38
}
39
40
- error("Cannot open registry log file '%s'. Registry data will be lost in case of netdata or server crash.", registry.log_filename);
40
+ netdata_log_error("Cannot open registry log file '%s'. Registry data will be lost in case of netdata or server crash.", registry.log_filename);
41
return -1;
42
}
43
@@ -55,7 +55,8 @@ void registry_log_recreate(void) {
55
// open it with truncate
56
registry.log_fp = fopen(registry.log_filename, "w");
57
if(registry.log_fp) fclose(registry.log_fp);
58
- else error("Cannot truncate registry log '%s'", registry.log_filename);
58
+ else
59
+ netdata_log_error("Cannot truncate registry log '%s'", registry.log_filename);
60
61
registry.log_fp = NULL;
62
registry_log_open();
@@ -72,7 +73,7 @@ ssize_t registry_log_load(void) {
73
debug(D_REGISTRY, "Registry: loading active db from: %s", registry.log_filename);
74
FILE *fp = fopen(registry.log_filename, "r");
75
if(!fp)
75
- error("Registry: cannot open registry file: %s", registry.log_filename);
76
+ netdata_log_error("Registry: cannot open registry file: %s", registry.log_filename);
77
else {
78
char *s, buf[4096 + 1];
79
line = 0;
@@ -87,7 +88,7 @@ ssize_t registry_log_load(void) {
88
89
// verify it is valid
90
if (unlikely(len < 85 || s[1] != '\t' || s[10] != '\t' || s[47] != '\t' || s[84] != '\t')) {
90
- error("Registry: log line %zd is wrong (len = %zu).", line, len);
91
+ netdata_log_error("Registry: log line %zd is wrong (len = %zu).", line, len);
92
continue;
93
}
94
s[1] = s[10] = s[47] = s[84] = '\0';
@@ -102,7 +103,7 @@ ssize_t registry_log_load(void) {
103
char *url = name;
104
while(*url && *url != '\t') url++;
105
if(!*url) {
105
- error("Registry: log line %zd does not have a url.", line);
106
+ netdata_log_error("Registry: log line %zd does not have a url.", line);
107
continue;
108
}
109
*url++ = '\0';
@@ -121,7 +122,7 @@ ssize_t registry_log_load(void) {
122
break;
123
124
default:
124
- error("Registry: ignoring line %zd of filename '%s': %s.", line, registry.log_filename, s);
125
+ netdata_log_error("Registry: ignoring line %zd of filename '%s': %s.", line, registry.log_filename, s);
126
break;
127
}
128
}
registry/registry_person.c
+4
-4
@@ -34,7 +34,7 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, RE
34
debug(D_REGISTRY, "Registry: registry_person_url_index_add('%s', '%s')", p->guid, pu->url->url);
35
REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_insert(&(p->person_urls), (avl_t *)(pu));
36
if(tpu != pu)
37
- error("Registry: registry_person_url_index_add('%s', '%s') already exists as '%s'", p->guid, pu->url->url, tpu->url->url);
37
+ netdata_log_error("Registry: registry_person_url_index_add('%s', '%s') already exists as '%s'", p->guid, pu->url->url, tpu->url->url);
38
39
return tpu;
40
}
@@ -43,9 +43,9 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, RE
43
debug(D_REGISTRY, "Registry: registry_person_url_index_del('%s', '%s')", p->guid, pu->url->url);
44
REGISTRY_PERSON_URL *tpu = (REGISTRY_PERSON_URL *)avl_remove(&(p->person_urls), (avl_t *)(pu));
45
if(!tpu)
46
- error("Registry: registry_person_url_index_del('%s', '%s') deleted nothing", p->guid, pu->url->url);
46
+ netdata_log_error("Registry: registry_person_url_index_del('%s', '%s') deleted nothing", p->guid, pu->url->url);
47
else if(tpu != pu)
48
- error("Registry: registry_person_url_index_del('%s', '%s') deleted wrong URL '%s'", p->guid, pu->url->url, tpu->url->url);
48
+ netdata_log_error("Registry: registry_person_url_index_del('%s', '%s') deleted wrong URL '%s'", p->guid, pu->url->url, tpu->url->url);
49
50
return tpu;
51
}
@@ -78,7 +78,7 @@ REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_M
78
debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): indexing URL in person", p->guid, m->guid, u->url);
79
REGISTRY_PERSON_URL *tpu = registry_person_url_index_add(p, pu);
80
if(tpu != pu) {
81
- error("Registry: Attempted to add duplicate person url '%s' with name '%s' to person '%s'", u->url, name, p->guid);
81
+ netdata_log_error("Registry: Attempted to add duplicate person url '%s' with name '%s' to person '%s'", u->url, name, p->guid);
82
freez(pu);
83
pu = tpu;
84
}
registry/registry_url.c
+3
-3
@@ -50,7 +50,7 @@ REGISTRY_URL *registry_url_get(const char *url, size_t urllen) {
50
debug(D_REGISTRY, "Registry: registry_url_get('%s'): indexing it", url);
51
n = registry_url_index_add(u);
52
if(n != u) {
53
- error("INTERNAL ERROR: registry_url_get(): url '%s' already exists in the registry as '%s'", u->url, n->url);
53
+ netdata_log_error("INTERNAL ERROR: registry_url_get(): url '%s' already exists in the registry as '%s'", u->url, n->url);
54
freez(u);
55
u = n;
56
}
@@ -72,11 +72,11 @@ void registry_url_unlink(REGISTRY_URL *u) {
72
debug(D_REGISTRY, "Registry: registry_url_unlink('%s'): No more links for this URL", u->url);
73
REGISTRY_URL *n = registry_url_index_del(u);
74
if(!n) {
75
- error("INTERNAL ERROR: registry_url_unlink('%s'): cannot find url in index", u->url);
75
+ netdata_log_error("INTERNAL ERROR: registry_url_unlink('%s'): cannot find url in index", u->url);
76
}
77
else {
78
if(n != u) {
79
- error("INTERNAL ERROR: registry_url_unlink('%s'): deleted different url '%s'", u->url, n->url);
79
+ netdata_log_error("INTERNAL ERROR: registry_url_unlink('%s'): deleted different url '%s'", u->url, n->url);
80
}
81
82
registry.urls_memory -= sizeof(REGISTRY_URL) + n->len; // no need for +1, 1 is already in REGISTRY_URL
spawn/spawn.c
+4
-4
@@ -219,7 +219,7 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
219
220
ret = uv_spawn(loop, process, &options); /* execute the netdata binary again as the netdata user */
221
if (0 != ret) {
222
- error("uv_spawn (process: \"%s\") (user: %s) failed (%s).", exepath, user, uv_strerror(ret));
222
+ netdata_log_error("uv_spawn (process: \"%s\") (user: %s) failed (%s).", exepath, user, uv_strerror(ret));
223
fatal("Cannot start netdata without the spawn server.");
224
}
225
@@ -242,7 +242,7 @@ void spawn_init(void)
242
completion_init(&completion);
243
error = uv_thread_create(&thread, spawn_client, &completion);
244
if (error) {
245
- error("uv_thread_create(): %s", uv_strerror(error));
245
+ netdata_log_error("uv_thread_create(): %s", uv_strerror(error));
246
goto after_error;
247
}
248
/* wait for spawn client thread to initialize */
@@ -253,7 +253,7 @@ void spawn_init(void)
253
if (spawn_thread_error) {
254
error = uv_thread_join(&thread);
255
if (error) {
256
- error("uv_thread_create(): %s", uv_strerror(error));
256
+ netdata_log_error("uv_thread_create(): %s", uv_strerror(error));
257
}
258
goto after_error;
259
}
@@ -285,5 +285,5 @@ void spawn_init(void)
285
return;
286
287
after_error:
288
- error("Failed to initialize spawn service. The alarms notifications will not be spawned.");
288
+ netdata_log_error("Failed to initialize spawn service. The alarms notifications will not be spawned.");
289
}
spawn/spawn_client.c
+5
-5
@@ -106,7 +106,7 @@ static void on_pipe_read(uv_stream_t* pipe, ssize_t nread, const uv_buf_t* buf)
106
} else if (UV_EOF == nread) {
107
netdata_log_info("EOF found in spawn pipe.");
108
} else if (nread < 0) {
109
- error("%s: %s", __func__, uv_strerror(nread));
109
+ netdata_log_error("%s: %s", __func__, uv_strerror(nread));
110
}
111
112
if (nread < 0) { /* stop stream due to EOF or error */
@@ -176,7 +176,7 @@ void spawn_client(void *arg)
176
loop = mallocz(sizeof(uv_loop_t));
177
ret = uv_loop_init(loop);
178
if (ret) {
179
- error("uv_loop_init(): %s", uv_strerror(ret));
179
+ netdata_log_error("uv_loop_init(): %s", uv_strerror(ret));
180
spawn_thread_error = ret;
181
goto error_after_loop_init;
182
}
@@ -185,14 +185,14 @@ void spawn_client(void *arg)
185
spawn_async.data = NULL;
186
ret = uv_async_init(loop, &spawn_async, async_cb);
187
if (ret) {
188
- error("uv_async_init(): %s", uv_strerror(ret));
188
+ netdata_log_error("uv_async_init(): %s", uv_strerror(ret));
189
spawn_thread_error = ret;
190
goto error_after_async_init;
191
}
192
193
ret = uv_pipe_init(loop, &spawn_channel, 1);
194
if (ret) {
195
- error("uv_pipe_init(): %s", uv_strerror(ret));
195
+ netdata_log_error("uv_pipe_init(): %s", uv_strerror(ret));
196
spawn_thread_error = ret;
197
goto error_after_pipe_init;
198
}
@@ -200,7 +200,7 @@ void spawn_client(void *arg)
200
201
ret = create_spawn_server(loop, &spawn_channel, &process);
202
if (ret) {
203
- error("Failed to fork spawn server process.");
203
+ netdata_log_error("Failed to fork spawn server process.");
204
spawn_thread_error = ret;
205
goto error_after_spawn_server;
206
}
streaming/compression.c
+3
-3
@@ -52,7 +52,7 @@ size_t rrdpush_compress(struct compressor_state *state, const char *data, size_t
52
return 0;
53
54
if(unlikely(size > COMPRESSION_MAX_MSG_SIZE)) {
55
- error("RRDPUSH COMPRESS: Compression Failed - Message size %lu above compression buffer limit: %d",
55
+ netdata_log_error("RRDPUSH COMPRESS: Compression Failed - Message size %lu above compression buffer limit: %d",
56
(long unsigned int)size, COMPRESSION_MAX_MSG_SIZE);
57
return 0;
58
}
@@ -83,7 +83,7 @@ size_t rrdpush_compress(struct compressor_state *state, const char *data, size_t
83
1);
84
85
if (compressed_data_size < 0) {
86
- error("Data compression error: %ld", compressed_data_size);
86
+ netdata_log_error("Data compression error: %ld", compressed_data_size);
87
return 0;
88
}
89
@@ -125,7 +125,7 @@ size_t rrdpush_decompress(struct decompressor_state *state, const char *compress
125
);
126
127
if (unlikely(decompressed_size < 0)) {
128
- error("RRDPUSH DECOMPRESS: decompressor returned negative decompressed bytes: %ld", decompressed_size);
128
+ netdata_log_error("RRDPUSH DECOMPRESS: decompressor returned negative decompressed bytes: %ld", decompressed_size);
129
return 0;
130
}
131
streaming/receiver.c
+9
-9
@@ -77,15 +77,15 @@ static inline int read_stream(struct receiver_state *r, char* buffer, size_t siz
77
} while(bytes_read < 0 && errno == EINTR && tries--);
78
79
if((bytes_read == 0 || bytes_read == -1) && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS)) {
80
- error("STREAM: %s(): timeout while waiting for data on socket!", __FUNCTION__);
80
+ netdata_log_error("STREAM: %s(): timeout while waiting for data on socket!", __FUNCTION__);
81
bytes_read = -3;
82
}
83
else if (bytes_read == 0) {
84
- error("STREAM: %s(): EOF while reading data from socket!", __FUNCTION__);
84
+ netdata_log_error("STREAM: %s(): EOF while reading data from socket!", __FUNCTION__);
85
bytes_read = -1;
86
}
87
else if (bytes_read < 0) {
88
- error("STREAM: %s() failed to read from socket!", __FUNCTION__);
88
+ netdata_log_error("STREAM: %s() failed to read from socket!", __FUNCTION__);
89
bytes_read = -2;
90
}
91
@@ -170,7 +170,7 @@ static inline bool receiver_read_compressed(struct receiver_state *r) {
170
}
171
172
if(unlikely(compressed_message_size > COMPRESSION_MAX_MSG_SIZE)) {
173
- error("received a compressed message of %zu bytes, which is bigger than the max compressed message size supported of %zu. Ignoring message.",
173
+ netdata_log_error("received a compressed message of %zu bytes, which is bigger than the max compressed message size supported of %zu. Ignoring message.",
174
compressed_message_size, (size_t)COMPRESSION_MAX_MSG_SIZE);
175
return false;
176
}
@@ -259,7 +259,7 @@ inline char *buffered_reader_next_line(struct buffered_reader *reader, char *dst
259
260
// if the destination is full, oops!
261
if(ds == de) {
262
- error("STREAM: received line exceeds %d bytes. Truncating it.", PLUGINSD_LINE_MAX);
262
+ netdata_log_error("STREAM: received line exceeds %d bytes. Truncating it.", PLUGINSD_LINE_MAX);
263
*ds = '\0';
264
reader->pos = ss - reader->read_buffer;
265
return dst;
@@ -498,7 +498,7 @@ bool stop_streaming_receiver(RRDHOST *host, STREAM_HANDSHAKE reason) {
498
}
499
500
if(host->receiver)
501
- error("STREAM '%s' [receive from [%s]:%s]: "
501
+ netdata_log_error("STREAM '%s' [receive from [%s]:%s]: "
502
"thread %d takes too long to stop, giving up..."
503
, rrdhost_hostname(host)
504
, host->receiver->client_ip, host->receiver->client_port
@@ -573,7 +573,7 @@ static void rrdpush_receive(struct receiver_state *rpt)
573
rpt->config.mode = rrd_memory_mode_id(appconfig_get(&stream_config, rpt->machine_guid, "memory mode", rrd_memory_mode_name(rpt->config.mode)));
574
575
if (unlikely(rpt->config.mode == RRD_MEMORY_MODE_DBENGINE && !dbengine_enabled)) {
576
- error("STREAM '%s' [receive from %s:%s]: "
576
+ netdata_log_error("STREAM '%s' [receive from %s:%s]: "
577
"dbengine is not enabled, falling back to default."
578
, rpt->hostname
579
, rpt->client_ip, rpt->client_port
@@ -751,7 +751,7 @@ static void rrdpush_receive(struct receiver_state *rpt)
751
{
752
// remove the non-blocking flag from the socket
753
if(sock_delnonblock(rpt->fd) < 0)
754
- error("STREAM '%s' [receive from [%s]:%s]: "
754
+ netdata_log_error("STREAM '%s' [receive from [%s]:%s]: "
755
"cannot remove the non-blocking flag from socket %d"
756
, rrdhost_hostname(rpt->host)
757
, rpt->client_ip, rpt->client_port
@@ -761,7 +761,7 @@ static void rrdpush_receive(struct receiver_state *rpt)
761
timeout.tv_sec = 600;
762
timeout.tv_usec = 0;
763
if (unlikely(setsockopt(rpt->fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout) != 0))
764
- error("STREAM '%s' [receive from [%s]:%s]: "
764
+ netdata_log_error("STREAM '%s' [receive from [%s]:%s]: "
765
"cannot set timeout for socket %d"
766
, rrdhost_hostname(rpt->host)
767
, rpt->client_ip, rpt->client_port
streaming/replication.c
+2
-2
@@ -799,7 +799,7 @@ static bool send_replay_chart_cmd(struct replication_request_details *r, const c
799
800
ssize_t ret = r->caller.callback(buffer, r->caller.data);
801
if (ret < 0) {
802
- error("REPLAY ERROR: 'host:%s/chart:%s' failed to send replication request to child (error %zd)",
802
+ netdata_log_error("REPLAY ERROR: 'host:%s/chart:%s' failed to send replication request to child (error %zd)",
803
rrdhost_hostname(r->host), rrdset_id(r->st), ret);
804
return false;
805
}
@@ -1860,7 +1860,7 @@ void *replication_thread_main(void *ptr __maybe_unused) {
1860
1861
int threads = config_get_number(CONFIG_SECTION_DB, "replication threads", 1);
1862
if(threads < 1 || threads > MAX_REPLICATION_THREADS) {
1863
- error("replication threads given %d is invalid, resetting to 1", threads);
1863
+ netdata_log_error("replication threads given %d is invalid, resetting to 1", threads);
1864
threads = 1;
1865
}
1866
streaming/rrdpush.c
+4
-4
@@ -148,7 +148,7 @@ int rrdpush_init() {
148
#endif
149
150
if(default_rrdpush_enabled && (!default_rrdpush_destination || !*default_rrdpush_destination || !default_rrdpush_api_key || !*default_rrdpush_api_key)) {
151
- error("STREAM [send]: cannot enable sending thread - information is missing.");
151
+ netdata_log_error("STREAM [send]: cannot enable sending thread - information is missing.");
152
default_rrdpush_enabled = 0;
153
}
154
@@ -479,7 +479,7 @@ RRDSET_STREAM_BUFFER rrdset_push_metric_initialize(RRDSET *st, time_t wall_clock
479
480
if(unlikely(!(host_flags & RRDHOST_FLAG_RRDPUSH_SENDER_LOGGED_STATUS))) {
481
rrdhost_flag_set(host, RRDHOST_FLAG_RRDPUSH_SENDER_LOGGED_STATUS);
482
- error("STREAM %s [send]: not ready - collected metrics are not sent to parent.", rrdhost_hostname(host));
482
+ netdata_log_error("STREAM %s [send]: not ready - collected metrics are not sent to parent.", rrdhost_hostname(host));
483
}
484
485
return (RRDSET_STREAM_BUFFER) { .wb = NULL, };
@@ -727,7 +727,7 @@ static void rrdpush_sender_thread_spawn(RRDHOST *host) {
727
snprintfz(tag, NETDATA_THREAD_TAG_MAX, THREAD_TAG_STREAM_SENDER "[%s]", rrdhost_hostname(host));
728
729
if(netdata_thread_create(&host->rrdpush_sender_thread, tag, NETDATA_THREAD_OPTION_DEFAULT, rrdpush_sender_thread, (void *) host->sender))
730
- error("STREAM %s [send]: failed to create new thread for client.", rrdhost_hostname(host));
730
+ netdata_log_error("STREAM %s [send]: failed to create new thread for client.", rrdhost_hostname(host));
731
else
732
rrdhost_flag_set(host, RRDHOST_FLAG_RRDPUSH_SENDER_SPAWN);
733
}
@@ -1075,7 +1075,7 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *decoded_query_stri
1075
#endif
1076
rpt->fd, initial_response, strlen(initial_response), 0, 60) != (ssize_t)strlen(initial_response)) {
1077
1078
- error("STREAM '%s' [receive from [%s]:%s]: "
1078
+ netdata_log_error("STREAM '%s' [receive from [%s]:%s]: "
1079
"failed to reply."
1080
, rpt->hostname
1081
, rpt->client_ip, rpt->client_port
streaming/sender.c
+30
-30
@@ -74,9 +74,9 @@ static inline void rrdpush_sender_thread_close_socket(RRDHOST *host);
74
*/
75
static inline void deactivate_compression(struct sender_state *s) {
76
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_NO_COMPRESSION);
77
- error("STREAM_COMPRESSION: Compression returned error, disabling it.");
77
+ netdata_log_error("STREAM_COMPRESSION: Compression returned error, disabling it.");
78
s->flags &= ~SENDER_FLAG_COMPRESSION;
79
- error("STREAM %s [send to %s]: Restarting connection without compression.", rrdhost_hostname(s->host), s->connected_to);
79
+ netdata_log_error("STREAM %s [send to %s]: Restarting connection without compression.", rrdhost_hostname(s->host), s->connected_to);
80
rrdpush_sender_thread_close_socket(s->host);
81
}
82
#endif
@@ -146,13 +146,13 @@ void sender_commit(struct sender_state *s, BUFFER *wb, STREAM_TRAFFIC_TYPE type)
146
char *dst;
147
size_t dst_len = rrdpush_compress(&s->compressor, src, size_to_compress, &dst);
148
if (!dst_len) {
149
- error("STREAM %s [send to %s]: COMPRESSION failed. Resetting compressor and re-trying",
149
+ netdata_log_error("STREAM %s [send to %s]: COMPRESSION failed. Resetting compressor and re-trying",
150
rrdhost_hostname(s->host), s->connected_to);
151
152
rrdpush_compressor_reset(&s->compressor);
153
dst_len = rrdpush_compress(&s->compressor, src, size_to_compress, &dst);
154
if(!dst_len) {
155
- error("STREAM %s [send to %s]: COMPRESSION failed again. Deactivating compression",
155
+ netdata_log_error("STREAM %s [send to %s]: COMPRESSION failed again. Deactivating compression",
156
rrdhost_hostname(s->host), s->connected_to);
157
158
deactivate_compression(s);
@@ -509,7 +509,7 @@ static inline bool rrdpush_sender_validate_response(RRDHOST *host, struct sender
509
510
char buf[LOG_DATE_LENGTH];
511
log_date(buf, LOG_DATE_LENGTH, host->destination->postpone_reconnection_until);
512
- error("STREAM %s [send to %s]: %s - will retry in %ld secs, at %s",
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);
514
515
return false;
@@ -541,7 +541,7 @@ static bool rrdpush_sender_connect_ssl(struct sender_state *s) {
541
// certificate is not valid
542
543
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_SSL_ERROR);
544
- error("SSL: closing the stream connection, because the server SSL certificate is not valid.");
544
+ netdata_log_error("SSL: closing the stream connection, because the server SSL certificate is not valid.");
545
rrdpush_sender_thread_close_socket(host);
546
host->destination->reason = STREAM_HANDSHAKE_ERROR_INVALID_CERTIFICATE;
547
host->destination->postpone_reconnection_until = now_realtime_sec() + 5 * 60;
@@ -551,7 +551,7 @@ static bool rrdpush_sender_connect_ssl(struct sender_state *s) {
551
return true;
552
}
553
554
- error("SSL: failed to establish connection.");
554
+ netdata_log_error("SSL: failed to establish connection.");
555
return false;
556
557
#else
@@ -581,7 +581,7 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
581
);
582
583
if(unlikely(s->rrdpush_sender_socket == -1)) {
584
- // error("STREAM %s [send to %s]: could not connect to parent node at this time.", rrdhost_hostname(host), host->rrdpush_send_destination);
584
+ // netdata_log_error("STREAM %s [send to %s]: could not connect to parent node at this time.", rrdhost_hostname(host), host->rrdpush_send_destination);
585
return false;
586
}
587
@@ -720,7 +720,7 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
720
if(bytes <= 0) { // timeout is 0
721
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_TIMEOUT);
722
rrdpush_sender_thread_close_socket(host);
723
- error("STREAM %s [send to %s]: failed to send HTTP header to remote netdata.", rrdhost_hostname(host), s->connected_to);
723
+ netdata_log_error("STREAM %s [send to %s]: failed to send HTTP header to remote netdata.", rrdhost_hostname(host), s->connected_to);
724
host->destination->reason = STREAM_HANDSHAKE_ERROR_SEND_TIMEOUT;
725
host->destination->postpone_reconnection_until = now_realtime_sec() + 1 * 60;
726
return false;
@@ -739,17 +739,17 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
739
if(bytes <= 0) { // timeout is 0
740
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_TIMEOUT);
741
rrdpush_sender_thread_close_socket(host);
742
- error("STREAM %s [send to %s]: remote netdata does not respond.", rrdhost_hostname(host), s->connected_to);
742
+ netdata_log_error("STREAM %s [send to %s]: remote netdata does not respond.", rrdhost_hostname(host), s->connected_to);
743
host->destination->reason = STREAM_HANDSHAKE_ERROR_RECEIVE_TIMEOUT;
744
host->destination->postpone_reconnection_until = now_realtime_sec() + 30;
745
return false;
746
}
747
748
if(sock_setnonblock(s->rrdpush_sender_socket) < 0)
749
- error("STREAM %s [send to %s]: cannot set non-blocking mode for socket.", rrdhost_hostname(host), s->connected_to);
749
+ netdata_log_error("STREAM %s [send to %s]: cannot set non-blocking mode for socket.", rrdhost_hostname(host), s->connected_to);
750
751
if(sock_enlarge_out(s->rrdpush_sender_socket) < 0)
752
- error("STREAM %s [send to %s]: cannot enlarge the socket buffer.", rrdhost_hostname(host), s->connected_to);
752
+ netdata_log_error("STREAM %s [send to %s]: cannot enlarge the socket buffer.", rrdhost_hostname(host), s->connected_to);
753
754
http[bytes] = '\0';
755
debug(D_STREAM, "Response to sender from far end: %s", http);
@@ -846,7 +846,7 @@ static ssize_t attempt_to_send(struct sender_state *s) {
846
else if (ret == -1) {
847
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_SEND_ERROR);
848
debug(D_STREAM, "STREAM: Send failed - closing socket...");
849
- error("STREAM %s [send to %s]: failed to send metrics - closing connection - we have sent %zu bytes on this connection.", rrdhost_hostname(s->host), s->connected_to, s->sent_bytes_on_this_connection);
849
+ netdata_log_error("STREAM %s [send to %s]: failed to send metrics - closing connection - we have sent %zu bytes on this connection.", rrdhost_hostname(s->host), s->connected_to, s->sent_bytes_on_this_connection);
850
rrdpush_sender_thread_close_socket(s->host);
851
}
852
else
@@ -886,11 +886,11 @@ static ssize_t attempt_read(struct sender_state *s) {
886
887
if (ret == 0 || errno == ECONNRESET) {
888
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_PARENT_CLOSED);
889
- error("STREAM %s [send to %s]: connection closed by far end.", rrdhost_hostname(s->host), s->connected_to);
889
+ netdata_log_error("STREAM %s [send to %s]: connection closed by far end.", rrdhost_hostname(s->host), s->connected_to);
890
}
891
else {
892
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_RECEIVE_ERROR);
893
- error("STREAM %s [send to %s]: error during receive (%zd) - closing connection.", rrdhost_hostname(s->host), s->connected_to, ret);
893
+ netdata_log_error("STREAM %s [send to %s]: error during receive (%zd) - closing connection.", rrdhost_hostname(s->host), s->connected_to, ret);
894
}
895
896
rrdpush_sender_thread_close_socket(s->host);
@@ -962,7 +962,7 @@ void execute_commands(struct sender_state *s) {
962
char *function = get_word(words, num_words, 3);
963
964
if(!transaction || !*transaction || !timeout_s || !*timeout_s || !function || !*function) {
965
- error("STREAM %s [send to %s] %s execution command is incomplete (transaction = '%s', timeout = '%s', function = '%s'). Ignoring it.",
965
+ netdata_log_error("STREAM %s [send to %s] %s execution command is incomplete (transaction = '%s', timeout = '%s', function = '%s'). Ignoring it.",
966
rrdhost_hostname(s->host), s->connected_to,
967
keyword,
968
transaction?transaction:"(unset)",
@@ -995,7 +995,7 @@ void execute_commands(struct sender_state *s) {
995
const char *before = get_word(words, num_words, 4);
996
997
if (!chart_id || !start_streaming || !after || !before) {
998
- error("STREAM %s [send to %s] %s command is incomplete"
998
+ netdata_log_error("STREAM %s [send to %s] %s command is incomplete"
999
" (chart=%s, start_streaming=%s, after=%s, before=%s)",
1000
rrdhost_hostname(s->host), s->connected_to,
1001
keyword,
@@ -1013,7 +1013,7 @@ void execute_commands(struct sender_state *s) {
1013
}
1014
}
1015
else {
1016
- error("STREAM %s [send to %s] received unknown command over connection: %s", rrdhost_hostname(s->host), s->connected_to, words[0]?words[0]:"(unset)");
1016
+ netdata_log_error("STREAM %s [send to %s] received unknown command over connection: %s", rrdhost_hostname(s->host), s->connected_to, words[0]?words[0]:"(unset)");
1017
}
1018
1019
worker_is_busy(WORKER_SENDER_JOB_EXECUTE);
@@ -1044,7 +1044,7 @@ static bool rrdpush_sender_pipe_close(RRDHOST *host, int *pipe_fds, bool reopen)
1044
int new_pipe_fds[2];
1045
if(reopen) {
1046
if(pipe(new_pipe_fds) != 0) {
1047
- error("STREAM %s [send]: cannot create required pipe.", rrdhost_hostname(host));
1047
+ netdata_log_error("STREAM %s [send]: cannot create required pipe.", rrdhost_hostname(host));
1048
new_pipe_fds[PIPE_READ] = -1;
1049
new_pipe_fds[PIPE_WRITE] = -1;
1050
ret = false;
@@ -1084,7 +1084,7 @@ void rrdpush_signal_sender_to_wake_up(struct sender_state *s) {
1084
1085
// signal the sender there are more data
1086
if (pipe_fd != -1 && write(pipe_fd, " ", 1) == -1) {
1087
- error("STREAM %s [send]: cannot write to internal pipe.", rrdhost_hostname(host));
1087
+ netdata_log_error("STREAM %s [send]: cannot write to internal pipe.", rrdhost_hostname(host));
1088
rrdpush_sender_pipe_close(host, s->rrdpush_sender_pipe, true);
1089
}
1090
}
@@ -1238,13 +1238,13 @@ void *rrdpush_sender_thread(void *ptr) {
1238
if(!rrdhost_has_rrdpush_sender_enabled(s->host) || !s->host->rrdpush_send_destination ||
1239
!*s->host->rrdpush_send_destination || !s->host->rrdpush_send_api_key ||
1240
!*s->host->rrdpush_send_api_key) {
1241
- error("STREAM %s [send]: thread created (task id %d), but host has streaming disabled.",
1241
+ netdata_log_error("STREAM %s [send]: thread created (task id %d), but host has streaming disabled.",
1242
rrdhost_hostname(s->host), gettid());
1243
return NULL;
1244
}
1245
1246
if(!rrdhost_set_sender(s->host)) {
1247
- error("STREAM %s [send]: thread created (task id %d), but there is another sender running for this host.",
1247
+ netdata_log_error("STREAM %s [send]: thread created (task id %d), but there is another sender running for this host.",
1248
rrdhost_hostname(s->host), gettid());
1249
return NULL;
1250
}
@@ -1282,7 +1282,7 @@ void *rrdpush_sender_thread(void *ptr) {
1282
pipe_buffer_size = 10 * 1024;
1283
1284
if(!rrdpush_sender_pipe_close(s->host, s->rrdpush_sender_pipe, true)) {
1285
- error("STREAM %s [send]: cannot create inter-thread communication pipe. Disabling streaming.",
1285
+ netdata_log_error("STREAM %s [send]: cannot create inter-thread communication pipe. Disabling streaming.",
1286
rrdhost_hostname(s->host));
1287
return NULL;
1288
}
@@ -1338,7 +1338,7 @@ void *rrdpush_sender_thread(void *ptr) {
1338
!rrdpush_sender_replicating_charts(s)
1339
)) {
1340
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_TIMEOUT);
1341
- error("STREAM %s [send to %s]: could not send metrics for %d seconds - closing connection - we have sent %zu bytes on this connection via %zu send attempts.", rrdhost_hostname(s->host), s->connected_to, s->timeout, s->sent_bytes_on_this_connection, s->send_attempts);
1341
+ netdata_log_error("STREAM %s [send to %s]: could not send metrics for %d seconds - closing connection - we have sent %zu bytes on this connection via %zu send attempts.", rrdhost_hostname(s->host), s->connected_to, s->timeout, s->sent_bytes_on_this_connection, s->send_attempts);
1342
rrdpush_sender_thread_close_socket(s->host);
1343
continue;
1344
}
@@ -1359,7 +1359,7 @@ void *rrdpush_sender_thread(void *ptr) {
1359
1360
if(unlikely(s->rrdpush_sender_pipe[PIPE_READ] == -1)) {
1361
if(!rrdpush_sender_pipe_close(s->host, s->rrdpush_sender_pipe, true)) {
1362
- error("STREAM %s [send]: cannot create inter-thread communication pipe. Disabling streaming.",
1362
+ netdata_log_error("STREAM %s [send]: cannot create inter-thread communication pipe. Disabling streaming.",
1363
rrdhost_hostname(s->host));
1364
rrdpush_sender_thread_close_socket(s->host);
1365
break;
@@ -1411,7 +1411,7 @@ void *rrdpush_sender_thread(void *ptr) {
1411
// Only errors from poll() are internal, but try restarting the connection
1412
if(unlikely(poll_rc == -1)) {
1413
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_POLL_ERROR);
1414
- error("STREAM %s [send to %s]: failed to poll(). Closing socket.", rrdhost_hostname(s->host), s->connected_to);
1414
+ netdata_log_error("STREAM %s [send to %s]: failed to poll(). Closing socket.", rrdhost_hostname(s->host), s->connected_to);
1415
rrdpush_sender_pipe_close(s->host, s->rrdpush_sender_pipe, true);
1416
rrdpush_sender_thread_close_socket(s->host);
1417
continue;
@@ -1433,7 +1433,7 @@ void *rrdpush_sender_thread(void *ptr) {
1433
debug(D_STREAM, "STREAM: Data added to send buffer (current buffer chunk %zu bytes)...", outstanding);
1434
1435
if (read(fds[Collector].fd, thread_data->pipe_buffer, pipe_buffer_size) == -1)
1436
- error("STREAM %s [send to %s]: cannot read from internal pipe.", rrdhost_hostname(s->host), s->connected_to);
1436
+ netdata_log_error("STREAM %s [send to %s]: cannot read from internal pipe.", rrdhost_hostname(s->host), s->connected_to);
1437
}
1438
1439
// Read as much as possible to fill the buffer, split into full lines for execution.
@@ -1461,7 +1461,7 @@ void *rrdpush_sender_thread(void *ptr) {
1461
1462
if(error) {
1463
rrdpush_sender_pipe_close(s->host, s->rrdpush_sender_pipe, true);
1464
- error("STREAM %s [send to %s]: restarting internal pipe: %s.",
1464
+ netdata_log_error("STREAM %s [send to %s]: restarting internal pipe: %s.",
1465
rrdhost_hostname(s->host), s->connected_to, error);
1466
}
1467
}
@@ -1478,7 +1478,7 @@ void *rrdpush_sender_thread(void *ptr) {
1478
1479
if(unlikely(error)) {
1480
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_SOCKET_ERROR);
1481
- error("STREAM %s [send to %s]: restarting connection: %s - %zu bytes transmitted.",
1481
+ netdata_log_error("STREAM %s [send to %s]: restarting connection: %s - %zu bytes transmitted.",
1482
rrdhost_hostname(s->host), s->connected_to, error, s->sent_bytes_on_this_connection);
1483
rrdpush_sender_thread_close_socket(s->host);
1484
}
@@ -1488,7 +1488,7 @@ void *rrdpush_sender_thread(void *ptr) {
1488
if(unlikely(s->flags & SENDER_FLAG_OVERFLOW)) {
1489
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_OVERFLOW);
1490
errno = 0;
1491
- error("STREAM %s [send to %s]: buffer full (allocated %zu bytes) after sending %zu bytes. Restarting connection",
1491
+ netdata_log_error("STREAM %s [send to %s]: buffer full (allocated %zu bytes) after sending %zu bytes. Restarting connection",
1492
rrdhost_hostname(s->host), s->connected_to, s->buffer->size, s->sent_bytes_on_this_connection);
1493
rrdpush_sender_thread_close_socket(s->host);
1494
}
tests/profile/benchmark-procfile-parser.c
+2
-2
@@ -207,7 +207,7 @@ procfile *procfile_readall1(procfile *ff) {
207
debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s));
208
r = read(ff->fd, &ff->data[s], ff->size - s);
209
if(unlikely(r == -1)) {
210
- if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
210
+ if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) netdata_log_error(PF_PREFIX ": Cannot read from file '%s' on fd %d", procfile_filename(ff), ff->fd);
211
procfile_close(ff);
212
return NULL;
213
}
@@ -217,7 +217,7 @@ procfile *procfile_readall1(procfile *ff) {
217
218
// debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);
219
if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) {
220
- if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
220
+ if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) netdata_log_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
221
procfile_close(ff);
222
return NULL;
223
}
tests/profile/test-eval.c
+1
-1
@@ -231,7 +231,7 @@ NETDATA_DOUBLE evaluate(EVAL_NODE *op, int depth) {
231
break;
232
233
default:
234
- error("I don't know how to handle operator '%c'", op->operator);
234
+ netdata_log_error("I don't know how to handle operator '%c'", op->operator);
235
r = 0;
236
break;
237
}
web/api/formatters/csv/csv.c
+2
-1
@@ -79,7 +79,8 @@ void rrdr2csv(RRDR *r, BUFFER *wb, uint32_t format, RRDR_OPTIONS options, const
79
else {
80
// generate the local date time
81
struct tm tmbuf, *tm = localtime_r(&now, &tmbuf);
82
- if(!tm) { error("localtime() failed."); continue; }
82
+ if(!tm) {
83
+ netdata_log_error("localtime() failed."); continue; }
84
buffer_date(wb, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
85
}
86
web/api/formatters/json/json.c
+2
-1
@@ -159,7 +159,8 @@ void rrdr2json(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, int datatable) {
159
if(dates == JSON_DATES_JS) {
160
// generate the local date time
161
struct tm tmbuf, *tm = localtime_r(&now, &tmbuf);
162
- if(!tm) { error("localtime_r() failed."); continue; }
162
+ if(!tm) {
163
+ netdata_log_error("localtime_r() failed."); continue; }
164
165
if(likely(i != start)) buffer_fast_strcat(wb, ",\n", 2);
166
buffer_fast_strcat(wb, pre_date, pre_date_len);
web/api/health/health_cmdapi.c
+1
-1
@@ -101,7 +101,7 @@ void health_silencers2file(BUFFER *wb) {
101
fclose(fd);
102
return;
103
}
104
- error("Silencer changes could not be written to %s. Error %s", silencers_filename, strerror(errno));
104
+ netdata_log_error("Silencer changes could not be written to %s. Error %s", silencers_filename, strerror(errno));
105
}
106
107
/**
web/api/queries/weights.c
+4
-4
@@ -1244,7 +1244,7 @@ static double kstwo(
1244
return NAN;
1245
1246
if(unlikely(base_size != baseline_points - 1 || high_size != highlight_points - 1)) {
1247
- error("Metric correlations: internal error - calculate_pairs_diff() returns the wrong number of entries");
1247
+ netdata_log_error("Metric correlations: internal error - calculate_pairs_diff() returns the wrong number of entries");
1248
return NAN;
1249
}
1250
@@ -1292,7 +1292,7 @@ NETDATA_DOUBLE *rrd2rrdr_ks2(
1292
stats->db_points_per_tier[tr] += r->internal.qt->db.tiers[tr].points;
1293
1294
if(r->d != 1 || r->internal.qt->query.used != 1) {
1295
- error("WEIGHTS: on query '%s' expected 1 dimension in RRDR but got %zu r->d and %zu qt->query.used",
1295
+ netdata_log_error("WEIGHTS: on query '%s' expected 1 dimension in RRDR but got %zu r->d and %zu qt->query.used",
1296
r->internal.qt->id, r->d, (size_t)r->internal.qt->query.used);
1297
goto cleanup;
1298
}
@@ -1368,11 +1368,11 @@ static void rrdset_metric_correlations_ks2(
1368
1369
// these conditions should never happen, but still let's check
1370
if(unlikely(prob < 0.0)) {
1371
- error("Metric correlations: kstwo() returned a negative number: %f", prob);
1371
+ netdata_log_error("Metric correlations: kstwo() returned a negative number: %f", prob);
1372
prob = -prob;
1373
}
1374
if(unlikely(prob > 1.0)) {
1375
- error("Metric correlations: kstwo() returned a number above 1.0: %f", prob);
1375
+ netdata_log_error("Metric correlations: kstwo() returned a number above 1.0: %f", prob);
1376
prob = 1.0;
1377
}
1378
web/api/web_api_v1.c
+10
-10
@@ -161,11 +161,11 @@ char *get_mgmt_api_key(void) {
161
if(fd != -1) {
162
char buf[GUID_LEN + 1];
163
if(read(fd, buf, GUID_LEN) != GUID_LEN)
164
- error("Failed to read management API key from '%s'", api_key_filename);
164
+ netdata_log_error("Failed to read management API key from '%s'", api_key_filename);
165
else {
166
buf[GUID_LEN] = '\0';
167
if(regenerate_guid(buf, guid) == -1) {
168
- error("Failed to validate management API key '%s' from '%s'.",
168
+ netdata_log_error("Failed to validate management API key '%s' from '%s'.",
169
buf, api_key_filename);
170
171
guid[0] = '\0';
@@ -185,12 +185,12 @@ char *get_mgmt_api_key(void) {
185
// save it
186
fd = open(api_key_filename, O_WRONLY|O_CREAT|O_TRUNC, 444);
187
if(fd == -1) {
188
- error("Cannot create unique management API key file '%s'. Please adjust config parameter 'netdata management api key file' to a proper path and file.", api_key_filename);
188
+ netdata_log_error("Cannot create unique management API key file '%s'. Please adjust config parameter 'netdata management api key file' to a proper path and file.", api_key_filename);
189
goto temp_key;
190
}
191
192
if(write(fd, guid, GUID_LEN) != GUID_LEN) {
193
- error("Cannot write the unique management API key file '%s'. Please adjust config parameter 'netdata management api key file' to a proper path and file with enough space left.", api_key_filename);
193
+ netdata_log_error("Cannot write the unique management API key file '%s'. Please adjust config parameter 'netdata management api key file' to a proper path and file with enough space left.", api_key_filename);
194
close(fd);
195
goto temp_key;
196
}
@@ -973,7 +973,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
973
else if(vhash == hash_search && !strcmp(value, "search")) action = 'S';
974
else if(vhash == hash_switch && !strcmp(value, "switch")) action = 'W';
975
#ifdef NETDATA_INTERNAL_CHECKS
976
- else error("unknown registry action '%s'", value);
976
+ else netdata_log_error("unknown registry action '%s'", value);
977
#endif /* NETDATA_INTERNAL_CHECKS */
978
}
979
/*
@@ -1003,7 +1003,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
1003
to_person_guid = value;
1004
}
1005
#ifdef NETDATA_INTERNAL_CHECKS
1006
- else error("unused registry URL parameter '%s' with value '%s'", name, value);
1006
+ else netdata_log_error("unused registry URL parameter '%s' with value '%s'", name, value);
1007
#endif /* NETDATA_INTERNAL_CHECKS */
1008
}
1009
@@ -1028,7 +1028,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
1028
switch(action) {
1029
case 'A':
1030
if(unlikely(!machine_guid || !machine_url || !url_name)) {
1031
- error("Invalid registry request - access requires these parameters: machine ('%s'), url ('%s'), name ('%s')", machine_guid ? machine_guid : "UNSET", machine_url ? machine_url : "UNSET", url_name ? url_name : "UNSET");
1031
+ netdata_log_error("Invalid registry request - access requires these parameters: machine ('%s'), url ('%s'), name ('%s')", machine_guid ? machine_guid : "UNSET", machine_url ? machine_url : "UNSET", url_name ? url_name : "UNSET");
1032
buffer_flush(w->response.data);
1033
buffer_strcat(w->response.data, "Invalid registry Access request.");
1034
return HTTP_RESP_BAD_REQUEST;
@@ -1039,7 +1039,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
1039
1040
case 'D':
1041
if(unlikely(!machine_guid || !machine_url || !delete_url)) {
1042
- error("Invalid registry request - delete requires these parameters: machine ('%s'), url ('%s'), delete_url ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", delete_url?delete_url:"UNSET");
1042
+ netdata_log_error("Invalid registry request - delete requires these parameters: machine ('%s'), url ('%s'), delete_url ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", delete_url?delete_url:"UNSET");
1043
buffer_flush(w->response.data);
1044
buffer_strcat(w->response.data, "Invalid registry Delete request.");
1045
return HTTP_RESP_BAD_REQUEST;
@@ -1050,7 +1050,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
1050
1051
case 'S':
1052
if(unlikely(!machine_guid || !machine_url || !search_machine_guid)) {
1053
- error("Invalid registry request - search requires these parameters: machine ('%s'), url ('%s'), for ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", search_machine_guid?search_machine_guid:"UNSET");
1053
+ netdata_log_error("Invalid registry request - search requires these parameters: machine ('%s'), url ('%s'), for ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", search_machine_guid?search_machine_guid:"UNSET");
1054
buffer_flush(w->response.data);
1055
buffer_strcat(w->response.data, "Invalid registry Search request.");
1056
return HTTP_RESP_BAD_REQUEST;
@@ -1061,7 +1061,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
1061
1062
case 'W':
1063
if(unlikely(!machine_guid || !machine_url || !to_person_guid)) {
1064
- error("Invalid registry request - switching identity requires these parameters: machine ('%s'), url ('%s'), to ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", to_person_guid?to_person_guid:"UNSET");
1064
+ netdata_log_error("Invalid registry request - switching identity requires these parameters: machine ('%s'), url ('%s'), to ('%s')", machine_guid?machine_guid:"UNSET", machine_url?machine_url:"UNSET", to_person_guid?to_person_guid:"UNSET");
1065
buffer_flush(w->response.data);
1066
buffer_strcat(w->response.data, "Invalid registry Switch request.");
1067
return HTTP_RESP_BAD_REQUEST;
web/rtc/webrtc.c
+15
-15
@@ -21,7 +21,7 @@ static void webrtc_log(rtcLogLevel level, const char *message) {
21
case RTC_LOG_WARNING:
22
case RTC_LOG_ERROR:
23
case RTC_LOG_FATAL:
24
- error("WEBRTC: %s", message);
24
+ netdata_log_error("WEBRTC: %s", message);
25
break;
26
27
case RTC_LOG_INFO:
@@ -263,7 +263,7 @@ static size_t webrtc_send_in_chunks(WEBRTC_DC *chan, const char *data, size_t si
263
total_message_size = -total_message_size;
264
265
if(rtcSendMessage(chan->dc, send_buffer, total_message_size) != RTC_ERR_SUCCESS)
266
- error("WEBRTC[%d],DC[%d]: failed to send LZ4 chunk %zu of %zu", chan->conn->pc, chan->dc, chunk, total_chunks);
266
+ netdata_log_error("WEBRTC[%d],DC[%d]: failed to send LZ4 chunk %zu of %zu", chan->conn->pc, chan->dc, chunk, total_chunks);
267
else
268
internal_error(true, "WEBRTC[%d],DC[%d]: sent chunk %zu of %zu, size %zu (total %d)",
269
chan->conn->pc, chan->dc, chunk, total_chunks, message_size, total_message_size);
@@ -403,7 +403,7 @@ static void myErrorCallback(int id __maybe_unused, const char *error, void *user
403
WEBRTC_DC *chan = user_ptr;
404
internal_fatal(chan->dc != id, "WEBRTC[%d],DC[%d]: dc mismatch, expected %d, got %d", chan->conn->pc, chan->dc, chan->dc, id);
405
406
- error("WEBRTC[%d],DC[%d]: ERROR: '%s'", chan->conn->pc, chan->dc, error);
406
+ netdata_log_error("WEBRTC[%d],DC[%d]: ERROR: '%s'", chan->conn->pc, chan->dc, error);
407
}
408
409
static void myMessageCallback(int id __maybe_unused, const char *message, int size, void *user_ptr) {
@@ -464,19 +464,19 @@ static void myDataChannelCallback(int pc __maybe_unused, int dc, void *user_ptr)
464
chan->label = strdupz(label);
465
466
if(rtcSetOpenCallback(dc, myOpenCallback) != RTC_ERR_SUCCESS)
467
- error("WEBRTC[%d],DC[%d]: rtcSetOpenCallback() failed.", conn->pc, chan->dc);
467
+ netdata_log_error("WEBRTC[%d],DC[%d]: rtcSetOpenCallback() failed.", conn->pc, chan->dc);
468
469
if(rtcSetClosedCallback(dc, myClosedCallback) != RTC_ERR_SUCCESS)
470
- error("WEBRTC[%d],DC[%d]: rtcSetClosedCallback() failed.", conn->pc, chan->dc);
470
+ netdata_log_error("WEBRTC[%d],DC[%d]: rtcSetClosedCallback() failed.", conn->pc, chan->dc);
471
472
if(rtcSetErrorCallback(dc, myErrorCallback) != RTC_ERR_SUCCESS)
473
- error("WEBRTC[%d],DC[%d]: rtcSetErrorCallback() failed.", conn->pc, chan->dc);
473
+ netdata_log_error("WEBRTC[%d],DC[%d]: rtcSetErrorCallback() failed.", conn->pc, chan->dc);
474
475
if(rtcSetMessageCallback(dc, myMessageCallback) != RTC_ERR_SUCCESS)
476
- error("WEBRTC[%d],DC[%d]: rtcSetMessageCallback() failed.", conn->pc, chan->dc);
476
+ netdata_log_error("WEBRTC[%d],DC[%d]: rtcSetMessageCallback() failed.", conn->pc, chan->dc);
477
478
// if(rtcSetAvailableCallback(dc, myAvailableCallback) != RTC_ERR_SUCCESS)
479
-// error("WEBRTC[%d],DC[%d]: rtcSetAvailableCallback() failed.", conn->pc, chan->dc);
479
+// netdata_log_error("WEBRTC[%d],DC[%d]: rtcSetAvailableCallback() failed.", conn->pc, chan->dc);
480
481
internal_error(true, "WEBRTC[%d],DC[%d]: new data channel with label '%s'", chan->conn->pc, chan->dc, chan->label);
482
}
@@ -671,29 +671,29 @@ int webrtc_new_connection(const char *sdp, BUFFER *wb) {
671
rtcSetUserPointer(conn->pc, conn);
672
673
if(rtcSetLocalDescriptionCallback(conn->pc, myDescriptionCallback) != RTC_ERR_SUCCESS)
674
- error("WEBRTC[%d]: rtcSetLocalDescriptionCallback() failed", conn->pc);
674
+ netdata_log_error("WEBRTC[%d]: rtcSetLocalDescriptionCallback() failed", conn->pc);
675
676
if(rtcSetLocalCandidateCallback(conn->pc, myCandidateCallback) != RTC_ERR_SUCCESS)
677
- error("WEBRTC[%d]: rtcSetLocalCandidateCallback() failed", conn->pc);
677
+ netdata_log_error("WEBRTC[%d]: rtcSetLocalCandidateCallback() failed", conn->pc);
678
679
if(rtcSetStateChangeCallback(conn->pc, myStateChangeCallback) != RTC_ERR_SUCCESS)
680
- error("WEBRTC[%d]: rtcSetStateChangeCallback() failed", conn->pc);
680
+ netdata_log_error("WEBRTC[%d]: rtcSetStateChangeCallback() failed", conn->pc);
681
682
if(rtcSetGatheringStateChangeCallback(conn->pc, myGatheringStateCallback) != RTC_ERR_SUCCESS)
683
- error("WEBRTC[%d]: rtcSetGatheringStateChangeCallback() failed", conn->pc);
683
+ netdata_log_error("WEBRTC[%d]: rtcSetGatheringStateChangeCallback() failed", conn->pc);
684
685
if(rtcSetDataChannelCallback(conn->pc, myDataChannelCallback) != RTC_ERR_SUCCESS)
686
- error("WEBRTC[%d]: rtcSetDataChannelCallback() failed", conn->pc);
686
+ netdata_log_error("WEBRTC[%d]: rtcSetDataChannelCallback() failed", conn->pc);
687
688
// initialize the handshake
689
internal_error(true, "WEBRTC[%d]: setting remote sdp: %s", conn->pc, sdp);
690
if(rtcSetRemoteDescription(conn->pc, sdp, "offer") != RTC_ERR_SUCCESS)
691
- error("WEBRTC[%d]: rtcSetRemoteDescription() failed", conn->pc);
691
+ netdata_log_error("WEBRTC[%d]: rtcSetRemoteDescription() failed", conn->pc);
692
693
// initiate the handshake process
694
if(conn->config.disableAutoNegotiation) {
695
if(rtcSetLocalDescription(conn->pc, NULL) != RTC_ERR_SUCCESS)
696
- error("WEBRTC[%d]: rtcSetLocalDescription() failed", conn->pc);
696
+ netdata_log_error("WEBRTC[%d]: rtcSetLocalDescription() failed", conn->pc);
697
}
698
699
bool logged = false;
web/server/h2o/http_server.c
+4
-4
@@ -78,11 +78,11 @@ static int ssl_init()
78
79
/* load certificate and private key */
80
if (SSL_CTX_use_PrivateKey_file(accept_ctx.ssl_ctx, key_fn, SSL_FILETYPE_PEM) != 1) {
81
- error("Could not load server key from \"%s\"", key_fn);
81
+ netdata_log_error("Could not load server key from \"%s\"", key_fn);
82
return -1;
83
}
84
if (SSL_CTX_use_certificate_file(accept_ctx.ssl_ctx, cert_fn, SSL_FILETYPE_PEM) != 1) {
85
- error("Could not load certificate from \"%s\"", cert_fn);
85
+ netdata_log_error("Could not load certificate from \"%s\"", cert_fn);
86
return -1;
87
}
88
@@ -318,14 +318,14 @@ void *h2o_main(void *ptr) {
318
accept_ctx.hosts = config.hosts;
319
320
if (create_listener(bind_addr, bind_port) != 0) {
321
- error("failed to create listener %s:%d", bind_addr, bind_port);
321
+ netdata_log_error("failed to create listener %s:%d", bind_addr, bind_port);
322
return NULL;
323
}
324
325
while (service_running(SERVICE_HTTPD)) {
326
int rc = h2o_evloop_run(ctx.loop, POLL_INTERVAL);
327
if (rc < 0 && errno != EINTR) {
328
- error("h2o_evloop_run returned (%d) with errno other than EINTR. Aborting", rc);
328
+ netdata_log_error("h2o_evloop_run returned (%d) with errno other than EINTR. Aborting", rc);
329
break;
330
}
331
}
web/server/static/static-threaded.c
+3
-3
@@ -180,7 +180,7 @@ static int web_server_file_write_callback(POLLINFO *pi, short int *events) {
180
(void)events;
181
182
worker_is_busy(WORKER_JOB_WRITE_FILE);
183
- error("Writing to web files is not supported!");
183
+ netdata_log_error("Writing to web files is not supported!");
184
worker_is_idle();
185
186
return -1;
@@ -325,7 +325,7 @@ static int web_server_rcv_callback(POLLINFO *pi, short int *events) {
325
if(fpi)
326
w->pollinfo_filecopy_slot = fpi->slot;
327
else {
328
- error("Failed to add filecopy fd. Closing client.");
328
+ netdata_log_error("Failed to add filecopy fd. Closing client.");
329
ret = -1;
330
goto cleanup;
331
}
@@ -483,7 +483,7 @@ static void socket_listen_main_static_threaded_cleanup(void *ptr) {
483
// }
484
//
485
// if(found)
486
-// error("%d static web threads are taking too long to finish. Giving up.", found);
486
+// netdata_log_error("%d static web threads are taking too long to finish. Giving up.", found);
487
488
netdata_log_info("closing all web server sockets...");
489
listen_sockets_close(&api_sockets);
web/server/web_client.c
+15
-16
@@ -31,7 +31,7 @@ static inline int web_client_cork_socket(struct web_client *w __maybe_unused) {
31
if(likely(web_client_is_corkable(w) && !w->tcp_cork && w->ofd != -1)) {
32
w->tcp_cork = true;
33
if(unlikely(setsockopt(w->ofd, IPPROTO_TCP, TCP_CORK, (char *) &w->tcp_cork, sizeof(int)) != 0)) {
34
- error("%llu: failed to enable TCP_CORK on socket.", w->id);
34
+ netdata_log_error("%llu: failed to enable TCP_CORK on socket.", w->id);
35
36
w->tcp_cork = false;
37
return -1;
@@ -58,7 +58,7 @@ static inline int web_client_uncork_socket(struct web_client *w __maybe_unused)
58
if(likely(w->tcp_cork && w->ofd != -1)) {
59
w->tcp_cork = false;
60
if(unlikely(setsockopt(w->ofd, IPPROTO_TCP, TCP_CORK, (char *) &w->tcp_cork, sizeof(int)) != 0)) {
61
- error("%llu: failed to disable TCP_CORK on socket.", w->id);
61
+ netdata_log_error("%llu: failed to disable TCP_CORK on socket.", w->id);
62
w->tcp_cork = true;
63
return -1;
64
}
@@ -521,7 +521,7 @@ static int mysendfile(struct web_client *w, char *filename) {
521
w->ifd = w->ofd;
522
523
if(errno == EBUSY || errno == EAGAIN) {
524
- error("%llu: File '%s' is busy, sending 307 Moved Temporarily to force retry.", w->id, web_filename);
524
+ netdata_log_error("%llu: File '%s' is busy, sending 307 Moved Temporarily to force retry.", w->id, web_filename);
525
w->response.data->content_type = CT_TEXT_HTML;
526
buffer_sprintf(w->response.header, "Location: /%s\r\n", filename);
527
buffer_strcat(w->response.data, "File is currently busy, please try again later: ");
@@ -529,7 +529,7 @@ static int mysendfile(struct web_client *w, char *filename) {
529
return HTTP_RESP_REDIR_TEMP;
530
}
531
else {
532
- error("%llu: Cannot open file '%s'.", w->id, web_filename);
532
+ netdata_log_error("%llu: Cannot open file '%s'.", w->id, web_filename);
533
w->response.data->content_type = CT_TEXT_HTML;
534
buffer_strcat(w->response.data, "Cannot open file: ");
535
buffer_strcat_htmlescape(w->response.data, web_filename);
@@ -566,7 +566,7 @@ void web_client_enable_deflate(struct web_client *w, int gzip) {
566
}
567
568
if(unlikely(w->response.sent)) {
569
- error("%llu: Cannot enable compression in the middle of a conversation.", w->id);
569
+ netdata_log_error("%llu: Cannot enable compression in the middle of a conversation.", w->id);
570
return;
571
}
572
@@ -587,13 +587,13 @@ void web_client_enable_deflate(struct web_client *w, int gzip) {
587
w->response.zstream.opaque = Z_NULL;
588
589
// if(deflateInit(&w->response.zstream, Z_DEFAULT_COMPRESSION) != Z_OK) {
590
-// error("%llu: Failed to initialize zlib. Proceeding without compression.", w->id);
590
+// netdata_log_error("%llu: Failed to initialize zlib. Proceeding without compression.", w->id);
591
// return;
592
// }
593
594
// Select GZIP compression: windowbits = 15 + 16 = 31
595
if(deflateInit2(&w->response.zstream, web_gzip_level, Z_DEFLATED, 15 + ((gzip)?16:0), 8, web_gzip_strategy) != Z_OK) {
596
- error("%llu: Failed to initialize zlib. Proceeding without compression.", w->id);
596
+ netdata_log_error("%llu: Failed to initialize zlib. Proceeding without compression.", w->id);
597
return;
598
}
599
@@ -977,7 +977,7 @@ static inline char *web_client_valid_method(struct web_client *w, char *s) {
977
memcpy(hostname,"not available",13);
978
hostname[13] = 0x00;
979
}
980
- error("The server is configured to always use encrypted connections, please enable the SSL on child with hostname '%s'.",hostname);
980
+ netdata_log_error("The server is configured to always use encrypted connections, please enable the SSL on child with hostname '%s'.",hostname);
981
s = NULL;
982
}
983
#endif
@@ -1281,7 +1281,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
1281
count++;
1282
1283
if(count > 100 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
1284
- error("Cannot send HTTP headers to web client.");
1284
+ netdata_log_error("Cannot send HTTP headers to web client.");
1285
break;
1286
}
1287
}
@@ -1292,7 +1292,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
1292
count++;
1293
1294
if(count > 100 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
1295
- error("Cannot send HTTP headers to web client.");
1295
+ netdata_log_error("Cannot send HTTP headers to web client.");
1296
break;
1297
}
1298
}
@@ -1302,7 +1302,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
1302
count++;
1303
1304
if(count > 100 || (errno != EAGAIN && errno != EWOULDBLOCK)) {
1305
- error("Cannot send HTTP headers to web client.");
1305
+ netdata_log_error("Cannot send HTTP headers to web client.");
1306
break;
1307
}
1308
}
@@ -1313,8 +1313,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
1313
w->statistics.sent_bytes += bytes;
1314
1315
if (bytes < 0) {
1316
-
1317
- error("HTTP headers failed to be sent (I sent %zu bytes but the system sent %zd bytes). Closing web client."
1316
+ netdata_log_error("HTTP headers failed to be sent (I sent %zu bytes but the system sent %zd bytes). Closing web client."
1317
, buffer_strlen(w->response.header_output)
1318
, bytes);
1319
@@ -1519,7 +1518,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
1518
else
1519
buffer_strcat(w->response.data, "I am doing it already");
1520
1522
- error("web request to exit received.");
1521
+ netdata_log_error("web request to exit received.");
1522
netdata_cleanup_and_exit(0);
1523
return HTTP_RESP_OK;
1524
}
@@ -1773,7 +1772,7 @@ void web_client_process_request(struct web_client *w) {
1772
{
1773
long len = sendfile(w->ofd, w->ifd, NULL, w->response.data->rbytes);
1774
if(len != w->response.data->rbytes)
1776
- error("%llu: sendfile() should copy %ld bytes, but copied %ld. Falling back to manual copy.", w->id, w->response.data->rbytes, len);
1775
+ netdata_log_error("%llu: sendfile() should copy %ld bytes, but copied %ld. Falling back to manual copy.", w->id, w->response.data->rbytes, len);
1776
else
1777
web_client_request_done(w);
1778
}
@@ -1932,7 +1931,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
1931
1932
// compress
1933
if(deflate(&w->response.zstream, flush) == Z_STREAM_ERROR) {
1935
- error("%llu: Compression failed. Closing down client.", w->id);
1934
+ netdata_log_error("%llu: Compression failed. Closing down client.", w->id);
1935
web_client_request_done(w);
1936
return(-1);
1937
}