summaryrefslogtreecommitdiffstats
path: root/database/sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'database/sqlite')
-rw-r--r--database/sqlite/sqlite_aclk_alert.c58
-rw-r--r--database/sqlite/sqlite_aclk_node.c9
-rw-r--r--database/sqlite/sqlite_health.c4
-rw-r--r--database/sqlite/sqlite_metadata.c28
4 files changed, 50 insertions, 49 deletions
diff --git a/database/sqlite/sqlite_aclk_alert.c b/database/sqlite/sqlite_aclk_alert.c
index 62ffab78a5..ec7fcbd05b 100644
--- a/database/sqlite/sqlite_aclk_alert.c
+++ b/database/sqlite/sqlite_aclk_alert.c
@@ -267,7 +267,7 @@ void aclk_push_alert_event(struct aclk_sync_cfg_t *wc)
int rc;
if (unlikely(!wc->alert_updates)) {
- netdata_log_access(
+ nd_log(NDLS_ACCESS, NDLP_NOTICE,
"ACLK STA [%s (%s)]: Ignoring alert push event, updates have been turned off for this node.",
wc->node_id,
wc->host ? rrdhost_hostname(wc->host) : "N/A");
@@ -424,7 +424,7 @@ void aclk_push_alert_event(struct aclk_sync_cfg_t *wc)
} else {
if (wc->alerts_log_first_sequence_id)
- netdata_log_access(
+ nd_log(NDLS_ACCESS, NDLP_DEBUG,
"ACLK RES [%s (%s)]: ALERTS SENT from %" PRIu64 " to %" PRIu64 "",
wc->node_id,
wc->host ? rrdhost_hostname(wc->host) : "N/A",
@@ -523,8 +523,11 @@ void aclk_send_alarm_configuration(char *config_hash)
if (unlikely(!wc))
return;
- netdata_log_access(
- "ACLK REQ [%s (%s)]: Request to send alert config %s.", wc->node_id, rrdhost_hostname(wc->host), config_hash);
+ nd_log(NDLS_ACCESS, NDLP_DEBUG,
+ "ACLK REQ [%s (%s)]: Request to send alert config %s.",
+ wc->node_id,
+ wc->host ? rrdhost_hostname(wc->host) : "N/A",
+ config_hash);
aclk_push_alert_config(wc->node_id, config_hash);
}
@@ -634,13 +637,13 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
}
if (likely(p_alarm_config.cfg_hash)) {
- netdata_log_access("ACLK RES [%s (%s)]: Sent alert config %s.", wc->node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A", config_hash);
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK RES [%s (%s)]: Sent alert config %s.", wc->node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A", config_hash);
aclk_send_provide_alarm_cfg(&p_alarm_config);
freez(p_alarm_config.cfg_hash);
destroy_aclk_alarm_configuration(&alarm_config);
}
else
- netdata_log_access("ACLK STA [%s (%s)]: Alert config for %s not found.", wc->node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A", config_hash);
+ nd_log(NDLS_ACCESS, NDLP_WARNING, "ACLK STA [%s (%s)]: Alert config for %s not found.", wc->node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A", config_hash);
bind_fail:
rc = sqlite3_finalize(res);
@@ -669,20 +672,15 @@ void aclk_start_alert_streaming(char *node_id, bool resets)
return;
if (unlikely(!host->health.health_enabled)) {
- netdata_log_access(
- "ACLK STA [%s (N/A)]: Ignoring request to stream alert state changes, health is disabled.", node_id);
+ nd_log(NDLS_ACCESS, NDLP_NOTICE, "ACLK STA [%s (N/A)]: Ignoring request to stream alert state changes, health is disabled.", node_id);
return;
}
if (resets) {
- netdata_log_access(
- "ACLK REQ [%s (%s)]: STREAM ALERTS ENABLED (RESET REQUESTED)",
- node_id,
- wc->host ? rrdhost_hostname(wc->host) : "N/A");
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK REQ [%s (%s)]: STREAM ALERTS ENABLED (RESET REQUESTED)", node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A");
sql_queue_existing_alerts_to_aclk(host);
} else
- netdata_log_access(
- "ACLK REQ [%s (%s)]: STREAM ALERTS ENABLED", node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A");
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK REQ [%s (%s)]: STREAM ALERTS ENABLED", node_id, wc->host ? rrdhost_hostname(wc->host) : "N/A");
wc->alert_updates = 1;
wc->alert_queue_removed = SEND_REMOVED_AFTER_HEALTH_LOOPS;
@@ -725,7 +723,7 @@ void sql_process_queue_removed_alerts_to_aclk(char *node_id)
rc = execute_insert(res);
if (likely(rc == SQLITE_DONE)) {
- netdata_log_access("ACLK STA [%s (%s)]: QUEUED REMOVED ALERTS", wc->node_id, rrdhost_hostname(wc->host));
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK STA [%s (%s)]: QUEUED REMOVED ALERTS", wc->node_id, rrdhost_hostname(wc->host));
rrdhost_flag_set(wc->host, RRDHOST_FLAG_ACLK_STREAM_ALERTS);
wc->alert_queue_removed = 0;
}
@@ -758,15 +756,15 @@ void aclk_process_send_alarm_snapshot(char *node_id, char *claim_id __maybe_unus
RRDHOST *host = find_host_by_node_id(node_id);
if (unlikely(!host || !(wc = host->aclk_config))) {
- netdata_log_access("ACLK STA [%s (N/A)]: ACLK node id does not exist", node_id);
+ nd_log(NDLS_ACCESS, NDLP_WARNING, "ACLK STA [%s (N/A)]: ACLK node id does not exist", node_id);
return;
}
- netdata_log_access(
- "IN [%s (%s)]: Request to send alerts snapshot, snapshot_uuid %s",
- node_id,
- wc->host ? rrdhost_hostname(wc->host) : "N/A",
- snapshot_uuid);
+ nd_log(NDLS_ACCESS, NDLP_DEBUG,
+ "IN [%s (%s)]: Request to send alerts snapshot, snapshot_uuid %s",
+ node_id,
+ wc->host ? rrdhost_hostname(wc->host) : "N/A",
+ snapshot_uuid);
if (wc->alerts_snapshot_uuid && !strcmp(wc->alerts_snapshot_uuid,snapshot_uuid))
return;
@@ -855,7 +853,7 @@ void aclk_push_alert_snapshot_event(char *node_id __maybe_unused)
RRDHOST *host = find_host_by_node_id(node_id);
if (unlikely(!host)) {
- netdata_log_access("AC [%s (N/A)]: Node id not found", node_id);
+ nd_log(NDLS_ACCESS, NDLP_WARNING, "AC [%s (N/A)]: Node id not found", node_id);
freez(node_id);
return;
}
@@ -865,7 +863,7 @@ void aclk_push_alert_snapshot_event(char *node_id __maybe_unused)
// we perhaps we don't need this for snapshots
if (unlikely(!wc->alert_updates)) {
- netdata_log_access(
+ nd_log(NDLS_ACCESS, NDLP_NOTICE,
"ACLK STA [%s (%s)]: Ignoring alert snapshot event, updates have been turned off for this node.",
wc->node_id,
wc->host ? rrdhost_hostname(wc->host) : "N/A");
@@ -879,7 +877,7 @@ void aclk_push_alert_snapshot_event(char *node_id __maybe_unused)
if (unlikely(!claim_id))
return;
- netdata_log_access("ACLK REQ [%s (%s)]: Sending alerts snapshot, snapshot_uuid %s", wc->node_id, rrdhost_hostname(wc->host), wc->alerts_snapshot_uuid);
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK REQ [%s (%s)]: Sending alerts snapshot, snapshot_uuid %s", wc->node_id, rrdhost_hostname(wc->host), wc->alerts_snapshot_uuid);
uint32_t cnt = 0;
@@ -1057,9 +1055,9 @@ void aclk_send_alarm_checkpoint(char *node_id, char *claim_id __maybe_unused)
RRDHOST *host = find_host_by_node_id(node_id);
if (unlikely(!host || !(wc = host->aclk_config)))
- netdata_log_access("ACLK REQ [%s (N/A)]: ALERTS CHECKPOINT REQUEST RECEIVED FOR INVALID NODE", node_id);
+ nd_log(NDLS_ACCESS, NDLP_WARNING, "ACLK REQ [%s (N/A)]: ALERTS CHECKPOINT REQUEST RECEIVED FOR INVALID NODE", node_id);
else {
- netdata_log_access("ACLK REQ [%s (%s)]: ALERTS CHECKPOINT REQUEST RECEIVED", node_id, rrdhost_hostname(host));
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK REQ [%s (%s)]: ALERTS CHECKPOINT REQUEST RECEIVED", node_id, rrdhost_hostname(host));
wc->alert_checkpoint_req = SEND_CHECKPOINT_AFTER_HEALTH_LOOPS;
}
}
@@ -1087,14 +1085,14 @@ void aclk_push_alarm_checkpoint(RRDHOST *host __maybe_unused)
#ifdef ENABLE_ACLK
struct aclk_sync_cfg_t *wc = host->aclk_config;
if (unlikely(!wc)) {
- netdata_log_access("ACLK REQ [%s (N/A)]: ALERTS CHECKPOINT REQUEST RECEIVED FOR INVALID NODE", rrdhost_hostname(host));
+ nd_log(NDLS_ACCESS, NDLP_WARNING, "ACLK REQ [%s (N/A)]: ALERTS CHECKPOINT REQUEST RECEIVED FOR INVALID NODE", rrdhost_hostname(host));
return;
}
if (rrdhost_flag_check(host, RRDHOST_FLAG_ACLK_STREAM_ALERTS)) {
//postpone checkpoint send
wc->alert_checkpoint_req += 3;
- netdata_log_access("ACLK REQ [%s (N/A)]: ALERTS CHECKPOINT POSTPONED", rrdhost_hostname(host));
+ nd_log(NDLS_ACCESS, NDLP_NOTICE, "ACLK REQ [%s (N/A)]: ALERTS CHECKPOINT POSTPONED", rrdhost_hostname(host));
return;
}
@@ -1157,9 +1155,9 @@ void aclk_push_alarm_checkpoint(RRDHOST *host __maybe_unused)
aclk_send_provide_alarm_checkpoint(&alarm_checkpoint);
freez(claim_id);
- netdata_log_access("ACLK RES [%s (%s)]: ALERTS CHECKPOINT SENT", wc->node_id, rrdhost_hostname(host));
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK RES [%s (%s)]: ALERTS CHECKPOINT SENT", wc->node_id, rrdhost_hostname(host));
} else
- netdata_log_access("ACLK RES [%s (%s)]: FAILED TO CREATE ALERTS CHECKPOINT HASH", wc->node_id, rrdhost_hostname(host));
+ nd_log(NDLS_ACCESS, NDLP_ERR, "ACLK RES [%s (%s)]: FAILED TO CREATE ALERTS CHECKPOINT HASH", wc->node_id, rrdhost_hostname(host));
wc->alert_checkpoint_req = 0;
buffer_free(alarms_to_hash);
diff --git a/database/sqlite/sqlite_aclk_node.c b/database/sqlite/sqlite_aclk_node.c
index 4f48e293f2..4dd644bade 100644
--- a/database/sqlite/sqlite_aclk_node.c
+++ b/database/sqlite/sqlite_aclk_node.c
@@ -43,7 +43,7 @@ static void build_node_collectors(RRDHOST *host)
dictionary_destroy(dict);
freez(upd_node_collectors.claim_id);
- netdata_log_access("ACLK RES [%s (%s)]: NODE COLLECTORS SENT", wc->node_id, rrdhost_hostname(host));
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK RES [%s (%s)]: NODE COLLECTORS SENT", wc->node_id, rrdhost_hostname(host));
}
static void build_node_info(RRDHOST *host)
@@ -103,7 +103,7 @@ static void build_node_info(RRDHOST *host)
node_info.data.host_labels_ptr = host->rrdlabels;
aclk_update_node_info(&node_info);
- netdata_log_access("ACLK RES [%s (%s)]: NODE INFO SENT for guid [%s] (%s)", wc->node_id, rrdhost_hostname(wc->host), host->machine_guid, wc->host == localhost ? "parent" : "child");
+ nd_log(NDLS_ACCESS, NDLP_DEBUG, "ACLK RES [%s (%s)]: NODE INFO SENT for guid [%s] (%s)", wc->node_id, rrdhost_hostname(wc->host), host->machine_guid, wc->host == localhost ? "parent" : "child");
rrd_unlock();
freez(node_info.claim_id);
@@ -169,8 +169,9 @@ void aclk_check_node_info_and_collectors(void)
dfe_done(host);
if (context_loading || replicating) {
- error_limit_static_thread_var(erl, 10, 100 * USEC_PER_MS);
- error_limit(&erl, "%zu nodes loading contexts, %zu replicating data", context_loading, replicating);
+ nd_log_limit_static_thread_var(erl, 10, 100 * USEC_PER_MS);
+ nd_log_limit(&erl, NDLS_DAEMON, NDLP_INFO,
+ "%zu nodes loading contexts, %zu replicating data", context_loading, replicating);
}
}
diff --git a/database/sqlite/sqlite_health.c b/database/sqlite/sqlite_health.c
index c47c6a8926..6f15901ee9 100644
--- a/database/sqlite/sqlite_health.c
+++ b/database/sqlite/sqlite_health.c
@@ -914,7 +914,9 @@ void sql_health_alarm_log_load(RRDHOST *host)
if (unlikely(!host->health_log.next_alarm_id || host->health_log.next_alarm_id <= host->health_max_alarm_id))
host->health_log.next_alarm_id = host->health_max_alarm_id + 1;
- netdata_log_health("[%s]: Table health_log, loaded %zd alarm entries, errors in %zd entries.", rrdhost_hostname(host), loaded, errored);
+ nd_log(NDLS_DAEMON, errored ? NDLP_WARNING : NDLP_DEBUG,
+ "[%s]: Table health_log, loaded %zd alarm entries, errors in %zd entries.",
+ rrdhost_hostname(host), loaded, errored);
ret = sqlite3_finalize(res);
if (unlikely(ret != SQLITE_OK))
diff --git a/database/sqlite/sqlite_metadata.c b/database/sqlite/sqlite_metadata.c
index 8ad98b9230..70af4809c8 100644
--- a/database/sqlite/sqlite_metadata.c
+++ b/database/sqlite/sqlite_metadata.c
@@ -1144,7 +1144,7 @@ void vacuum_database(sqlite3 *database, const char *db_alias, int threshold, int
if (free_pages > (total_pages * threshold / 100)) {
int do_free_pages = (int) (free_pages * vacuum_pc / 100);
- netdata_log_info("%s: Freeing %d database pages", db_alias, do_free_pages);
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "%s: Freeing %d database pages", db_alias, do_free_pages);
char sql[128];
snprintfz(sql, 127, "PRAGMA incremental_vacuum(%d)", do_free_pages);
@@ -1258,7 +1258,7 @@ static void start_all_host_load_context(uv_work_t *req __maybe_unused)
RRDHOST *host;
size_t max_threads = MIN(get_netdata_cpus() / 2, 6);
- netdata_log_info("METADATA: Using %zu threads for context loading", max_threads);
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Using %zu threads for context loading", max_threads);
struct host_context_load_thread *hclt = callocz(max_threads, sizeof(*hclt));
size_t thread_index;
@@ -1291,7 +1291,7 @@ static void start_all_host_load_context(uv_work_t *req __maybe_unused)
cleanup_finished_threads(hclt, max_threads, true);
freez(hclt);
usec_t ended_ut = now_monotonic_usec(); (void)ended_ut;
- netdata_log_info("METADATA: host contexts loaded in %0.2f ms", (double)(ended_ut - started_ut) / USEC_PER_MS);
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: host contexts loaded in %0.2f ms", (double)(ended_ut - started_ut) / USEC_PER_MS);
worker_is_idle();
}
@@ -1556,7 +1556,7 @@ static void metadata_event_loop(void *arg)
wc->timer_req.data = wc;
fatal_assert(0 == uv_timer_start(&wc->timer_req, timer_cb, TIMER_INITIAL_PERIOD_MS, TIMER_REPEAT_PERIOD_MS));
- netdata_log_info("Starting metadata sync thread");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "Starting metadata sync thread");
struct metadata_cmd cmd;
memset(&cmd, 0, sizeof(cmd));
@@ -1684,7 +1684,7 @@ static void metadata_event_loop(void *arg)
freez(loop);
worker_unregister();
- netdata_log_info("Shutting down event loop");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "Shutting down event loop");
completion_mark_complete(&wc->start_stop_complete);
if (wc->scan_complete) {
completion_destroy(wc->scan_complete);
@@ -1710,15 +1710,15 @@ void metadata_sync_shutdown(void)
struct metadata_cmd cmd;
memset(&cmd, 0, sizeof(cmd));
- netdata_log_info("METADATA: Sending a shutdown command");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Sending a shutdown command");
cmd.opcode = METADATA_SYNC_SHUTDOWN;
metadata_enq_cmd(&metasync_worker, &cmd);
/* wait for metadata thread to shut down */
- netdata_log_info("METADATA: Waiting for shutdown ACK");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Waiting for shutdown ACK");
completion_wait_for(&metasync_worker.start_stop_complete);
completion_destroy(&metasync_worker.start_stop_complete);
- netdata_log_info("METADATA: Shutdown complete");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Shutdown complete");
}
void metadata_sync_shutdown_prepare(void)
@@ -1735,20 +1735,20 @@ void metadata_sync_shutdown_prepare(void)
completion_init(compl);
__atomic_store_n(&wc->scan_complete, compl, __ATOMIC_RELAXED);
- netdata_log_info("METADATA: Sending a scan host command");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Sending a scan host command");
uint32_t max_wait_iterations = 2000;
while (unlikely(metadata_flag_check(&metasync_worker, METADATA_FLAG_PROCESSING)) && max_wait_iterations--) {
if (max_wait_iterations == 1999)
- netdata_log_info("METADATA: Current worker is running; waiting to finish");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Current worker is running; waiting to finish");
sleep_usec(1000);
}
cmd.opcode = METADATA_SCAN_HOSTS;
metadata_enq_cmd(&metasync_worker, &cmd);
- netdata_log_info("METADATA: Waiting for host scan completion");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Waiting for host scan completion");
completion_wait_for(wc->scan_complete);
- netdata_log_info("METADATA: Host scan complete; can continue with shutdown");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "METADATA: Host scan complete; can continue with shutdown");
}
// -------------------------------------------------------------
@@ -1766,7 +1766,7 @@ void metadata_sync_init(void)
completion_wait_for(&wc->start_stop_complete);
completion_destroy(&wc->start_stop_complete);
- netdata_log_info("SQLite metadata sync initialization complete");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "SQLite metadata sync initialization complete");
}
@@ -1825,7 +1825,7 @@ void metadata_queue_load_host_context(RRDHOST *host)
if (unlikely(!metasync_worker.loop))
return;
queue_metadata_cmd(METADATA_LOAD_HOST_CONTEXT, host, NULL);
- netdata_log_info("Queued command to load host contexts");
+ nd_log(NDLS_DAEMON, NDLP_DEBUG, "Queued command to load host contexts");
}
//