0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-25 21:43:55 +00:00

Rename log Macros (debug) ()

This commit is contained in:
thiagoftsm 2023-07-11 14:45:16 +00:00 committed by GitHub
parent f00b398016
commit f672f4a955
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 677 additions and 676 deletions

View file

@ -110,7 +110,7 @@ static int load_private_key()
netdata_log_error("Claimed agent cannot establish ACLK - unable to load private key '%s' failed.", filename); netdata_log_error("Claimed agent cannot establish ACLK - unable to load private key '%s' failed.", filename);
return 1; return 1;
} }
debug(D_ACLK, "Claimed agent loaded private key len=%ld bytes", bytes_read); netdata_log_debug(D_ACLK, "Claimed agent loaded private key len=%ld bytes", bytes_read);
BIO *key_bio = BIO_new_mem_buf(private_key, -1); BIO *key_bio = BIO_new_mem_buf(private_key, -1);
if (key_bio==NULL) { if (key_bio==NULL) {
@ -240,7 +240,7 @@ void aclk_mqtt_wss_log_cb(mqtt_wss_log_type_t log_type, const char* str)
netdata_log_info("%s", str); netdata_log_info("%s", str);
return; return;
case MQTT_WSS_LOG_DEBUG: case MQTT_WSS_LOG_DEBUG:
debug(D_ACLK, "%s", str); netdata_log_debug(D_ACLK, "%s", str);
return; return;
default: default:
netdata_log_error("Unknown log type from mqtt_wss"); netdata_log_error("Unknown log type from mqtt_wss");
@ -252,7 +252,7 @@ static void msg_callback(const char *topic, const void *msg, size_t msglen, int
UNUSED(qos); UNUSED(qos);
aclk_rcvd_cloud_msgs++; aclk_rcvd_cloud_msgs++;
debug(D_ACLK, "Got Message From Broker Topic \"%s\" QOS %d", topic, qos); netdata_log_debug(D_ACLK, "Got Message From Broker Topic \"%s\" QOS %d", topic, qos);
if (aclk_shared_state.mqtt_shutdown_msg_id > 0) { if (aclk_shared_state.mqtt_shutdown_msg_id > 0) {
netdata_log_error("Link is shutting down. Ignoring incoming message."); netdata_log_error("Link is shutting down. Ignoring incoming message.");

View file

@ -286,10 +286,10 @@ static void aclk_query_process_msg(struct aclk_query_thread *query_thr, aclk_que
worker_is_busy(query->type); worker_is_busy(query->type);
if (query->type == HTTP_API_V2) { if (query->type == HTTP_API_V2) {
debug(D_ACLK, "Processing Queued Message of type: \"http_api_request_v2\""); netdata_log_debug(D_ACLK, "Processing Queued Message of type: \"http_api_request_v2\"");
http_api_v2(query_thr, query); http_api_v2(query_thr, query);
} else { } else {
debug(D_ACLK, "Processing Queued Message of type: \"%s\"", query->data.bin_payload.msg_name); netdata_log_debug(D_ACLK, "Processing Queued Message of type: \"%s\"", query->data.bin_payload.msg_name);
send_bin_msg(query_thr, query); send_bin_msg(query_thr, query);
} }

View file

@ -180,7 +180,7 @@ int aclk_handle_cloud_cmd_message(char *payload)
return 1; return 1;
} }
debug(D_ACLK, "ACLK incoming 'cmd' message (%s)", payload); netdata_log_debug(D_ACLK, "ACLK incoming 'cmd' message (%s)", payload);
int rc = json_parse(payload, &cloud_to_agent, cloud_to_agent_parse); int rc = json_parse(payload, &cloud_to_agent, cloud_to_agent_parse);
@ -250,7 +250,7 @@ int create_node_instance_result(const char *msg, size_t msg_len)
return 1; return 1;
} }
debug(D_ACLK, "CreateNodeInstanceResult: guid:%s nodeid:%s", res.machine_guid, res.node_id); netdata_log_debug(D_ACLK, "CreateNodeInstanceResult: guid:%s nodeid:%s", res.machine_guid, res.node_id);
uuid_t host_id, node_id; uuid_t host_id, node_id;
if (uuid_parse(res.machine_guid, host_id)) { if (uuid_parse(res.machine_guid, host_id)) {
@ -529,7 +529,7 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
ACLK_STATS_UNLOCK; ACLK_STATS_UNLOCK;
} }
new_cloud_rx_msg_t *msg_descriptor = find_rx_handler_by_hash(simple_hash(message_type)); new_cloud_rx_msg_t *msg_descriptor = find_rx_handler_by_hash(simple_hash(message_type));
debug(D_ACLK, "Got message named '%s' from cloud", message_type); netdata_log_debug(D_ACLK, "Got message named '%s' from cloud", message_type);
if (unlikely(!msg_descriptor)) { if (unlikely(!msg_descriptor)) {
netdata_log_error("Do not know how to handle message of type '%s'. Ignoring", message_type); netdata_log_error("Do not know how to handle message of type '%s'. Ignoring", message_type);
if (aclk_stats_enabled) { if (aclk_stats_enabled) {

View file

@ -219,7 +219,7 @@ static int topic_cache_add_topic(struct json_object *json, struct aclk_topic *to
} }
topic->topic_id = topic_name_to_id(json_object_get_string(json_object_iter_peek_value(&it))); topic->topic_id = topic_name_to_id(json_object_get_string(json_object_iter_peek_value(&it)));
if (topic->topic_id == ACLK_TOPICID_UNKNOWN) { if (topic->topic_id == ACLK_TOPICID_UNKNOWN) {
debug(D_ACLK, "topic dictionary has unknown topic name \"%s\"", json_object_get_string(json_object_iter_peek_value(&it))); netdata_log_debug(D_ACLK, "topic dictionary has unknown topic name \"%s\"", json_object_get_string(json_object_iter_peek_value(&it)));
} }
json_object_iter_next(&it); json_object_iter_next(&it);
continue; continue;

View file

@ -427,10 +427,12 @@ void read_cgroup_plugin_configuration() {
//TODO: can there be more than 1 cgroup2 mount point? //TODO: can there be more than 1 cgroup2 mount point?
mi = mountinfo_find_by_filesystem_super_option(root, "cgroup2", "rw"); //there is no cgroup2 specific super option - for now use 'rw' option mi = mountinfo_find_by_filesystem_super_option(root, "cgroup2", "rw"); //there is no cgroup2 specific super option - for now use 'rw' option
if(mi) debug(D_CGROUP, "found unified cgroup root using super options, with path: '%s'", mi->mount_point); if(mi)
netdata_log_debug(D_CGROUP, "found unified cgroup root using super options, with path: '%s'", mi->mount_point);
if(!mi) { if(!mi) {
mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup2", "cgroup"); mi = mountinfo_find_by_filesystem_mount_source(root, "cgroup2", "cgroup");
if(mi) debug(D_CGROUP, "found unified cgroup root using mountsource info, with path: '%s'", mi->mount_point); if(mi)
netdata_log_debug(D_CGROUP, "found unified cgroup root using mountsource info, with path: '%s'", mi->mount_point);
} }
if(!mi) { if(!mi) {
collector_error("CGROUP: cannot find cgroup2 mountinfo. Assuming default: /sys/fs/cgroup"); collector_error("CGROUP: cannot find cgroup2 mountinfo. Assuming default: /sys/fs/cgroup");
@ -439,7 +441,7 @@ void read_cgroup_plugin_configuration() {
else s = mi->mount_point; else s = mi->mount_point;
set_cgroup_base_path(filename, s); set_cgroup_base_path(filename, s);
cgroup_unified_base = config_get("plugin:cgroups", "path to unified cgroups", filename); cgroup_unified_base = config_get("plugin:cgroups", "path to unified cgroups", filename);
debug(D_CGROUP, "using cgroup root: '%s'", cgroup_unified_base); netdata_log_debug(D_CGROUP, "using cgroup root: '%s'", cgroup_unified_base);
} }
cgroup_root_max = (int)config_get_number("plugin:cgroups", "max cgroups to allow", cgroup_root_max); cgroup_root_max = (int)config_get_number("plugin:cgroups", "max cgroups to allow", cgroup_root_max);
@ -982,13 +984,13 @@ static int k8s_get_container_first_proc_comm(const char *id, char *comm) {
ff = procfile_reopen(ff, filename, NULL, CGROUP_PROCFILE_FLAG); ff = procfile_reopen(ff, filename, NULL, CGROUP_PROCFILE_FLAG);
if (unlikely(!ff)) { if (unlikely(!ff)) {
debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot open file '%s'.", filename); netdata_log_debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot open file '%s'.", filename);
return 1; return 1;
} }
ff = procfile_readall(ff); ff = procfile_readall(ff);
if (unlikely(!ff)) { if (unlikely(!ff)) {
debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot read file '%s'.", filename); netdata_log_debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot read file '%s'.", filename);
return 1; return 1;
} }
@ -1006,13 +1008,13 @@ static int k8s_get_container_first_proc_comm(const char *id, char *comm) {
ff = procfile_reopen(ff, filename, NULL, PROCFILE_FLAG_DEFAULT); ff = procfile_reopen(ff, filename, NULL, PROCFILE_FLAG_DEFAULT);
if (unlikely(!ff)) { if (unlikely(!ff)) {
debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot open file '%s'.", filename); netdata_log_debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot open file '%s'.", filename);
return 1; return 1;
} }
ff = procfile_readall(ff); ff = procfile_readall(ff);
if (unlikely(!ff)) { if (unlikely(!ff)) {
debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot read file '%s'.", filename); netdata_log_debug(D_CGROUP, "CGROUP: k8s_is_pause_container(): cannot read file '%s'.", filename);
return 1; return 1;
} }
@ -1612,7 +1614,7 @@ memory_next:
} }
static inline void read_cgroup(struct cgroup *cg) { static inline void read_cgroup(struct cgroup *cg) {
debug(D_CGROUP, "reading metrics for cgroups '%s'", cg->id); netdata_log_debug(D_CGROUP, "reading metrics for cgroups '%s'", cg->id);
if(!(cg->options & CGROUP_OPTIONS_IS_UNIFIED)) { if(!(cg->options & CGROUP_OPTIONS_IS_UNIFIED)) {
cgroup_read_cpuacct_stat(&cg->cpuacct_stat); cgroup_read_cpuacct_stat(&cg->cpuacct_stat);
cgroup_read_cpuacct_usage(&cg->cpuacct_usage); cgroup_read_cpuacct_usage(&cg->cpuacct_usage);
@ -1640,7 +1642,7 @@ static inline void read_cgroup(struct cgroup *cg) {
} }
static inline void read_all_discovered_cgroups(struct cgroup *root) { static inline void read_all_discovered_cgroups(struct cgroup *root) {
debug(D_CGROUP, "reading metrics for all cgroups"); netdata_log_debug(D_CGROUP, "reading metrics for all cgroups");
struct cgroup *cg; struct cgroup *cg;
for (cg = root; cg; cg = cg->next) { for (cg = root; cg; cg = cg->next) {
@ -1655,7 +1657,7 @@ static inline void read_all_discovered_cgroups(struct cgroup *root) {
#define CGROUP_NETWORK_INTERFACE_MAX_LINE 2048 #define CGROUP_NETWORK_INTERFACE_MAX_LINE 2048
static inline void read_cgroup_network_interfaces(struct cgroup *cg) { static inline void read_cgroup_network_interfaces(struct cgroup *cg) {
debug(D_CGROUP, "looking for the network interfaces of cgroup '%s' with chart id '%s' and title '%s'", cg->id, cg->chart_id, cg->chart_title); netdata_log_debug(D_CGROUP, "looking for the network interfaces of cgroup '%s' with chart id '%s' and title '%s'", cg->id, cg->chart_id, cg->chart_title);
pid_t cgroup_pid; pid_t cgroup_pid;
char cgroup_identifier[CGROUP_NETWORK_INTERFACE_MAX_LINE + 1]; char cgroup_identifier[CGROUP_NETWORK_INTERFACE_MAX_LINE + 1];
@ -1667,7 +1669,7 @@ static inline void read_cgroup_network_interfaces(struct cgroup *cg) {
snprintfz(cgroup_identifier, CGROUP_NETWORK_INTERFACE_MAX_LINE, "%s%s", cgroup_unified_base, cg->id); snprintfz(cgroup_identifier, CGROUP_NETWORK_INTERFACE_MAX_LINE, "%s%s", cgroup_unified_base, cg->id);
} }
debug(D_CGROUP, "executing cgroup_identifier %s --cgroup '%s' for cgroup '%s'", cgroups_network_interface_script, cgroup_identifier, cg->id); netdata_log_debug(D_CGROUP, "executing cgroup_identifier %s --cgroup '%s' for cgroup '%s'", cgroups_network_interface_script, cgroup_identifier, cg->id);
FILE *fp_child_input, *fp_child_output; FILE *fp_child_input, *fp_child_output;
(void)netdata_popen_raw_default_flags_and_environment(&cgroup_pid, &fp_child_input, &fp_child_output, cgroups_network_interface_script, "--cgroup", cgroup_identifier); (void)netdata_popen_raw_default_flags_and_environment(&cgroup_pid, &fp_child_input, &fp_child_output, cgroups_network_interface_script, "--cgroup", cgroup_identifier);
if(!fp_child_output) { if(!fp_child_output) {
@ -1713,7 +1715,7 @@ static inline void read_cgroup_network_interfaces(struct cgroup *cg) {
} }
netdata_pclose(fp_child_input, fp_child_output, cgroup_pid); netdata_pclose(fp_child_input, fp_child_output, cgroup_pid);
// debug(D_CGROUP, "closed cgroup_identifier for cgroup '%s'", cg->id); // netdata_log_debug(D_CGROUP, "closed cgroup_identifier for cgroup '%s'", cg->id);
} }
static inline void free_cgroup_network_interfaces(struct cgroup *cg) { static inline void free_cgroup_network_interfaces(struct cgroup *cg) {
@ -1793,7 +1795,7 @@ static inline void free_pressure(struct pressure *res) {
} }
static inline void cgroup_free(struct cgroup *cg) { static inline void cgroup_free(struct cgroup *cg) {
debug(D_CGROUP, "Removing cgroup '%s' with chart id '%s' (was %s and %s)", cg->id, cg->chart_id, (cg->enabled)?"enabled":"disabled", (cg->available)?"available":"not available"); netdata_log_debug(D_CGROUP, "Removing cgroup '%s' with chart id '%s' (was %s and %s)", cg->id, cg->chart_id, (cg->enabled)?"enabled":"disabled", (cg->available)?"available":"not available");
if(cg->st_cpu) rrdset_is_obsolete(cg->st_cpu); if(cg->st_cpu) rrdset_is_obsolete(cg->st_cpu);
if(cg->st_cpu_limit) rrdset_is_obsolete(cg->st_cpu_limit); if(cg->st_cpu_limit) rrdset_is_obsolete(cg->st_cpu_limit);
@ -1870,8 +1872,8 @@ static inline void discovery_rename_cgroup(struct cgroup *cg) {
} }
cg->pending_renames--; cg->pending_renames--;
debug(D_CGROUP, "looking for the name of cgroup '%s' with chart id '%s' and title '%s'", cg->id, cg->chart_id, cg->chart_title); netdata_log_debug(D_CGROUP, "looking for the name of cgroup '%s' with chart id '%s' and title '%s'", cg->id, cg->chart_id, cg->chart_title);
debug(D_CGROUP, "executing command %s \"%s\" for cgroup '%s'", cgroups_rename_script, cg->intermediate_id, cg->chart_id); netdata_log_debug(D_CGROUP, "executing command %s \"%s\" for cgroup '%s'", cgroups_rename_script, cg->intermediate_id, cg->chart_id);
pid_t cgroup_pid; pid_t cgroup_pid;
FILE *fp_child_input, *fp_child_output; FILE *fp_child_input, *fp_child_output;
@ -1984,7 +1986,7 @@ static inline void convert_cgroup_to_systemd_service(struct cgroup *cg) {
} }
static inline struct cgroup *discovery_cgroup_add(const char *id) { static inline struct cgroup *discovery_cgroup_add(const char *id) {
debug(D_CGROUP, "adding to list, cgroup with id '%s'", id); netdata_log_debug(D_CGROUP, "adding to list, cgroup with id '%s'", id);
struct cgroup *cg = callocz(1, sizeof(struct cgroup)); struct cgroup *cg = callocz(1, sizeof(struct cgroup));
cg->id = strdupz(id); cg->id = strdupz(id);
@ -2011,7 +2013,7 @@ static inline struct cgroup *discovery_cgroup_add(const char *id) {
} }
static inline struct cgroup *discovery_cgroup_find(const char *id) { static inline struct cgroup *discovery_cgroup_find(const char *id) {
debug(D_CGROUP, "searching for cgroup '%s'", id); netdata_log_debug(D_CGROUP, "searching for cgroup '%s'", id);
uint32_t hash = simple_hash(id); uint32_t hash = simple_hash(id);
@ -2021,7 +2023,7 @@ static inline struct cgroup *discovery_cgroup_find(const char *id) {
break; break;
} }
debug(D_CGROUP, "cgroup '%s' %s in memory", id, (cg)?"found":"not found"); netdata_log_debug(D_CGROUP, "cgroup '%s' %s in memory", id, (cg)?"found":"not found");
return cg; return cg;
} }
@ -2029,7 +2031,7 @@ static inline void discovery_find_cgroup_in_dir_callback(const char *dir) {
if (!dir || !*dir) { if (!dir || !*dir) {
dir = "/"; dir = "/";
} }
debug(D_CGROUP, "examining cgroup dir '%s'", dir); netdata_log_debug(D_CGROUP, "examining cgroup dir '%s'", dir);
struct cgroup *cg = discovery_cgroup_find(dir); struct cgroup *cg = discovery_cgroup_find(dir);
if (cg) { if (cg) {
@ -2058,7 +2060,7 @@ static inline void discovery_find_cgroup_in_dir_callback(const char *dir) {
static inline int discovery_find_dir_in_subdirs(const char *base, const char *this, void (*callback)(const char *)) { static inline int discovery_find_dir_in_subdirs(const char *base, const char *this, void (*callback)(const char *)) {
if(!this) this = base; if(!this) this = base;
debug(D_CGROUP, "searching for directories in '%s' (base '%s')", this?this:"", base); netdata_log_debug(D_CGROUP, "searching for directories in '%s' (base '%s')", this?this:"", base);
size_t dirlen = strlen(this), baselen = strlen(base); size_t dirlen = strlen(this), baselen = strlen(base);
@ -2112,7 +2114,7 @@ static inline int discovery_find_dir_in_subdirs(const char *base, const char *th
} }
static inline void discovery_mark_all_cgroups_as_unavailable() { static inline void discovery_mark_all_cgroups_as_unavailable() {
debug(D_CGROUP, "marking all cgroups as not available"); netdata_log_debug(D_CGROUP, "marking all cgroups as not available");
struct cgroup *cg; struct cgroup *cg;
for (cg = discovered_cgroup_root; cg; cg = cg->discovered_next) { for (cg = discovered_cgroup_root; cg; cg = cg->discovered_next) {
cg->available = 0; cg->available = 0;
@ -2126,7 +2128,7 @@ static inline void discovery_update_filenames() {
if(unlikely(!cg->available || !cg->enabled || cg->pending_renames)) if(unlikely(!cg->available || !cg->enabled || cg->pending_renames))
continue; continue;
debug(D_CGROUP, "checking paths for cgroup '%s'", cg->id); netdata_log_debug(D_CGROUP, "checking paths for cgroup '%s'", cg->id);
// check for newly added cgroups // check for newly added cgroups
// and update the filenames they read // and update the filenames they read
@ -2143,10 +2145,10 @@ static inline void discovery_update_filenames() {
cg->filename_cpu_cfs_period = strdupz(filename); cg->filename_cpu_cfs_period = strdupz(filename);
snprintfz(filename, FILENAME_MAX, "%s%s/cpu.cfs_quota_us", cgroup_cpuacct_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/cpu.cfs_quota_us", cgroup_cpuacct_base, cg->id);
cg->filename_cpu_cfs_quota = strdupz(filename); cg->filename_cpu_cfs_quota = strdupz(filename);
debug(D_CGROUP, "cpuacct.stat filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_stat.filename); netdata_log_debug(D_CGROUP, "cpuacct.stat filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_stat.filename);
} }
else else
debug(D_CGROUP, "cpuacct.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "cpuacct.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_cpuacct_usage && !cg->cpuacct_usage.filename && !is_cgroup_systemd_service(cg))) { if(unlikely(cgroup_enable_cpuacct_usage && !cg->cpuacct_usage.filename && !is_cgroup_systemd_service(cg))) {
@ -2154,20 +2156,20 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->cpuacct_usage.filename = strdupz(filename); cg->cpuacct_usage.filename = strdupz(filename);
cg->cpuacct_usage.enabled = cgroup_enable_cpuacct_usage; cg->cpuacct_usage.enabled = cgroup_enable_cpuacct_usage;
debug(D_CGROUP, "cpuacct.usage_percpu filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_usage.filename); netdata_log_debug(D_CGROUP, "cpuacct.usage_percpu filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_usage.filename);
} }
else else
debug(D_CGROUP, "cpuacct.usage_percpu file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "cpuacct.usage_percpu file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_cpuacct_cpu_throttling && !cg->cpuacct_cpu_throttling.filename && !is_cgroup_systemd_service(cg))) { if(unlikely(cgroup_enable_cpuacct_cpu_throttling && !cg->cpuacct_cpu_throttling.filename && !is_cgroup_systemd_service(cg))) {
snprintfz(filename, FILENAME_MAX, "%s%s/cpu.stat", cgroup_cpuacct_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/cpu.stat", cgroup_cpuacct_base, cg->id);
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->cpuacct_cpu_throttling.filename = strdupz(filename); cg->cpuacct_cpu_throttling.filename = strdupz(filename);
cg->cpuacct_cpu_throttling.enabled = cgroup_enable_cpuacct_cpu_throttling; cg->cpuacct_cpu_throttling.enabled = cgroup_enable_cpuacct_cpu_throttling;
debug(D_CGROUP, "cpu.stat filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_cpu_throttling.filename); netdata_log_debug(D_CGROUP, "cpu.stat filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_cpu_throttling.filename);
} }
else else
debug(D_CGROUP, "cpu.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "cpu.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if (unlikely( if (unlikely(
cgroup_enable_cpuacct_cpu_shares && !cg->cpuacct_cpu_shares.filename && cgroup_enable_cpuacct_cpu_shares && !cg->cpuacct_cpu_shares.filename &&
@ -2176,10 +2178,10 @@ static inline void discovery_update_filenames() {
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->cpuacct_cpu_shares.filename = strdupz(filename); cg->cpuacct_cpu_shares.filename = strdupz(filename);
cg->cpuacct_cpu_shares.enabled = cgroup_enable_cpuacct_cpu_shares; cg->cpuacct_cpu_shares.enabled = cgroup_enable_cpuacct_cpu_shares;
debug( netdata_log_debug(
D_CGROUP, "cpu.shares filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_cpu_shares.filename); D_CGROUP, "cpu.shares filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_cpu_shares.filename);
} else } else
debug(D_CGROUP, "cpu.shares file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "cpu.shares file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely((cgroup_enable_detailed_memory || cgroup_used_memory) && !cg->memory.filename_detailed && (cgroup_used_memory || cgroup_enable_systemd_services_detailed_memory || !is_cgroup_systemd_service(cg)))) { if(unlikely((cgroup_enable_detailed_memory || cgroup_used_memory) && !cg->memory.filename_detailed && (cgroup_used_memory || cgroup_enable_systemd_services_detailed_memory || !is_cgroup_systemd_service(cg)))) {
@ -2187,10 +2189,10 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->memory.filename_detailed = strdupz(filename); cg->memory.filename_detailed = strdupz(filename);
cg->memory.enabled_detailed = (cgroup_enable_detailed_memory == CONFIG_BOOLEAN_YES)?CONFIG_BOOLEAN_YES:CONFIG_BOOLEAN_AUTO; cg->memory.enabled_detailed = (cgroup_enable_detailed_memory == CONFIG_BOOLEAN_YES)?CONFIG_BOOLEAN_YES:CONFIG_BOOLEAN_AUTO;
debug(D_CGROUP, "memory.stat filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_detailed); netdata_log_debug(D_CGROUP, "memory.stat filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_detailed);
} }
else else
debug(D_CGROUP, "memory.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_memory && !cg->memory.filename_usage_in_bytes)) { if(unlikely(cgroup_enable_memory && !cg->memory.filename_usage_in_bytes)) {
@ -2198,12 +2200,12 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->memory.filename_usage_in_bytes = strdupz(filename); cg->memory.filename_usage_in_bytes = strdupz(filename);
cg->memory.enabled_usage_in_bytes = cgroup_enable_memory; cg->memory.enabled_usage_in_bytes = cgroup_enable_memory;
debug(D_CGROUP, "memory.usage_in_bytes filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_usage_in_bytes); netdata_log_debug(D_CGROUP, "memory.usage_in_bytes filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_usage_in_bytes);
snprintfz(filename, FILENAME_MAX, "%s%s/memory.limit_in_bytes", cgroup_memory_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/memory.limit_in_bytes", cgroup_memory_base, cg->id);
cg->filename_memory_limit = strdupz(filename); cg->filename_memory_limit = strdupz(filename);
} }
else else
debug(D_CGROUP, "memory.usage_in_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.usage_in_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_swap && !cg->memory.filename_msw_usage_in_bytes)) { if(unlikely(cgroup_enable_swap && !cg->memory.filename_msw_usage_in_bytes)) {
@ -2213,10 +2215,10 @@ static inline void discovery_update_filenames() {
cg->memory.enabled_msw_usage_in_bytes = cgroup_enable_swap; cg->memory.enabled_msw_usage_in_bytes = cgroup_enable_swap;
snprintfz(filename, FILENAME_MAX, "%s%s/memory.memsw.limit_in_bytes", cgroup_memory_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/memory.memsw.limit_in_bytes", cgroup_memory_base, cg->id);
cg->filename_memoryswap_limit = strdupz(filename); cg->filename_memoryswap_limit = strdupz(filename);
debug(D_CGROUP, "memory.msw_usage_in_bytes filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_msw_usage_in_bytes); netdata_log_debug(D_CGROUP, "memory.msw_usage_in_bytes filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_msw_usage_in_bytes);
} }
else else
debug(D_CGROUP, "memory.msw_usage_in_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.msw_usage_in_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_memory_failcnt && !cg->memory.filename_failcnt)) { if(unlikely(cgroup_enable_memory_failcnt && !cg->memory.filename_failcnt)) {
@ -2224,10 +2226,10 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->memory.filename_failcnt = strdupz(filename); cg->memory.filename_failcnt = strdupz(filename);
cg->memory.enabled_failcnt = cgroup_enable_memory_failcnt; cg->memory.enabled_failcnt = cgroup_enable_memory_failcnt;
debug(D_CGROUP, "memory.failcnt filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_failcnt); netdata_log_debug(D_CGROUP, "memory.failcnt filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_failcnt);
} }
else else
debug(D_CGROUP, "memory.failcnt file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.failcnt file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_blkio_io && !cg->io_service_bytes.filename)) { if(unlikely(cgroup_enable_blkio_io && !cg->io_service_bytes.filename)) {
@ -2235,16 +2237,16 @@ static inline void discovery_update_filenames() {
if (unlikely(stat(filename, &buf) != -1)) { if (unlikely(stat(filename, &buf) != -1)) {
cg->io_service_bytes.filename = strdupz(filename); cg->io_service_bytes.filename = strdupz(filename);
cg->io_service_bytes.enabled = cgroup_enable_blkio_io; cg->io_service_bytes.enabled = cgroup_enable_blkio_io;
debug(D_CGROUP, "blkio.io_service_bytes_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename); netdata_log_debug(D_CGROUP, "blkio.io_service_bytes_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_service_bytes_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_service_bytes_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename);
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_service_bytes", cgroup_blkio_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_service_bytes", cgroup_blkio_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->io_service_bytes.filename = strdupz(filename); cg->io_service_bytes.filename = strdupz(filename);
cg->io_service_bytes.enabled = cgroup_enable_blkio_io; cg->io_service_bytes.enabled = cgroup_enable_blkio_io;
debug(D_CGROUP, "blkio.io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename); netdata_log_debug(D_CGROUP, "blkio.io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
} }
} }
@ -2254,16 +2256,16 @@ static inline void discovery_update_filenames() {
if (unlikely(stat(filename, &buf) != -1)) { if (unlikely(stat(filename, &buf) != -1)) {
cg->io_serviced.filename = strdupz(filename); cg->io_serviced.filename = strdupz(filename);
cg->io_serviced.enabled = cgroup_enable_blkio_ops; cg->io_serviced.enabled = cgroup_enable_blkio_ops;
debug(D_CGROUP, "blkio.io_serviced_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_serviced.filename); netdata_log_debug(D_CGROUP, "blkio.io_serviced_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_serviced.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_serviced_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_serviced_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename);
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_serviced", cgroup_blkio_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_serviced", cgroup_blkio_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->io_serviced.filename = strdupz(filename); cg->io_serviced.filename = strdupz(filename);
cg->io_serviced.enabled = cgroup_enable_blkio_ops; cg->io_serviced.enabled = cgroup_enable_blkio_ops;
debug(D_CGROUP, "blkio.io_serviced filename for cgroup '%s': '%s'", cg->id, cg->io_serviced.filename); netdata_log_debug(D_CGROUP, "blkio.io_serviced filename for cgroup '%s': '%s'", cg->id, cg->io_serviced.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
} }
} }
@ -2273,17 +2275,17 @@ static inline void discovery_update_filenames() {
if (unlikely(stat(filename, &buf) != -1)) { if (unlikely(stat(filename, &buf) != -1)) {
cg->throttle_io_service_bytes.filename = strdupz(filename); cg->throttle_io_service_bytes.filename = strdupz(filename);
cg->throttle_io_service_bytes.enabled = cgroup_enable_blkio_throttle_io; cg->throttle_io_service_bytes.enabled = cgroup_enable_blkio_throttle_io;
debug(D_CGROUP,"blkio.throttle.io_service_bytes_recursive filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_service_bytes.filename); netdata_log_debug(D_CGROUP,"blkio.throttle.io_service_bytes_recursive filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_service_bytes.filename);
} else { } else {
debug(D_CGROUP, "blkio.throttle.io_service_bytes_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_service_bytes_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename);
snprintfz( snprintfz(
filename, FILENAME_MAX, "%s%s/blkio.throttle.io_service_bytes", cgroup_blkio_base, cg->id); filename, FILENAME_MAX, "%s%s/blkio.throttle.io_service_bytes", cgroup_blkio_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->throttle_io_service_bytes.filename = strdupz(filename); cg->throttle_io_service_bytes.filename = strdupz(filename);
cg->throttle_io_service_bytes.enabled = cgroup_enable_blkio_throttle_io; cg->throttle_io_service_bytes.enabled = cgroup_enable_blkio_throttle_io;
debug(D_CGROUP, "blkio.throttle.io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_service_bytes.filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_service_bytes.filename);
} else { } else {
debug(D_CGROUP, "blkio.throttle.io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
} }
} }
@ -2293,16 +2295,16 @@ static inline void discovery_update_filenames() {
if (unlikely(stat(filename, &buf) != -1)) { if (unlikely(stat(filename, &buf) != -1)) {
cg->throttle_io_serviced.filename = strdupz(filename); cg->throttle_io_serviced.filename = strdupz(filename);
cg->throttle_io_serviced.enabled = cgroup_enable_blkio_throttle_ops; cg->throttle_io_serviced.enabled = cgroup_enable_blkio_throttle_ops;
debug(D_CGROUP, "blkio.throttle.io_serviced_recursive filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_serviced.filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_serviced_recursive filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_serviced.filename);
} else { } else {
debug(D_CGROUP, "blkio.throttle.io_serviced_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_serviced_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename);
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.throttle.io_serviced", cgroup_blkio_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/blkio.throttle.io_serviced", cgroup_blkio_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->throttle_io_serviced.filename = strdupz(filename); cg->throttle_io_serviced.filename = strdupz(filename);
cg->throttle_io_serviced.enabled = cgroup_enable_blkio_throttle_ops; cg->throttle_io_serviced.enabled = cgroup_enable_blkio_throttle_ops;
debug(D_CGROUP, "blkio.throttle.io_serviced filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_serviced.filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_serviced filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_serviced.filename);
} else { } else {
debug(D_CGROUP, "blkio.throttle.io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.throttle.io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
} }
} }
@ -2312,16 +2314,16 @@ static inline void discovery_update_filenames() {
if (unlikely(stat(filename, &buf) != -1)) { if (unlikely(stat(filename, &buf) != -1)) {
cg->io_merged.filename = strdupz(filename); cg->io_merged.filename = strdupz(filename);
cg->io_merged.enabled = cgroup_enable_blkio_merged_ops; cg->io_merged.enabled = cgroup_enable_blkio_merged_ops;
debug(D_CGROUP, "blkio.io_merged_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_merged.filename); netdata_log_debug(D_CGROUP, "blkio.io_merged_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_merged.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_merged_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_merged_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename);
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_merged", cgroup_blkio_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_merged", cgroup_blkio_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->io_merged.filename = strdupz(filename); cg->io_merged.filename = strdupz(filename);
cg->io_merged.enabled = cgroup_enable_blkio_merged_ops; cg->io_merged.enabled = cgroup_enable_blkio_merged_ops;
debug(D_CGROUP, "blkio.io_merged filename for cgroup '%s': '%s'", cg->id, cg->io_merged.filename); netdata_log_debug(D_CGROUP, "blkio.io_merged filename for cgroup '%s': '%s'", cg->id, cg->io_merged.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_merged file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_merged file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
} }
} }
@ -2331,16 +2333,16 @@ static inline void discovery_update_filenames() {
if (unlikely(stat(filename, &buf) != -1)) { if (unlikely(stat(filename, &buf) != -1)) {
cg->io_queued.filename = strdupz(filename); cg->io_queued.filename = strdupz(filename);
cg->io_queued.enabled = cgroup_enable_blkio_queued_ops; cg->io_queued.enabled = cgroup_enable_blkio_queued_ops;
debug(D_CGROUP, "blkio.io_queued_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_queued.filename); netdata_log_debug(D_CGROUP, "blkio.io_queued_recursive filename for cgroup '%s': '%s'", cg->id, cg->io_queued.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_queued_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_queued_recursive file for cgroup '%s': '%s' does not exist.", cg->id, filename);
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_queued", cgroup_blkio_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_queued", cgroup_blkio_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->io_queued.filename = strdupz(filename); cg->io_queued.filename = strdupz(filename);
cg->io_queued.enabled = cgroup_enable_blkio_queued_ops; cg->io_queued.enabled = cgroup_enable_blkio_queued_ops;
debug(D_CGROUP, "blkio.io_queued filename for cgroup '%s': '%s'", cg->id, cg->io_queued.filename); netdata_log_debug(D_CGROUP, "blkio.io_queued filename for cgroup '%s': '%s'", cg->id, cg->io_queued.filename);
} else { } else {
debug(D_CGROUP, "blkio.io_queued file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "blkio.io_queued file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
} }
} }
@ -2351,18 +2353,18 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->io_service_bytes.filename = strdupz(filename); cg->io_service_bytes.filename = strdupz(filename);
cg->io_service_bytes.enabled = cgroup_enable_blkio_io; cg->io_service_bytes.enabled = cgroup_enable_blkio_io;
debug(D_CGROUP, "io.stat filename for unified cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename); netdata_log_debug(D_CGROUP, "io.stat filename for unified cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename);
} else } else
debug(D_CGROUP, "io.stat file for unified cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "io.stat file for unified cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if (unlikely(cgroup_enable_blkio_ops && !cg->io_serviced.filename)) { if (unlikely(cgroup_enable_blkio_ops && !cg->io_serviced.filename)) {
snprintfz(filename, FILENAME_MAX, "%s%s/io.stat", cgroup_unified_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/io.stat", cgroup_unified_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->io_serviced.filename = strdupz(filename); cg->io_serviced.filename = strdupz(filename);
cg->io_serviced.enabled = cgroup_enable_blkio_ops; cg->io_serviced.enabled = cgroup_enable_blkio_ops;
debug(D_CGROUP, "io.stat filename for unified cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename); netdata_log_debug(D_CGROUP, "io.stat filename for unified cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename);
} else } else
debug(D_CGROUP, "io.stat file for unified cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "io.stat file for unified cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if (unlikely( if (unlikely(
(cgroup_enable_cpuacct_stat || cgroup_enable_cpuacct_cpu_throttling) && (cgroup_enable_cpuacct_stat || cgroup_enable_cpuacct_cpu_throttling) &&
@ -2376,19 +2378,19 @@ static inline void discovery_update_filenames() {
cg->filename_cpu_cfs_period = NULL; cg->filename_cpu_cfs_period = NULL;
snprintfz(filename, FILENAME_MAX, "%s%s/cpu.max", cgroup_unified_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/cpu.max", cgroup_unified_base, cg->id);
cg->filename_cpu_cfs_quota = strdupz(filename); cg->filename_cpu_cfs_quota = strdupz(filename);
debug(D_CGROUP, "cpu.stat filename for unified cgroup '%s': '%s'", cg->id, cg->cpuacct_stat.filename); netdata_log_debug(D_CGROUP, "cpu.stat filename for unified cgroup '%s': '%s'", cg->id, cg->cpuacct_stat.filename);
} }
else else
debug(D_CGROUP, "cpu.stat file for unified cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "cpu.stat file for unified cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if (unlikely(cgroup_enable_cpuacct_cpu_shares && !cg->cpuacct_cpu_shares.filename)) { if (unlikely(cgroup_enable_cpuacct_cpu_shares && !cg->cpuacct_cpu_shares.filename)) {
snprintfz(filename, FILENAME_MAX, "%s%s/cpu.weight", cgroup_unified_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/cpu.weight", cgroup_unified_base, cg->id);
if (likely(stat(filename, &buf) != -1)) { if (likely(stat(filename, &buf) != -1)) {
cg->cpuacct_cpu_shares.filename = strdupz(filename); cg->cpuacct_cpu_shares.filename = strdupz(filename);
cg->cpuacct_cpu_shares.enabled = cgroup_enable_cpuacct_cpu_shares; cg->cpuacct_cpu_shares.enabled = cgroup_enable_cpuacct_cpu_shares;
debug(D_CGROUP, "cpu.weight filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_cpu_shares.filename); netdata_log_debug(D_CGROUP, "cpu.weight filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_cpu_shares.filename);
} else } else
debug(D_CGROUP, "cpu.weight file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "cpu.weight file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely((cgroup_enable_detailed_memory || cgroup_used_memory) && !cg->memory.filename_detailed && (cgroup_used_memory || cgroup_enable_systemd_services_detailed_memory || !is_cgroup_systemd_service(cg)))) { if(unlikely((cgroup_enable_detailed_memory || cgroup_used_memory) && !cg->memory.filename_detailed && (cgroup_used_memory || cgroup_enable_systemd_services_detailed_memory || !is_cgroup_systemd_service(cg)))) {
@ -2396,10 +2398,10 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->memory.filename_detailed = strdupz(filename); cg->memory.filename_detailed = strdupz(filename);
cg->memory.enabled_detailed = (cgroup_enable_detailed_memory == CONFIG_BOOLEAN_YES)?CONFIG_BOOLEAN_YES:CONFIG_BOOLEAN_AUTO; cg->memory.enabled_detailed = (cgroup_enable_detailed_memory == CONFIG_BOOLEAN_YES)?CONFIG_BOOLEAN_YES:CONFIG_BOOLEAN_AUTO;
debug(D_CGROUP, "memory.stat filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_detailed); netdata_log_debug(D_CGROUP, "memory.stat filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_detailed);
} }
else else
debug(D_CGROUP, "memory.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.stat file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_memory && !cg->memory.filename_usage_in_bytes)) { if(unlikely(cgroup_enable_memory && !cg->memory.filename_usage_in_bytes)) {
@ -2407,12 +2409,12 @@ static inline void discovery_update_filenames() {
if(likely(stat(filename, &buf) != -1)) { if(likely(stat(filename, &buf) != -1)) {
cg->memory.filename_usage_in_bytes = strdupz(filename); cg->memory.filename_usage_in_bytes = strdupz(filename);
cg->memory.enabled_usage_in_bytes = cgroup_enable_memory; cg->memory.enabled_usage_in_bytes = cgroup_enable_memory;
debug(D_CGROUP, "memory.current filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_usage_in_bytes); netdata_log_debug(D_CGROUP, "memory.current filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_usage_in_bytes);
snprintfz(filename, FILENAME_MAX, "%s%s/memory.max", cgroup_unified_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/memory.max", cgroup_unified_base, cg->id);
cg->filename_memory_limit = strdupz(filename); cg->filename_memory_limit = strdupz(filename);
} }
else else
debug(D_CGROUP, "memory.current file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.current file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if(unlikely(cgroup_enable_swap && !cg->memory.filename_msw_usage_in_bytes)) { if(unlikely(cgroup_enable_swap && !cg->memory.filename_msw_usage_in_bytes)) {
@ -2422,10 +2424,10 @@ static inline void discovery_update_filenames() {
cg->memory.enabled_msw_usage_in_bytes = cgroup_enable_swap; cg->memory.enabled_msw_usage_in_bytes = cgroup_enable_swap;
snprintfz(filename, FILENAME_MAX, "%s%s/memory.swap.max", cgroup_unified_base, cg->id); snprintfz(filename, FILENAME_MAX, "%s%s/memory.swap.max", cgroup_unified_base, cg->id);
cg->filename_memoryswap_limit = strdupz(filename); cg->filename_memoryswap_limit = strdupz(filename);
debug(D_CGROUP, "memory.swap.current filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_msw_usage_in_bytes); netdata_log_debug(D_CGROUP, "memory.swap.current filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_msw_usage_in_bytes);
} }
else else
debug(D_CGROUP, "memory.swap file for cgroup '%s': '%s' does not exist.", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.swap file for cgroup '%s': '%s' does not exist.", cg->id, filename);
} }
if (unlikely(cgroup_enable_pressure_cpu && !cg->cpu_pressure.filename)) { if (unlikely(cgroup_enable_pressure_cpu && !cg->cpu_pressure.filename)) {
@ -2434,9 +2436,9 @@ static inline void discovery_update_filenames() {
cg->cpu_pressure.filename = strdupz(filename); cg->cpu_pressure.filename = strdupz(filename);
cg->cpu_pressure.some.enabled = cgroup_enable_pressure_cpu; cg->cpu_pressure.some.enabled = cgroup_enable_pressure_cpu;
cg->cpu_pressure.full.enabled = CONFIG_BOOLEAN_NO; cg->cpu_pressure.full.enabled = CONFIG_BOOLEAN_NO;
debug(D_CGROUP, "cpu.pressure filename for cgroup '%s': '%s'", cg->id, cg->cpu_pressure.filename); netdata_log_debug(D_CGROUP, "cpu.pressure filename for cgroup '%s': '%s'", cg->id, cg->cpu_pressure.filename);
} else { } else {
debug(D_CGROUP, "cpu.pressure file for cgroup '%s': '%s' does not exist", cg->id, filename); netdata_log_debug(D_CGROUP, "cpu.pressure file for cgroup '%s': '%s' does not exist", cg->id, filename);
} }
} }
@ -2446,9 +2448,9 @@ static inline void discovery_update_filenames() {
cg->io_pressure.filename = strdupz(filename); cg->io_pressure.filename = strdupz(filename);
cg->io_pressure.some.enabled = cgroup_enable_pressure_io_some; cg->io_pressure.some.enabled = cgroup_enable_pressure_io_some;
cg->io_pressure.full.enabled = cgroup_enable_pressure_io_full; cg->io_pressure.full.enabled = cgroup_enable_pressure_io_full;
debug(D_CGROUP, "io.pressure filename for cgroup '%s': '%s'", cg->id, cg->io_pressure.filename); netdata_log_debug(D_CGROUP, "io.pressure filename for cgroup '%s': '%s'", cg->id, cg->io_pressure.filename);
} else { } else {
debug(D_CGROUP, "io.pressure file for cgroup '%s': '%s' does not exist", cg->id, filename); netdata_log_debug(D_CGROUP, "io.pressure file for cgroup '%s': '%s' does not exist", cg->id, filename);
} }
} }
@ -2458,9 +2460,9 @@ static inline void discovery_update_filenames() {
cg->memory_pressure.filename = strdupz(filename); cg->memory_pressure.filename = strdupz(filename);
cg->memory_pressure.some.enabled = cgroup_enable_pressure_memory_some; cg->memory_pressure.some.enabled = cgroup_enable_pressure_memory_some;
cg->memory_pressure.full.enabled = cgroup_enable_pressure_memory_full; cg->memory_pressure.full.enabled = cgroup_enable_pressure_memory_full;
debug(D_CGROUP, "memory.pressure filename for cgroup '%s': '%s'", cg->id, cg->memory_pressure.filename); netdata_log_debug(D_CGROUP, "memory.pressure filename for cgroup '%s': '%s'", cg->id, cg->memory_pressure.filename);
} else { } else {
debug(D_CGROUP, "memory.pressure file for cgroup '%s': '%s' does not exist", cg->id, filename); netdata_log_debug(D_CGROUP, "memory.pressure file for cgroup '%s': '%s' does not exist", cg->id, filename);
} }
} }
} }
@ -2477,7 +2479,7 @@ static inline void discovery_cleanup_all_cgroups() {
struct cgroup *t; struct cgroup *t;
for(t = discovered_cgroup_root; t ; t = t->discovered_next) { for(t = discovered_cgroup_root; t ; t = t->discovered_next) {
if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) { if(t != cg && t->available && !t->enabled && t->options & CGROUP_OPTIONS_DISABLED_DUPLICATE && t->hash_chart == cg->hash_chart && !strcmp(t->chart_id, cg->chart_id)) {
debug(D_CGROUP, "Enabling duplicate of cgroup '%s' with id '%s', because the original with id '%s' stopped.", t->chart_id, t->id, cg->id); netdata_log_debug(D_CGROUP, "Enabling duplicate of cgroup '%s' with id '%s', because the original with id '%s' stopped.", t->chart_id, t->id, cg->id);
t->enabled = 1; t->enabled = 1;
t->options &= ~CGROUP_OPTIONS_DISABLED_DUPLICATE; t->options &= ~CGROUP_OPTIONS_DISABLED_DUPLICATE;
break; break;
@ -2505,7 +2507,7 @@ static inline void discovery_cleanup_all_cgroups() {
} }
static inline void discovery_copy_discovered_cgroups_to_reader() { static inline void discovery_copy_discovered_cgroups_to_reader() {
debug(D_CGROUP, "copy discovered cgroups to the main group list"); netdata_log_debug(D_CGROUP, "copy discovered cgroups to the main group list");
struct cgroup *cg; struct cgroup *cg;
@ -2543,7 +2545,7 @@ static inline void discovery_share_cgroups_with_ebpf() {
is_cgroup_procs_exist(ptr, cg->id); is_cgroup_procs_exist(ptr, cg->id);
} }
debug(D_CGROUP, "cgroup shared: NAME=%s, ENABLED=%d", ptr->name, ptr->enabled); netdata_log_debug(D_CGROUP, "cgroup shared: NAME=%s, ENABLED=%d", ptr->name, ptr->enabled);
} }
shm_cgroup_ebpf.header->cgroup_root_count = count; shm_cgroup_ebpf.header->cgroup_root_count = count;
@ -2633,13 +2635,13 @@ static inline void discovery_process_first_time_seen_cgroup(struct cgroup *cg) {
} }
if (cgroup_enable_systemd_services && matches_systemd_services_cgroups(cg->id)) { if (cgroup_enable_systemd_services && matches_systemd_services_cgroups(cg->id)) {
debug(D_CGROUP, "cgroup '%s' (name '%s') matches 'cgroups to match as systemd services'", cg->id, cg->chart_title); netdata_log_debug(D_CGROUP, "cgroup '%s' (name '%s') matches 'cgroups to match as systemd services'", cg->id, cg->chart_title);
convert_cgroup_to_systemd_service(cg); convert_cgroup_to_systemd_service(cg);
return; return;
} }
if (matches_enabled_cgroup_renames(cg->id)) { if (matches_enabled_cgroup_renames(cg->id)) {
debug(D_CGROUP, "cgroup '%s' (name '%s') matches 'run script to rename cgroups matching', will try to rename it", cg->id, cg->chart_title); netdata_log_debug(D_CGROUP, "cgroup '%s' (name '%s') matches 'run script to rename cgroups matching', will try to rename it", cg->id, cg->chart_title);
if (is_inside_k8s && k8s_is_container(cg->id)) { if (is_inside_k8s && k8s_is_container(cg->id)) {
// it may take up to a minute for the K8s API to return data for the container // it may take up to a minute for the K8s API to return data for the container
// tested on AWS K8s cluster with 100% CPU utilization // tested on AWS K8s cluster with 100% CPU utilization
@ -2664,7 +2666,7 @@ static int discovery_is_cgroup_duplicate(struct cgroup *cg) {
static inline void discovery_process_cgroup(struct cgroup *cg) { static inline void discovery_process_cgroup(struct cgroup *cg) {
if (!cg) { if (!cg) {
debug(D_CGROUP, "discovery_process_cgroup() received NULL"); netdata_log_debug(D_CGROUP, "discovery_process_cgroup() received NULL");
return; return;
} }
if (!cg->available || cg->processed) { if (!cg->available || cg->processed) {
@ -2700,12 +2702,12 @@ static inline void discovery_process_cgroup(struct cgroup *cg) {
} }
if (!(cg->enabled = matches_enabled_cgroup_names(cg->chart_title))) { if (!(cg->enabled = matches_enabled_cgroup_names(cg->chart_title))) {
debug(D_CGROUP, "cgroup '%s' (name '%s') disabled by 'enable by default cgroups names matching'", cg->id, cg->chart_title); netdata_log_debug(D_CGROUP, "cgroup '%s' (name '%s') disabled by 'enable by default cgroups names matching'", cg->id, cg->chart_title);
return; return;
} }
if (!(cg->enabled = matches_enabled_cgroup_paths(cg->id))) { if (!(cg->enabled = matches_enabled_cgroup_paths(cg->id))) {
debug(D_CGROUP, "cgroup '%s' (name '%s') disabled by 'enable by default cgroups matching'", cg->id, cg->chart_title); netdata_log_debug(D_CGROUP, "cgroup '%s' (name '%s') disabled by 'enable by default cgroups matching'", cg->id, cg->chart_title);
return; return;
} }
@ -2730,7 +2732,7 @@ static inline void discovery_process_cgroup(struct cgroup *cg) {
} }
static inline void discovery_find_all_cgroups() { static inline void discovery_find_all_cgroups() {
debug(D_CGROUP, "searching for cgroups"); netdata_log_debug(D_CGROUP, "searching for cgroups");
worker_is_busy(WORKER_DISCOVERY_INIT); worker_is_busy(WORKER_DISCOVERY_INIT);
discovery_mark_all_cgroups_as_unavailable(); discovery_mark_all_cgroups_as_unavailable();
@ -2765,7 +2767,7 @@ static inline void discovery_find_all_cgroups() {
worker_is_busy(WORKER_DISCOVERY_SHARE); worker_is_busy(WORKER_DISCOVERY_SHARE);
discovery_share_cgroups_with_ebpf(); discovery_share_cgroups_with_ebpf();
debug(D_CGROUP, "done searching for cgroups"); netdata_log_debug(D_CGROUP, "done searching for cgroups");
} }
static void cgroup_discovery_cleanup(void *ptr) { static void cgroup_discovery_cleanup(void *ptr) {
@ -3587,7 +3589,7 @@ static inline void update_cpu_limits2(struct cgroup *cg) {
} else { } else {
cg->cpu_cfs_quota = str2ull(procfile_lineword(ff, 0, 0), NULL); cg->cpu_cfs_quota = str2ull(procfile_lineword(ff, 0, 0), NULL);
} }
debug(D_CGROUP, "CPU limits values: %llu %llu %llu", cg->cpu_cfs_period, cg->cpuset_cpus, cg->cpu_cfs_quota); netdata_log_debug(D_CGROUP, "CPU limits values: %llu %llu %llu", cg->cpu_cfs_period, cg->cpuset_cpus, cg->cpu_cfs_quota);
return; return;
cpu_limits2_err: cpu_limits2_err:
@ -3645,7 +3647,7 @@ static inline int update_memory_limits(char **filename, const RRDSETVAR_ACQUIRED
} }
void update_cgroup_charts(int update_every) { void update_cgroup_charts(int update_every) {
debug(D_CGROUP, "updating cgroups charts"); netdata_log_debug(D_CGROUP, "updating cgroups charts");
char type[RRD_ID_LENGTH_MAX + 1]; char type[RRD_ID_LENGTH_MAX + 1];
char title[CHART_TITLE_MAX + 1]; char title[CHART_TITLE_MAX + 1];
@ -4754,7 +4756,7 @@ void update_cgroup_charts(int update_every) {
, services_do_queued_ops, services_do_merged_ops , services_do_queued_ops, services_do_merged_ops
); );
debug(D_CGROUP, "done updating cgroups charts"); netdata_log_debug(D_CGROUP, "done updating cgroups charts");
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View file

@ -1541,8 +1541,7 @@ uint32_t ebpf_enable_tracepoints(ebpf_tracepoint_t *tps)
uint32_t cnt = 0; uint32_t cnt = 0;
for (int i = 0; tps[i].class != NULL; i++) { for (int i = 0; tps[i].class != NULL; i++) {
if (ebpf_enable_tracepoint(&tps[i]) == -1) { if (ebpf_enable_tracepoint(&tps[i]) == -1) {
infoerr("failed to enable tracepoint %s:%s", netdata_log_error("Failed to enable tracepoint %s:%s", tps[i].class, tps[i].event);
tps[i].class, tps[i].event);
} }
else { else {
cnt += 1; cnt += 1;

View file

@ -121,7 +121,7 @@ void *freebsd_main(void *ptr)
if (unlikely(!pm->enabled)) if (unlikely(!pm->enabled))
continue; continue;
debug(D_PROCNETDEV_LOOP, "FREEBSD calling %s.", pm->name); netdata_log_debug(D_PROCNETDEV_LOOP, "FREEBSD calling %s.", pm->name);
worker_is_busy(i); worker_is_busy(i);
pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt); pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);

View file

@ -66,7 +66,7 @@ void *macos_main(void *ptr)
if (unlikely(!pm->enabled)) if (unlikely(!pm->enabled))
continue; continue;
debug(D_PROCNETDEV_LOOP, "macos calling %s.", pm->name); netdata_log_debug(D_PROCNETDEV_LOOP, "macos calling %s.", pm->name);
worker_is_busy(i); worker_is_busy(i);
pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt); pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);

View file

@ -245,7 +245,7 @@ void *pluginsd_main(void *ptr)
if (unlikely(!service_running(SERVICE_COLLECTORS))) if (unlikely(!service_running(SERVICE_COLLECTORS)))
break; break;
debug(D_PLUGINSD, "examining file '%s'", file->d_name); netdata_log_debug(D_PLUGINSD, "examining file '%s'", file->d_name);
if (unlikely(strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0)) if (unlikely(strcmp(file->d_name, ".") == 0 || strcmp(file->d_name, "..") == 0))
continue; continue;
@ -254,7 +254,7 @@ void *pluginsd_main(void *ptr)
if (unlikely(len <= (int)PLUGINSD_FILE_SUFFIX_LEN)) if (unlikely(len <= (int)PLUGINSD_FILE_SUFFIX_LEN))
continue; continue;
if (unlikely(strcmp(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) { if (unlikely(strcmp(PLUGINSD_FILE_SUFFIX, &file->d_name[len - (int)PLUGINSD_FILE_SUFFIX_LEN]) != 0)) {
debug(D_PLUGINSD, "file '%s' does not end in '%s'", file->d_name, PLUGINSD_FILE_SUFFIX); netdata_log_debug(D_PLUGINSD, "file '%s' does not end in '%s'", file->d_name, PLUGINSD_FILE_SUFFIX);
continue; continue;
} }
@ -263,7 +263,7 @@ void *pluginsd_main(void *ptr)
int enabled = config_get_boolean(CONFIG_SECTION_PLUGINS, pluginname, automatic_run); int enabled = config_get_boolean(CONFIG_SECTION_PLUGINS, pluginname, automatic_run);
if (unlikely(!enabled)) { if (unlikely(!enabled)) {
debug(D_PLUGINSD, "plugin '%s' is not enabled", file->d_name); netdata_log_debug(D_PLUGINSD, "plugin '%s' is not enabled", file->d_name);
continue; continue;
} }
@ -274,7 +274,7 @@ void *pluginsd_main(void *ptr)
break; break;
if (likely(cd && plugin_is_running(cd))) { if (likely(cd && plugin_is_running(cd))) {
debug(D_PLUGINSD, "plugin '%s' is already running", cd->filename); netdata_log_debug(D_PLUGINSD, "plugin '%s' is already running", cd->filename);
continue; continue;
} }

View file

@ -237,7 +237,7 @@ static inline PARSER_RC pluginsd_set(char **words, size_t num_words, PARSER *par
if(!rd) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL); if(!rd) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
debug(D_PLUGINSD, "PLUGINSD: 'host:%s/chart:%s/dim:%s' SET is setting value to '%s'", netdata_log_debug(D_PLUGINSD, "PLUGINSD: 'host:%s/chart:%s/dim:%s' SET is setting value to '%s'",
rrdhost_hostname(host), rrdset_id(st), dimension, value && *value ? value : "UNSET"); rrdhost_hostname(host), rrdset_id(st), dimension, value && *value ? value : "UNSET");
if (value && *value) if (value && *value)
@ -303,7 +303,7 @@ static inline PARSER_RC pluginsd_end(char **words, size_t num_words, PARSER *par
if(!st) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL); if(!st) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) if (unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
debug(D_PLUGINSD, "requested an END on chart '%s'", rrdset_id(st)); netdata_log_debug(D_PLUGINSD, "requested an END on chart '%s'", rrdset_id(st));
pluginsd_set_chart_from_parent(parser, NULL, PLUGINSD_KEYWORD_END); pluginsd_set_chart_from_parent(parser, NULL, PLUGINSD_KEYWORD_END);
parser->user.data_collections_count++; parser->user.data_collections_count++;
@ -517,7 +517,7 @@ static inline PARSER_RC pluginsd_chart(char **words, size_t num_words, PARSER *p
if (unlikely(!units)) if (unlikely(!units))
units = "unknown"; units = "unknown";
debug( netdata_log_debug(
D_PLUGINSD, D_PLUGINSD,
"creating chart type='%s', id='%s', name='%s', family='%s', context='%s', chart='%s', priority=%d, update_every=%d", "creating chart type='%s', id='%s', name='%s', family='%s', context='%s', chart='%s', priority=%d, update_every=%d",
type, id, name ? name : "", family ? family : "", context ? context : "", rrdset_type_name(chart_type), type, id, name ? name : "", family ? family : "", context ? context : "", rrdset_type_name(chart_type),
@ -642,7 +642,7 @@ static inline PARSER_RC pluginsd_dimension(char **words, size_t num_words, PARSE
algorithm = "absolute"; algorithm = "absolute";
if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
debug( netdata_log_debug(
D_PLUGINSD, D_PLUGINSD,
"creating dimension in chart %s, id='%s', name='%s', algorithm='%s', multiplier=%ld, divisor=%ld, hidden='%s'", "creating dimension in chart %s, id='%s', name='%s', algorithm='%s', multiplier=%ld, divisor=%ld, hidden='%s'",
rrdset_id(st), id, name ? name : "", rrd_algorithm_name(rrd_algorithm_id(algorithm)), multiplier, divisor, rrdset_id(st), id, name ? name : "", rrd_algorithm_name(rrd_algorithm_id(algorithm)), multiplier, divisor,
@ -1013,7 +1013,7 @@ static inline PARSER_RC pluginsd_variable(char **words, size_t num_words, PARSER
} }
static inline PARSER_RC pluginsd_flush(char **words __maybe_unused, size_t num_words __maybe_unused, PARSER *parser) { static inline PARSER_RC pluginsd_flush(char **words __maybe_unused, size_t num_words __maybe_unused, PARSER *parser) {
debug(D_PLUGINSD, "requested a " PLUGINSD_KEYWORD_FLUSH); netdata_log_debug(D_PLUGINSD, "requested a " PLUGINSD_KEYWORD_FLUSH);
pluginsd_set_chart_from_parent(parser, NULL, PLUGINSD_KEYWORD_FLUSH); pluginsd_set_chart_from_parent(parser, NULL, PLUGINSD_KEYWORD_FLUSH);
parser->user.replay.start_time = 0; parser->user.replay.start_time = 0;
parser->user.replay.end_time = 0; parser->user.replay.end_time = 0;
@ -1078,7 +1078,7 @@ static inline PARSER_RC pluginsd_overwrite(char **words __maybe_unused, size_t n
RRDHOST *host = pluginsd_require_host_from_parent(parser, PLUGINSD_KEYWORD_OVERWRITE); RRDHOST *host = pluginsd_require_host_from_parent(parser, PLUGINSD_KEYWORD_OVERWRITE);
if(!host) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL); if(!host) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
debug(D_PLUGINSD, "requested to OVERWRITE host labels"); netdata_log_debug(D_PLUGINSD, "requested to OVERWRITE host labels");
if(unlikely(!host->rrdlabels)) if(unlikely(!host->rrdlabels))
host->rrdlabels = rrdlabels_create(); host->rrdlabels = rrdlabels_create();
@ -1119,7 +1119,7 @@ static inline PARSER_RC pluginsd_clabel_commit(char **words __maybe_unused, size
RRDSET *st = pluginsd_require_chart_from_parent(parser, PLUGINSD_KEYWORD_CLABEL_COMMIT, PLUGINSD_KEYWORD_BEGIN); RRDSET *st = pluginsd_require_chart_from_parent(parser, PLUGINSD_KEYWORD_CLABEL_COMMIT, PLUGINSD_KEYWORD_BEGIN);
if(!st) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL); if(!st) return PLUGINSD_DISABLE_PLUGIN(parser, NULL, NULL);
debug(D_PLUGINSD, "requested to commit chart labels"); netdata_log_debug(D_PLUGINSD, "requested to commit chart labels");
if(!parser->user.chart_rrdlabels_linked_temporarily) { if(!parser->user.chart_rrdlabels_linked_temporarily) {
netdata_log_error("PLUGINSD: 'host:%s' got CLABEL_COMMIT, without a CHART or BEGIN. Ignoring it.", rrdhost_hostname(host)); netdata_log_error("PLUGINSD: 'host:%s' got CLABEL_COMMIT, without a CHART or BEGIN. Ignoring it.", rrdhost_hostname(host));

View file

@ -139,7 +139,7 @@ void *proc_main(void *ptr)
if (config_get_boolean("plugin:proc", "/proc/net/dev", CONFIG_BOOLEAN_YES)) { if (config_get_boolean("plugin:proc", "/proc/net/dev", CONFIG_BOOLEAN_YES)) {
netdev_thread = mallocz(sizeof(netdata_thread_t)); netdev_thread = mallocz(sizeof(netdata_thread_t));
debug(D_SYSTEM, "Starting thread %s.", THREAD_NETDEV_NAME); netdata_log_debug(D_SYSTEM, "Starting thread %s.", THREAD_NETDEV_NAME);
netdata_thread_create( netdata_thread_create(
netdev_thread, THREAD_NETDEV_NAME, NETDATA_THREAD_OPTION_JOINABLE, netdev_main, netdev_thread); netdev_thread, THREAD_NETDEV_NAME, NETDATA_THREAD_OPTION_JOINABLE, netdev_main, netdev_thread);
} }
@ -180,7 +180,7 @@ void *proc_main(void *ptr)
if (unlikely(!pm->enabled)) if (unlikely(!pm->enabled))
continue; continue;
debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name); netdata_log_debug(D_PROCNETDEV_LOOP, "PROC calling %s.", pm->name);
worker_is_busy(i); worker_is_busy(i);
pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt); pm->enabled = !pm->func(localhost->rrd_update_every, hb_dt);

View file

@ -370,7 +370,7 @@ static void dictionary_metric_insert_callback(const DICTIONARY_ITEM *item, void
STATSD_METRIC *m = (STATSD_METRIC *)value; STATSD_METRIC *m = (STATSD_METRIC *)value;
const char *name = dictionary_acquired_item_name(item); const char *name = dictionary_acquired_item_name(item);
debug(D_STATSD, "Creating new %s metric '%s'", index->name, name); netdata_log_debug(D_STATSD, "Creating new %s metric '%s'", index->name, name);
m->name = name; m->name = name;
m->hash = simple_hash(name); m->hash = simple_hash(name);
@ -401,7 +401,7 @@ static void dictionary_metric_delete_callback(const DICTIONARY_ITEM *item, void
} }
static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, const char *name) { static inline STATSD_METRIC *statsd_find_or_add_metric(STATSD_INDEX *index, const char *name) {
debug(D_STATSD, "searching for metric '%s' under '%s'", name, index->name); netdata_log_debug(D_STATSD, "searching for metric '%s' under '%s'", name, index->name);
#ifdef STATSD_MULTITHREADED #ifdef STATSD_MULTITHREADED
// avoid the write lock of dictionary_set() for existing metrics // avoid the write lock of dictionary_set() for existing metrics
@ -673,7 +673,7 @@ static inline const char *statsd_parse_field_trim(const char *start, char *end)
} }
static void statsd_process_metric(const char *name, const char *value, const char *type, const char *sampling, const char *tags) { static void statsd_process_metric(const char *name, const char *value, const char *type, const char *sampling, const char *tags) {
debug(D_STATSD, "STATSD: raw metric '%s', value '%s', type '%s', sampling '%s', tags '%s'", name?name:"(null)", value?value:"(null)", type?type:"(null)", sampling?sampling:"(null)", tags?tags:"(null)"); netdata_log_debug(D_STATSD, "STATSD: raw metric '%s', value '%s', type '%s', sampling '%s', tags '%s'", name?name:"(null)", value?value:"(null)", type?type:"(null)", sampling?sampling:"(null)", tags?tags:"(null)");
if(unlikely(!name || !*name)) return; if(unlikely(!name || !*name)) return;
if(unlikely(!type || !*type)) type = "m"; if(unlikely(!type || !*type)) type = "m";
@ -768,7 +768,7 @@ static void statsd_process_metric(const char *name, const char *value, const cha
static inline size_t statsd_process(char *buffer, size_t size, int require_newlines) { static inline size_t statsd_process(char *buffer, size_t size, int require_newlines) {
buffer[size] = '\0'; buffer[size] = '\0';
debug(D_STATSD, "RECEIVED: %zu bytes: '%s'", size, buffer); netdata_log_debug(D_STATSD, "RECEIVED: %zu bytes: '%s'", size, buffer);
const char *s = buffer; const char *s = buffer;
while(*s) { while(*s) {
@ -949,7 +949,7 @@ static int statsd_rcv_callback(POLLINFO *pi, short int *events) {
} }
else if (!rc) { else if (!rc) {
// connection closed // connection closed
debug(D_STATSD, "STATSD: client disconnected."); netdata_log_debug(D_STATSD, "STATSD: client disconnected.");
ret = -1; ret = -1;
} }
else { else {
@ -1231,14 +1231,14 @@ static STATSD_APP_CHART_DIM *add_dimension_to_app_chart(
} }
chart->dimensions_count++; chart->dimensions_count++;
debug(D_STATSD, "Added dimension '%s' to chart '%s' of app '%s', for metric '%s', with type %u, multiplier %d, divisor %d", netdata_log_debug(D_STATSD, "Added dimension '%s' to chart '%s' of app '%s', for metric '%s', with type %u, multiplier %d, divisor %d",
dim->name, chart->id, app->name, dim->metric, dim->value_type, dim->multiplier, dim->divisor); dim->name, chart->id, app->name, dim->metric, dim->value_type, dim->multiplier, dim->divisor);
return dim; return dim;
} }
static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHART *chart, DICTIONARY *dict) { static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHART *chart, DICTIONARY *dict) {
debug(D_STATSD, "STATSD configuration reading file '%s'", filename); netdata_log_debug(D_STATSD, "STATSD configuration reading file '%s'", filename);
char *buffer = mallocz(STATSD_CONF_LINE_MAX + 1); char *buffer = mallocz(STATSD_CONF_LINE_MAX + 1);
@ -1257,11 +1257,11 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
s = trim(buffer); s = trim(buffer);
if (!s || *s == '#') { if (!s || *s == '#') {
debug(D_STATSD, "STATSD: ignoring line %zu of file '%s', it is empty.", line, filename); netdata_log_debug(D_STATSD, "STATSD: ignoring line %zu of file '%s', it is empty.", line, filename);
continue; continue;
} }
debug(D_STATSD, "STATSD: processing line %zu of file '%s': %s", line, filename, buffer); netdata_log_debug(D_STATSD, "STATSD: processing line %zu of file '%s': %s", line, filename, buffer);
if(*s == 'i' && strncmp(s, "include", 7) == 0) { if(*s == 'i' && strncmp(s, "include", 7) == 0) {
s = trim(&s[7]); s = trim(&s[7]);
@ -1375,7 +1375,7 @@ static int statsd_readfile(const char *filename, STATSD_APP *app, STATSD_APP_CHA
continue; continue;
} }
if(!value) { if(!value) {
debug(D_CONFIG, "STATSD: ignoring line %zu of file '%s', value is empty.", line, filename); netdata_log_debug(D_CONFIG, "STATSD: ignoring line %zu of file '%s', value is empty.", line, filename);
continue; continue;
} }
@ -1625,7 +1625,7 @@ static inline RRDSET *statsd_private_rrdset_create(
} }
static inline void statsd_private_chart_gauge(STATSD_METRIC *m) { static inline void statsd_private_chart_gauge(STATSD_METRIC *m) {
debug(D_STATSD, "updating private chart for gauge metric '%s'", m->name); netdata_log_debug(D_STATSD, "updating private chart for gauge metric '%s'", m->name);
if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) { if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) {
m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA; m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA;
@ -1665,7 +1665,7 @@ static inline void statsd_private_chart_gauge(STATSD_METRIC *m) {
} }
static inline void statsd_private_chart_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) { static inline void statsd_private_chart_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) {
debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name); netdata_log_debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name);
if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) { if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) {
m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA; m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA;
@ -1705,7 +1705,7 @@ static inline void statsd_private_chart_counter_or_meter(STATSD_METRIC *m, const
} }
static inline void statsd_private_chart_set(STATSD_METRIC *m) { static inline void statsd_private_chart_set(STATSD_METRIC *m) {
debug(D_STATSD, "updating private chart for set metric '%s'", m->name); netdata_log_debug(D_STATSD, "updating private chart for set metric '%s'", m->name);
if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) { if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) {
m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA; m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA;
@ -1745,7 +1745,7 @@ static inline void statsd_private_chart_set(STATSD_METRIC *m) {
} }
static inline void statsd_private_chart_dictionary(STATSD_METRIC *m) { static inline void statsd_private_chart_dictionary(STATSD_METRIC *m) {
debug(D_STATSD, "updating private chart for dictionary metric '%s'", m->name); netdata_log_debug(D_STATSD, "updating private chart for dictionary metric '%s'", m->name);
if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) { if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) {
m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA; m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA;
@ -1788,7 +1788,7 @@ static inline void statsd_private_chart_dictionary(STATSD_METRIC *m) {
} }
static inline void statsd_private_chart_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) { static inline void statsd_private_chart_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name); netdata_log_debug(D_STATSD, "updating private chart for %s metric '%s'", dim, m->name);
if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) { if(unlikely(!m->st || m->options & STATSD_METRIC_OPTION_UPDATED_CHART_METADATA)) {
m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA; m->options &= ~STATSD_METRIC_OPTION_UPDATED_CHART_METADATA;
@ -1843,7 +1843,7 @@ static inline void statsd_private_chart_timer_or_histogram(STATSD_METRIC *m, con
// statsd flush metrics // statsd flush metrics
static inline void statsd_flush_gauge(STATSD_METRIC *m) { static inline void statsd_flush_gauge(STATSD_METRIC *m) {
debug(D_STATSD, "flushing gauge metric '%s'", m->name); netdata_log_debug(D_STATSD, "flushing gauge metric '%s'", m->name);
int updated = 0; int updated = 0;
if(unlikely(!m->reset && m->count)) { if(unlikely(!m->reset && m->count)) {
@ -1858,7 +1858,7 @@ static inline void statsd_flush_gauge(STATSD_METRIC *m) {
} }
static inline void statsd_flush_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) { static inline void statsd_flush_counter_or_meter(STATSD_METRIC *m, const char *dim, const char *family) {
debug(D_STATSD, "flushing %s metric '%s'", dim, m->name); netdata_log_debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
int updated = 0; int updated = 0;
if(unlikely(!m->reset && m->count)) { if(unlikely(!m->reset && m->count)) {
@ -1881,7 +1881,7 @@ static inline void statsd_flush_meter(STATSD_METRIC *m) {
} }
static inline void statsd_flush_set(STATSD_METRIC *m) { static inline void statsd_flush_set(STATSD_METRIC *m) {
debug(D_STATSD, "flushing set metric '%s'", m->name); netdata_log_debug(D_STATSD, "flushing set metric '%s'", m->name);
int updated = 0; int updated = 0;
if(unlikely(!m->reset && m->count)) { if(unlikely(!m->reset && m->count)) {
@ -1899,7 +1899,7 @@ static inline void statsd_flush_set(STATSD_METRIC *m) {
} }
static inline void statsd_flush_dictionary(STATSD_METRIC *m) { static inline void statsd_flush_dictionary(STATSD_METRIC *m) {
debug(D_STATSD, "flushing dictionary metric '%s'", m->name); netdata_log_debug(D_STATSD, "flushing dictionary metric '%s'", m->name);
int updated = 0; int updated = 0;
if(unlikely(!m->reset && m->count)) { if(unlikely(!m->reset && m->count)) {
@ -1927,7 +1927,7 @@ static inline void statsd_flush_dictionary(STATSD_METRIC *m) {
} }
static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) { static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
debug(D_STATSD, "flushing %s metric '%s'", dim, m->name); netdata_log_debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
int updated = 0; int updated = 0;
if(unlikely(!m->reset && m->count && m->histogram.ext->used > 0)) { if(unlikely(!m->reset && m->count && m->histogram.ext->used > 0)) {
@ -1952,7 +1952,7 @@ static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char
netdata_mutex_unlock(&m->histogram.ext->mutex); netdata_mutex_unlock(&m->histogram.ext->mutex);
debug(D_STATSD, "STATSD %s metric %s: min " COLLECTED_NUMBER_FORMAT ", max " COLLECTED_NUMBER_FORMAT ", last " COLLECTED_NUMBER_FORMAT ", pcent " COLLECTED_NUMBER_FORMAT ", median " COLLECTED_NUMBER_FORMAT ", stddev " COLLECTED_NUMBER_FORMAT ", sum " COLLECTED_NUMBER_FORMAT, netdata_log_debug(D_STATSD, "STATSD %s metric %s: min " COLLECTED_NUMBER_FORMAT ", max " COLLECTED_NUMBER_FORMAT ", last " COLLECTED_NUMBER_FORMAT ", pcent " COLLECTED_NUMBER_FORMAT ", median " COLLECTED_NUMBER_FORMAT ", stddev " COLLECTED_NUMBER_FORMAT ", sum " COLLECTED_NUMBER_FORMAT,
dim, m->name, m->histogram.ext->last_min, m->histogram.ext->last_max, m->last, m->histogram.ext->last_percentile, m->histogram.ext->last_median, m->histogram.ext->last_stddev, m->histogram.ext->last_sum); dim, m->name, m->histogram.ext->last_min, m->histogram.ext->last_max, m->last, m->histogram.ext->last_percentile, m->histogram.ext->last_median, m->histogram.ext->last_stddev, m->histogram.ext->last_sum);
m->histogram.ext->zeroed = 0; m->histogram.ext->zeroed = 0;
@ -2066,7 +2066,7 @@ static inline void link_metric_to_app_dimension(STATSD_APP *app, STATSD_METRIC *
chart->dimensions_linked_count++; chart->dimensions_linked_count++;
m->options |= STATSD_METRIC_OPTION_USED_IN_APPS; m->options |= STATSD_METRIC_OPTION_USED_IN_APPS;
debug(D_STATSD, "metric '%s' of type %u linked with app '%s', chart '%s', dimension '%s', algorithm '%s'", m->name, m->type, app->name, chart->id, dim->name, rrd_algorithm_name(dim->algorithm)); netdata_log_debug(D_STATSD, "metric '%s' of type %u linked with app '%s', chart '%s', dimension '%s', algorithm '%s'", m->name, m->type, app->name, chart->id, dim->name, rrd_algorithm_name(dim->algorithm));
} }
static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC *m) { static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC *m) {
@ -2075,7 +2075,7 @@ static inline void check_if_metric_is_for_app(STATSD_INDEX *index, STATSD_METRIC
STATSD_APP *app; STATSD_APP *app;
for(app = statsd.apps; app ;app = app->next) { for(app = statsd.apps; app ;app = app->next) {
if(unlikely(simple_pattern_matches(app->metrics, m->name))) { if(unlikely(simple_pattern_matches(app->metrics, m->name))) {
debug(D_STATSD, "metric '%s' matches app '%s'", m->name, app->name); netdata_log_debug(D_STATSD, "metric '%s' matches app '%s'", m->name, app->name);
// the metric should get the options from the app // the metric should get the options from the app
@ -2200,7 +2200,7 @@ static inline RRDDIM *statsd_add_dim_to_app_chart(STATSD_APP *app, STATSD_APP_CH
} }
static inline void statsd_update_app_chart(STATSD_APP *app, STATSD_APP_CHART *chart) { static inline void statsd_update_app_chart(STATSD_APP *app, STATSD_APP_CHART *chart) {
debug(D_STATSD, "updating chart '%s' for app '%s'", chart->id, app->name); netdata_log_debug(D_STATSD, "updating chart '%s' for app '%s'", chart->id, app->name);
if(!chart->st) { if(!chart->st) {
chart->st = rrdset_create_custom( chart->st = rrdset_create_custom(
@ -2232,22 +2232,22 @@ static inline void statsd_update_app_chart(STATSD_APP *app, STATSD_APP_CHART *ch
statsd_add_dim_to_app_chart(app, chart, dim); statsd_add_dim_to_app_chart(app, chart, dim);
if (unlikely(dim->value_ptr)) { if (unlikely(dim->value_ptr)) {
debug(D_STATSD, "updating dimension '%s' (%s) of chart '%s' (%s) for app '%s' with value " COLLECTED_NUMBER_FORMAT, dim->name, rrddim_id(dim->rd), chart->id, rrdset_id(chart->st), app->name, *dim->value_ptr); netdata_log_debug(D_STATSD, "updating dimension '%s' (%s) of chart '%s' (%s) for app '%s' with value " COLLECTED_NUMBER_FORMAT, dim->name, rrddim_id(dim->rd), chart->id, rrdset_id(chart->st), app->name, *dim->value_ptr);
rrddim_set_by_pointer(chart->st, dim->rd, *dim->value_ptr); rrddim_set_by_pointer(chart->st, dim->rd, *dim->value_ptr);
} }
} }
} }
rrdset_done(chart->st); rrdset_done(chart->st);
debug(D_STATSD, "completed update of chart '%s' for app '%s'", chart->id, app->name); netdata_log_debug(D_STATSD, "completed update of chart '%s' for app '%s'", chart->id, app->name);
} }
static inline void statsd_update_all_app_charts(void) { static inline void statsd_update_all_app_charts(void) {
// debug(D_STATSD, "updating app charts"); // netdata_log_debug(D_STATSD, "updating app charts");
STATSD_APP *app; STATSD_APP *app;
for(app = statsd.apps; app ;app = app->next) { for(app = statsd.apps; app ;app = app->next) {
// debug(D_STATSD, "updating charts for app '%s'", app->name); // netdata_log_debug(D_STATSD, "updating charts for app '%s'", app->name);
STATSD_APP_CHART *chart; STATSD_APP_CHART *chart;
for(chart = app->charts; chart ;chart = chart->next) { for(chart = app->charts; chart ;chart = chart->next) {
@ -2257,7 +2257,7 @@ static inline void statsd_update_all_app_charts(void) {
} }
} }
// debug(D_STATSD, "completed update of app charts"); // netdata_log_debug(D_STATSD, "completed update of app charts");
} }
const char *statsd_metric_type_string(STATSD_METRIC_TYPE type) { const char *statsd_metric_type_string(STATSD_METRIC_TYPE type) {
@ -2290,7 +2290,7 @@ static inline void statsd_flush_index_metrics(STATSD_INDEX *index, void (*flush_
if(unlikely(!(m->options & STATSD_METRIC_OPTION_PRIVATE_CHART_CHECKED))) { if(unlikely(!(m->options & STATSD_METRIC_OPTION_PRIVATE_CHART_CHECKED))) {
if(unlikely(statsd.private_charts >= statsd.max_private_charts_hard)) { if(unlikely(statsd.private_charts >= statsd.max_private_charts_hard)) {
debug(D_STATSD, "STATSD: metric '%s' will not be charted, because the hard limit of the maximum number " netdata_log_debug(D_STATSD, "STATSD: metric '%s' will not be charted, because the hard limit of the maximum number "
"of charts has been reached.", m->name); "of charts has been reached.", m->name);
collector_info("STATSD: metric '%s' will not be charted, because the hard limit of the maximum number " collector_info("STATSD: metric '%s' will not be charted, because the hard limit of the maximum number "
@ -2301,10 +2301,10 @@ static inline void statsd_flush_index_metrics(STATSD_INDEX *index, void (*flush_
} }
else { else {
if (simple_pattern_matches(statsd.charts_for, m->name)) { if (simple_pattern_matches(statsd.charts_for, m->name)) {
debug(D_STATSD, "STATSD: metric '%s' will be charted.", m->name); netdata_log_debug(D_STATSD, "STATSD: metric '%s' will be charted.", m->name);
m->options |= STATSD_METRIC_OPTION_PRIVATE_CHART_ENABLED; m->options |= STATSD_METRIC_OPTION_PRIVATE_CHART_ENABLED;
} else { } else {
debug(D_STATSD, "STATSD: metric '%s' will not be charted.", m->name); netdata_log_debug(D_STATSD, "STATSD: metric '%s' will not be charted.", m->name);
m->options &= ~STATSD_METRIC_OPTION_PRIVATE_CHART_ENABLED; m->options &= ~STATSD_METRIC_OPTION_PRIVATE_CHART_ENABLED;
} }
} }

View file

@ -174,7 +174,7 @@ static inline struct tc_device *tc_device_index_find(const char *id) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
static inline void tc_class_free(struct tc_device *n, struct tc_class *c) { static inline void tc_class_free(struct tc_device *n, struct tc_class *c) {
debug(D_TC_LOOP, "Removing from device '%s' class '%s', parentid '%s', leafid '%s', unused=%d", netdata_log_debug(D_TC_LOOP, "Removing from device '%s' class '%s', parentid '%s', leafid '%s', unused=%d",
string2str(n->id), string2str(c->id), string2str(c->parentid), string2str(c->leafid), string2str(n->id), string2str(c->id), string2str(c->parentid), string2str(c->leafid),
c->unupdated); c->unupdated);
@ -271,7 +271,7 @@ static inline void tc_device_commit(struct tc_device *d) {
dfe_done(c); dfe_done(c);
if(unlikely(!d->enabled || (!updated_classes && !updated_qdiscs))) { if(unlikely(!d->enabled || (!updated_classes && !updated_qdiscs))) {
debug(D_TC_LOOP, "TC: Ignoring TC device '%s'. It is not enabled/updated.", string2str(d->name?d->name:d->id)); netdata_log_debug(D_TC_LOOP, "TC: Ignoring TC device '%s'. It is not enabled/updated.", string2str(d->name?d->name:d->id));
tc_device_classes_cleanup(d); tc_device_classes_cleanup(d);
return; return;
} }
@ -308,7 +308,7 @@ static inline void tc_device_commit(struct tc_device *d) {
if(unlikely(!c->updated)) if(unlikely(!c->updated))
continue; continue;
//debug(D_TC_LOOP, "TC: In device '%s', %s '%s' has leafid: '%s' and parentid '%s'.", //netdata_log_debug(D_TC_LOOP, "TC: In device '%s', %s '%s' has leafid: '%s' and parentid '%s'.",
// d->id, // d->id,
// c->isqdisc?"qdisc":"class", // c->isqdisc?"qdisc":"class",
// c->id, // c->id,
@ -326,7 +326,7 @@ static inline void tc_device_commit(struct tc_device *d) {
if((x->parentid && c->id == x->parentid) || if((x->parentid && c->id == x->parentid) ||
(c->leafid && x->parentid && c->leafid == x->parentid)) { (c->leafid && x->parentid && c->leafid == x->parentid)) {
// debug(D_TC_LOOP, "TC: In device '%s', %s '%s' (leafid: '%s') has as leaf %s '%s' (parentid: '%s').", d->name?d->name:d->id, c->isqdisc?"qdisc":"class", c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->isqdisc?"qdisc":"class", x->name?x->name:x->id, x->parentid?x->parentid:x->id); // netdata_log_debug(D_TC_LOOP, "TC: In device '%s', %s '%s' (leafid: '%s') has as leaf %s '%s' (parentid: '%s').", d->name?d->name:d->id, c->isqdisc?"qdisc":"class", c->name?c->name:c->id, c->leafid?c->leafid:c->id, x->isqdisc?"qdisc":"class", x->name?x->name:x->id, x->parentid?x->parentid:x->id);
c->isleaf = false; c->isleaf = false;
x->hasparent = true; x->hasparent = true;
} }
@ -340,7 +340,7 @@ static inline void tc_device_commit(struct tc_device *d) {
if(unlikely(!c->updated)) if(unlikely(!c->updated))
continue; continue;
// debug(D_TC_LOOP, "TC: device '%s', %s '%s' isleaf=%d, hasparent=%d", d->id, (c->isqdisc)?"qdisc":"class", c->id, c->isleaf, c->hasparent); // netdata_log_debug(D_TC_LOOP, "TC: device '%s', %s '%s' isleaf=%d, hasparent=%d", d->id, (c->isqdisc)?"qdisc":"class", c->id, c->isleaf, c->hasparent);
if(unlikely((c->isleaf && c->hasparent) || d->enabled_all_classes_qdiscs)) { if(unlikely((c->isleaf && c->hasparent) || d->enabled_all_classes_qdiscs)) {
c->render = true; c->render = true;
@ -355,7 +355,7 @@ static inline void tc_device_commit(struct tc_device *d) {
//if(unlikely(!c->hasparent)) { //if(unlikely(!c->hasparent)) {
// if(root) collector_error("TC: multiple root class/qdisc for device '%s' (old: '%s', new: '%s')", d->id, root->id, c->id); // if(root) collector_error("TC: multiple root class/qdisc for device '%s' (old: '%s', new: '%s')", d->id, root->id, c->id);
// root = c; // root = c;
// debug(D_TC_LOOP, "TC: found root class/qdisc '%s'", root->id); // netdata_log_debug(D_TC_LOOP, "TC: found root class/qdisc '%s'", root->id);
//} //}
} }
dfe_done(c); dfe_done(c);
@ -365,8 +365,8 @@ static inline void tc_device_commit(struct tc_device *d) {
if(unlikely(debug_flags & D_TC_LOOP)) { if(unlikely(debug_flags & D_TC_LOOP)) {
dfe_start_read(d->classes, c) { dfe_start_read(d->classes, c) {
if(c->render) debug(D_TC_LOOP, "TC: final nodes dump for '%s': class %s, OK", string2str(d->name), string2str(c->id)); if(c->render) netdata_log_debug(D_TC_LOOP, "TC: final nodes dump for '%s': class %s, OK", string2str(d->name), string2str(c->id));
else debug(D_TC_LOOP, "TC: final nodes dump for '%s': class '%s', IGNORE (updated: %d, isleaf: %d, hasparent: %d, parent: '%s')", else netdata_log_debug(D_TC_LOOP, "TC: final nodes dump for '%s': class '%s', IGNORE (updated: %d, isleaf: %d, hasparent: %d, parent: '%s')",
string2str(d->name?d->name:d->id), string2str(c->id), c->updated, c->isleaf, c->hasparent, string2str(c->parentid)); string2str(d->name?d->name:d->id), string2str(c->id), c->updated, c->isleaf, c->hasparent, string2str(c->parentid));
} }
dfe_done(c); dfe_done(c);
@ -374,12 +374,12 @@ static inline void tc_device_commit(struct tc_device *d) {
#endif #endif
if(unlikely(!active_nodes)) { if(unlikely(!active_nodes)) {
debug(D_TC_LOOP, "TC: Ignoring TC device '%s'. No useful classes/qdiscs.", string2str(d->name?d->name:d->id)); netdata_log_debug(D_TC_LOOP, "TC: Ignoring TC device '%s'. No useful classes/qdiscs.", string2str(d->name?d->name:d->id));
tc_device_classes_cleanup(d); tc_device_classes_cleanup(d);
return; return;
} }
debug(D_TC_LOOP, "TC: evaluating TC device '%s'. enabled = %d/%d (bytes: %d/%d, packets: %d/%d, dropped: %d/%d, tokens: %d/%d, ctokens: %d/%d, all_classes_qdiscs: %d/%d), classes: (bytes = %llu, packets = %llu, dropped = %llu, tokens = %llu, ctokens = %llu).", netdata_log_debug(D_TC_LOOP, "TC: evaluating TC device '%s'. enabled = %d/%d (bytes: %d/%d, packets: %d/%d, dropped: %d/%d, tokens: %d/%d, ctokens: %d/%d, all_classes_qdiscs: %d/%d), classes: (bytes = %llu, packets = %llu, dropped = %llu, tokens = %llu, ctokens = %llu).",
string2str(d->name?d->name:d->id), string2str(d->name?d->name:d->id),
d->enabled, enable_new_interfaces, d->enabled, enable_new_interfaces,
d->enabled_bytes, enable_bytes, d->enabled_bytes, enable_bytes,
@ -676,7 +676,7 @@ static inline void tc_device_commit(struct tc_device *d) {
rrdlabels_add(d->st_ctokens->rrdlabels, "device_group", string2str(d->family?d->family:d->id), RRDLABEL_SRC_AUTO); rrdlabels_add(d->st_ctokens->rrdlabels, "device_group", string2str(d->family?d->family:d->id), RRDLABEL_SRC_AUTO);
} }
else { else {
debug(D_TC_LOOP, "TC: Updating _ctokens chart for device '%s'", string2str(d->name?d->name:d->id)); netdata_log_debug(D_TC_LOOP, "TC: Updating _ctokens chart for device '%s'", string2str(d->name?d->name:d->id));
if(unlikely(d->name_updated)) { if(unlikely(d->name_updated)) {
char name[RRD_ID_LENGTH_MAX + 1]; char name[RRD_ID_LENGTH_MAX + 1];
@ -724,7 +724,7 @@ static inline void tc_device_set_class_name(struct tc_device *d, char *id, char
} }
if(likely(name && *name && strcmp(string2str(c->id), name) != 0)) { if(likely(name && *name && strcmp(string2str(c->id), name) != 0)) {
debug(D_TC_LOOP, "TC: Setting device '%s', class '%s' name to '%s'", string2str(d->id), id, name); netdata_log_debug(D_TC_LOOP, "TC: Setting device '%s', class '%s' name to '%s'", string2str(d->id), id, name);
c->name = string_strdupz(name); c->name = string_strdupz(name);
c->name_updated = true; c->name_updated = true;
} }
@ -741,7 +741,7 @@ static inline void tc_device_set_device_name(struct tc_device *d, char *name) {
} }
if(likely(name && *name && strcmp(string2str(d->id), name) != 0)) { if(likely(name && *name && strcmp(string2str(d->id), name) != 0)) {
debug(D_TC_LOOP, "TC: Setting device '%s' name to '%s'", string2str(d->id), name); netdata_log_debug(D_TC_LOOP, "TC: Setting device '%s' name to '%s'", string2str(d->id), name);
d->name = string_strdupz(name); d->name = string_strdupz(name);
d->name_updated = true; d->name_updated = true;
} }
@ -752,7 +752,7 @@ static inline void tc_device_set_device_family(struct tc_device *d, char *family
d->family = NULL; d->family = NULL;
if(likely(family && *family && strcmp(string2str(d->id), family) != 0)) { if(likely(family && *family && strcmp(string2str(d->id), family) != 0)) {
debug(D_TC_LOOP, "TC: Setting device '%s' family to '%s'", string2str(d->id), family); netdata_log_debug(D_TC_LOOP, "TC: Setting device '%s' family to '%s'", string2str(d->id), family);
d->family = string_strdupz(family); d->family = string_strdupz(family);
d->family_updated = true; d->family_updated = true;
} }
@ -763,7 +763,7 @@ static inline struct tc_device *tc_device_create(char *id) {
struct tc_device *d = tc_device_index_find(id); struct tc_device *d = tc_device_index_find(id);
if(!d) { if(!d) {
debug(D_TC_LOOP, "TC: Creating device '%s'", id); netdata_log_debug(D_TC_LOOP, "TC: Creating device '%s'", id);
struct tc_device tmp = { struct tc_device tmp = {
.id = string_strdupz(id), .id = string_strdupz(id),
@ -779,7 +779,7 @@ static inline struct tc_class *tc_class_add(struct tc_device *n, char *id, bool
struct tc_class *c = tc_class_index_find(n, id); struct tc_class *c = tc_class_index_find(n, id);
if(!c) { if(!c) {
debug(D_TC_LOOP, "TC: Creating in device '%s', class id '%s', parentid '%s', leafid '%s'", netdata_log_debug(D_TC_LOOP, "TC: Creating in device '%s', class id '%s', parentid '%s', leafid '%s'",
string2str(n->id), id, parentid?parentid:"", leafid?leafid:""); string2str(n->id), id, parentid?parentid:"", leafid?leafid:"");
struct tc_class tmp = { struct tc_class tmp = {
@ -936,7 +936,7 @@ void *tc_main(void *ptr) {
struct tc_class *class = NULL; struct tc_class *class = NULL;
snprintfz(command, TC_LINE_MAX, "exec %s %d", tc_script, localhost->rrd_update_every); snprintfz(command, TC_LINE_MAX, "exec %s %d", tc_script, localhost->rrd_update_every);
debug(D_TC_LOOP, "executing '%s'", command); netdata_log_debug(D_TC_LOOP, "executing '%s'", command);
fp_child_output = netdata_popen(command, (pid_t *)&tc_child_pid, &fp_child_input); fp_child_output = netdata_popen(command, (pid_t *)&tc_child_pid, &fp_child_input);
if(unlikely(!fp_child_output)) { if(unlikely(!fp_child_output)) {
@ -949,23 +949,23 @@ void *tc_main(void *ptr) {
if(unlikely(!service_running(SERVICE_COLLECTORS))) break; if(unlikely(!service_running(SERVICE_COLLECTORS))) break;
buffer[TC_LINE_MAX] = '\0'; buffer[TC_LINE_MAX] = '\0';
// debug(D_TC_LOOP, "TC: read '%s'", buffer); // netdata_log_debug(D_TC_LOOP, "TC: read '%s'", buffer);
tc_split_words(buffer, words, PLUGINSD_MAX_WORDS); tc_split_words(buffer, words, PLUGINSD_MAX_WORDS);
if(unlikely(!words[0] || !*words[0])) { if(unlikely(!words[0] || !*words[0])) {
// debug(D_TC_LOOP, "empty line"); // netdata_log_debug(D_TC_LOOP, "empty line");
worker_is_idle(); worker_is_idle();
continue; continue;
} }
// else debug(D_TC_LOOP, "First word is '%s'", words[0]); // else netdata_log_debug(D_TC_LOOP, "First word is '%s'", words[0]);
first_hash = simple_hash(words[0]); first_hash = simple_hash(words[0]);
if(unlikely(device && ((first_hash == CLASS_HASH && strcmp(words[0], "class") == 0) || (first_hash == QDISC_HASH && strcmp(words[0], "qdisc") == 0)))) { if(unlikely(device && ((first_hash == CLASS_HASH && strcmp(words[0], "class") == 0) || (first_hash == QDISC_HASH && strcmp(words[0], "qdisc") == 0)))) {
worker_is_busy(WORKER_TC_CLASS); worker_is_busy(WORKER_TC_CLASS);
// debug(D_TC_LOOP, "CLASS line on class id='%s', parent='%s', parentid='%s', leaf='%s', leafid='%s'", words[2], words[3], words[4], words[5], words[6]); // netdata_log_debug(D_TC_LOOP, "CLASS line on class id='%s', parent='%s', parentid='%s', leaf='%s', leafid='%s'", words[2], words[3], words[4], words[5], words[6]);
char *type = words[1]; // the class/qdisc type: htb, fq_codel, etc char *type = words[1]; // the class/qdisc type: htb, fq_codel, etc
char *id = words[2]; // the class/qdisc major:minor char *id = words[2]; // the class/qdisc major:minor
@ -1033,7 +1033,7 @@ void *tc_main(void *ptr) {
else if(unlikely(first_hash == END_HASH && strcmp(words[0], "END") == 0)) { else if(unlikely(first_hash == END_HASH && strcmp(words[0], "END") == 0)) {
worker_is_busy(WORKER_TC_END); worker_is_busy(WORKER_TC_END);
// debug(D_TC_LOOP, "END line"); // netdata_log_debug(D_TC_LOOP, "END line");
if(likely(device)) { if(likely(device)) {
netdata_thread_disable_cancelability(); netdata_thread_disable_cancelability();
@ -1048,7 +1048,7 @@ void *tc_main(void *ptr) {
else if(unlikely(first_hash == BEGIN_HASH && strcmp(words[0], "BEGIN") == 0)) { else if(unlikely(first_hash == BEGIN_HASH && strcmp(words[0], "BEGIN") == 0)) {
worker_is_busy(WORKER_TC_BEGIN); worker_is_busy(WORKER_TC_BEGIN);
// debug(D_TC_LOOP, "BEGIN line on device '%s'", words[1]); // netdata_log_debug(D_TC_LOOP, "BEGIN line on device '%s'", words[1]);
if(likely(words[1] && *words[1])) { if(likely(words[1] && *words[1])) {
device = tc_device_create(words[1]); device = tc_device_create(words[1]);
@ -1063,7 +1063,7 @@ void *tc_main(void *ptr) {
else if(unlikely(device && class && first_hash == SENT_HASH && strcmp(words[0], "Sent") == 0)) { else if(unlikely(device && class && first_hash == SENT_HASH && strcmp(words[0], "Sent") == 0)) {
worker_is_busy(WORKER_TC_SENT); worker_is_busy(WORKER_TC_SENT);
// debug(D_TC_LOOP, "SENT line '%s'", words[1]); // netdata_log_debug(D_TC_LOOP, "SENT line '%s'", words[1]);
if(likely(words[1] && *words[1])) { if(likely(words[1] && *words[1])) {
class->bytes = str2ull(words[1], NULL); class->bytes = str2ull(words[1], NULL);
class->updated = true; class->updated = true;
@ -1087,7 +1087,7 @@ void *tc_main(void *ptr) {
else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strcmp(words[0], "lended:") == 0)) { else if(unlikely(device && class && class->updated && first_hash == LENDED_HASH && strcmp(words[0], "lended:") == 0)) {
worker_is_busy(WORKER_TC_LENDED); worker_is_busy(WORKER_TC_LENDED);
// debug(D_TC_LOOP, "LENDED line '%s'", words[1]); // netdata_log_debug(D_TC_LOOP, "LENDED line '%s'", words[1]);
//if(likely(words[1] && *words[1])) //if(likely(words[1] && *words[1]))
// class->lended = str2ull(words[1]); // class->lended = str2ull(words[1]);
@ -1100,7 +1100,7 @@ void *tc_main(void *ptr) {
else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strcmp(words[0], "tokens:") == 0)) { else if(unlikely(device && class && class->updated && first_hash == TOKENS_HASH && strcmp(words[0], "tokens:") == 0)) {
worker_is_busy(WORKER_TC_TOKENS); worker_is_busy(WORKER_TC_TOKENS);
// debug(D_TC_LOOP, "TOKENS line '%s'", words[1]); // netdata_log_debug(D_TC_LOOP, "TOKENS line '%s'", words[1]);
if(likely(words[1] && *words[1])) if(likely(words[1] && *words[1]))
class->tokens = str2ull(words[1], NULL); class->tokens = str2ull(words[1], NULL);
@ -1110,21 +1110,21 @@ void *tc_main(void *ptr) {
else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strcmp(words[0], "SETDEVICENAME") == 0)) { else if(unlikely(device && first_hash == SETDEVICENAME_HASH && strcmp(words[0], "SETDEVICENAME") == 0)) {
worker_is_busy(WORKER_TC_SETDEVICENAME); worker_is_busy(WORKER_TC_SETDEVICENAME);
// debug(D_TC_LOOP, "SETDEVICENAME line '%s'", words[1]); // netdata_log_debug(D_TC_LOOP, "SETDEVICENAME line '%s'", words[1]);
if(likely(words[1] && *words[1])) if(likely(words[1] && *words[1]))
tc_device_set_device_name(device, words[1]); tc_device_set_device_name(device, words[1]);
} }
else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strcmp(words[0], "SETDEVICEGROUP") == 0)) { else if(unlikely(device && first_hash == SETDEVICEGROUP_HASH && strcmp(words[0], "SETDEVICEGROUP") == 0)) {
worker_is_busy(WORKER_TC_SETDEVICEGROUP); worker_is_busy(WORKER_TC_SETDEVICEGROUP);
// debug(D_TC_LOOP, "SETDEVICEGROUP line '%s'", words[1]); // netdata_log_debug(D_TC_LOOP, "SETDEVICEGROUP line '%s'", words[1]);
if(likely(words[1] && *words[1])) if(likely(words[1] && *words[1]))
tc_device_set_device_family(device, words[1]); tc_device_set_device_family(device, words[1]);
} }
else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strcmp(words[0], "SETCLASSNAME") == 0)) { else if(unlikely(device && first_hash == SETCLASSNAME_HASH && strcmp(words[0], "SETCLASSNAME") == 0)) {
worker_is_busy(WORKER_TC_SETCLASSNAME); worker_is_busy(WORKER_TC_SETCLASSNAME);
// debug(D_TC_LOOP, "SETCLASSNAME line '%s' '%s'", words[1], words[2]); // netdata_log_debug(D_TC_LOOP, "SETCLASSNAME line '%s' '%s'", words[1], words[2]);
char *id = words[1]; char *id = words[1];
char *path = words[2]; char *path = words[2];
if(likely(id && *id && path && *path)) if(likely(id && *id && path && *path))
@ -1147,7 +1147,7 @@ void *tc_main(void *ptr) {
worker_set_metric(WORKER_TC_CLASSES, number_of_classes); worker_set_metric(WORKER_TC_CLASSES, number_of_classes);
} }
//else { //else {
// debug(D_TC_LOOP, "IGNORED line"); // netdata_log_debug(D_TC_LOOP, "IGNORED line");
//} //}
worker_is_idle(); worker_is_idle();

View file

@ -24,45 +24,45 @@ struct array_printer {
*/ */
void analytics_log_data(void) void analytics_log_data(void)
{ {
debug(D_ANALYTICS, "NETDATA_CONFIG_STREAM_ENABLED : [%s]", analytics_data.netdata_config_stream_enabled); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_STREAM_ENABLED : [%s]", analytics_data.netdata_config_stream_enabled);
debug(D_ANALYTICS, "NETDATA_CONFIG_MEMORY_MODE : [%s]", analytics_data.netdata_config_memory_mode); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_MEMORY_MODE : [%s]", analytics_data.netdata_config_memory_mode);
debug(D_ANALYTICS, "NETDATA_CONFIG_EXPORTING_ENABLED : [%s]", analytics_data.netdata_config_exporting_enabled); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_EXPORTING_ENABLED : [%s]", analytics_data.netdata_config_exporting_enabled);
debug(D_ANALYTICS, "NETDATA_EXPORTING_CONNECTORS : [%s]", analytics_data.netdata_exporting_connectors); netdata_log_debug(D_ANALYTICS, "NETDATA_EXPORTING_CONNECTORS : [%s]", analytics_data.netdata_exporting_connectors);
debug(D_ANALYTICS, "NETDATA_ALLMETRICS_PROMETHEUS_USED : [%s]", analytics_data.netdata_allmetrics_prometheus_used); netdata_log_debug(D_ANALYTICS, "NETDATA_ALLMETRICS_PROMETHEUS_USED : [%s]", analytics_data.netdata_allmetrics_prometheus_used);
debug(D_ANALYTICS, "NETDATA_ALLMETRICS_SHELL_USED : [%s]", analytics_data.netdata_allmetrics_shell_used); netdata_log_debug(D_ANALYTICS, "NETDATA_ALLMETRICS_SHELL_USED : [%s]", analytics_data.netdata_allmetrics_shell_used);
debug(D_ANALYTICS, "NETDATA_ALLMETRICS_JSON_USED : [%s]", analytics_data.netdata_allmetrics_json_used); netdata_log_debug(D_ANALYTICS, "NETDATA_ALLMETRICS_JSON_USED : [%s]", analytics_data.netdata_allmetrics_json_used);
debug(D_ANALYTICS, "NETDATA_DASHBOARD_USED : [%s]", analytics_data.netdata_dashboard_used); netdata_log_debug(D_ANALYTICS, "NETDATA_DASHBOARD_USED : [%s]", analytics_data.netdata_dashboard_used);
debug(D_ANALYTICS, "NETDATA_COLLECTORS : [%s]", analytics_data.netdata_collectors); netdata_log_debug(D_ANALYTICS, "NETDATA_COLLECTORS : [%s]", analytics_data.netdata_collectors);
debug(D_ANALYTICS, "NETDATA_COLLECTORS_COUNT : [%s]", analytics_data.netdata_collectors_count); netdata_log_debug(D_ANALYTICS, "NETDATA_COLLECTORS_COUNT : [%s]", analytics_data.netdata_collectors_count);
debug(D_ANALYTICS, "NETDATA_BUILDINFO : [%s]", analytics_data.netdata_buildinfo); netdata_log_debug(D_ANALYTICS, "NETDATA_BUILDINFO : [%s]", analytics_data.netdata_buildinfo);
debug(D_ANALYTICS, "NETDATA_CONFIG_PAGE_CACHE_SIZE : [%s]", analytics_data.netdata_config_page_cache_size); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_PAGE_CACHE_SIZE : [%s]", analytics_data.netdata_config_page_cache_size);
debug(D_ANALYTICS, "NETDATA_CONFIG_MULTIDB_DISK_QUOTA : [%s]", analytics_data.netdata_config_multidb_disk_quota); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_MULTIDB_DISK_QUOTA : [%s]", analytics_data.netdata_config_multidb_disk_quota);
debug(D_ANALYTICS, "NETDATA_CONFIG_HTTPS_ENABLED : [%s]", analytics_data.netdata_config_https_enabled); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_HTTPS_ENABLED : [%s]", analytics_data.netdata_config_https_enabled);
debug(D_ANALYTICS, "NETDATA_CONFIG_WEB_ENABLED : [%s]", analytics_data.netdata_config_web_enabled); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_WEB_ENABLED : [%s]", analytics_data.netdata_config_web_enabled);
debug(D_ANALYTICS, "NETDATA_CONFIG_RELEASE_CHANNEL : [%s]", analytics_data.netdata_config_release_channel); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_RELEASE_CHANNEL : [%s]", analytics_data.netdata_config_release_channel);
debug(D_ANALYTICS, "NETDATA_MIRRORED_HOST_COUNT : [%s]", analytics_data.netdata_mirrored_host_count); netdata_log_debug(D_ANALYTICS, "NETDATA_MIRRORED_HOST_COUNT : [%s]", analytics_data.netdata_mirrored_host_count);
debug(D_ANALYTICS, "NETDATA_MIRRORED_HOSTS_REACHABLE : [%s]", analytics_data.netdata_mirrored_hosts_reachable); netdata_log_debug(D_ANALYTICS, "NETDATA_MIRRORED_HOSTS_REACHABLE : [%s]", analytics_data.netdata_mirrored_hosts_reachable);
debug(D_ANALYTICS, "NETDATA_MIRRORED_HOSTS_UNREACHABLE : [%s]", analytics_data.netdata_mirrored_hosts_unreachable); netdata_log_debug(D_ANALYTICS, "NETDATA_MIRRORED_HOSTS_UNREACHABLE : [%s]", analytics_data.netdata_mirrored_hosts_unreachable);
debug(D_ANALYTICS, "NETDATA_NOTIFICATION_METHODS : [%s]", analytics_data.netdata_notification_methods); netdata_log_debug(D_ANALYTICS, "NETDATA_NOTIFICATION_METHODS : [%s]", analytics_data.netdata_notification_methods);
debug(D_ANALYTICS, "NETDATA_ALARMS_NORMAL : [%s]", analytics_data.netdata_alarms_normal); netdata_log_debug(D_ANALYTICS, "NETDATA_ALARMS_NORMAL : [%s]", analytics_data.netdata_alarms_normal);
debug(D_ANALYTICS, "NETDATA_ALARMS_WARNING : [%s]", analytics_data.netdata_alarms_warning); netdata_log_debug(D_ANALYTICS, "NETDATA_ALARMS_WARNING : [%s]", analytics_data.netdata_alarms_warning);
debug(D_ANALYTICS, "NETDATA_ALARMS_CRITICAL : [%s]", analytics_data.netdata_alarms_critical); netdata_log_debug(D_ANALYTICS, "NETDATA_ALARMS_CRITICAL : [%s]", analytics_data.netdata_alarms_critical);
debug(D_ANALYTICS, "NETDATA_CHARTS_COUNT : [%s]", analytics_data.netdata_charts_count); netdata_log_debug(D_ANALYTICS, "NETDATA_CHARTS_COUNT : [%s]", analytics_data.netdata_charts_count);
debug(D_ANALYTICS, "NETDATA_METRICS_COUNT : [%s]", analytics_data.netdata_metrics_count); netdata_log_debug(D_ANALYTICS, "NETDATA_METRICS_COUNT : [%s]", analytics_data.netdata_metrics_count);
debug(D_ANALYTICS, "NETDATA_CONFIG_IS_PARENT : [%s]", analytics_data.netdata_config_is_parent); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_IS_PARENT : [%s]", analytics_data.netdata_config_is_parent);
debug(D_ANALYTICS, "NETDATA_CONFIG_HOSTS_AVAILABLE : [%s]", analytics_data.netdata_config_hosts_available); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_HOSTS_AVAILABLE : [%s]", analytics_data.netdata_config_hosts_available);
debug(D_ANALYTICS, "NETDATA_HOST_CLOUD_AVAILABLE : [%s]", analytics_data.netdata_host_cloud_available); netdata_log_debug(D_ANALYTICS, "NETDATA_HOST_CLOUD_AVAILABLE : [%s]", analytics_data.netdata_host_cloud_available);
debug(D_ANALYTICS, "NETDATA_HOST_ACLK_AVAILABLE : [%s]", analytics_data.netdata_host_aclk_available); netdata_log_debug(D_ANALYTICS, "NETDATA_HOST_ACLK_AVAILABLE : [%s]", analytics_data.netdata_host_aclk_available);
debug(D_ANALYTICS, "NETDATA_HOST_ACLK_PROTOCOL : [%s]", analytics_data.netdata_host_aclk_protocol); netdata_log_debug(D_ANALYTICS, "NETDATA_HOST_ACLK_PROTOCOL : [%s]", analytics_data.netdata_host_aclk_protocol);
debug(D_ANALYTICS, "NETDATA_HOST_ACLK_IMPLEMENTATION : [%s]", analytics_data.netdata_host_aclk_implementation); netdata_log_debug(D_ANALYTICS, "NETDATA_HOST_ACLK_IMPLEMENTATION : [%s]", analytics_data.netdata_host_aclk_implementation);
debug(D_ANALYTICS, "NETDATA_HOST_AGENT_CLAIMED : [%s]", analytics_data.netdata_host_agent_claimed); netdata_log_debug(D_ANALYTICS, "NETDATA_HOST_AGENT_CLAIMED : [%s]", analytics_data.netdata_host_agent_claimed);
debug(D_ANALYTICS, "NETDATA_HOST_CLOUD_ENABLED : [%s]", analytics_data.netdata_host_cloud_enabled); netdata_log_debug(D_ANALYTICS, "NETDATA_HOST_CLOUD_ENABLED : [%s]", analytics_data.netdata_host_cloud_enabled);
debug(D_ANALYTICS, "NETDATA_CONFIG_HTTPS_AVAILABLE : [%s]", analytics_data.netdata_config_https_available); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_HTTPS_AVAILABLE : [%s]", analytics_data.netdata_config_https_available);
debug(D_ANALYTICS, "NETDATA_INSTALL_TYPE : [%s]", analytics_data.netdata_install_type); netdata_log_debug(D_ANALYTICS, "NETDATA_INSTALL_TYPE : [%s]", analytics_data.netdata_install_type);
debug(D_ANALYTICS, "NETDATA_PREBUILT_DISTRO : [%s]", analytics_data.netdata_prebuilt_distro); netdata_log_debug(D_ANALYTICS, "NETDATA_PREBUILT_DISTRO : [%s]", analytics_data.netdata_prebuilt_distro);
debug(D_ANALYTICS, "NETDATA_CONFIG_IS_PRIVATE_REGISTRY : [%s]", analytics_data.netdata_config_is_private_registry); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_IS_PRIVATE_REGISTRY : [%s]", analytics_data.netdata_config_is_private_registry);
debug(D_ANALYTICS, "NETDATA_CONFIG_USE_PRIVATE_REGISTRY: [%s]", analytics_data.netdata_config_use_private_registry); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_USE_PRIVATE_REGISTRY: [%s]", analytics_data.netdata_config_use_private_registry);
debug(D_ANALYTICS, "NETDATA_CONFIG_OOM_SCORE : [%s]", analytics_data.netdata_config_oom_score); netdata_log_debug(D_ANALYTICS, "NETDATA_CONFIG_OOM_SCORE : [%s]", analytics_data.netdata_config_oom_score);
} }
/* /*
@ -323,7 +323,7 @@ void analytics_alarms_notifications(void)
pid_t command_pid; pid_t command_pid;
debug(D_ANALYTICS, "Executing %s", script); netdata_log_debug(D_ANALYTICS, "Executing %s", script);
BUFFER *b = buffer_create(1000, NULL); BUFFER *b = buffer_create(1000, NULL);
int cnt = 0; int cnt = 0;
@ -561,7 +561,7 @@ void analytics_main_cleanup(void *ptr)
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr; struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
static_thread->enabled = NETDATA_MAIN_THREAD_EXITING; static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
debug(D_ANALYTICS, "Cleaning up..."); netdata_log_debug(D_ANALYTICS, "Cleaning up...");
analytics_free_data(); analytics_free_data();
static_thread->enabled = NETDATA_MAIN_THREAD_EXITED; static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
@ -581,7 +581,7 @@ void *analytics_main(void *ptr)
heartbeat_init(&hb); heartbeat_init(&hb);
usec_t step_ut = USEC_PER_SEC; usec_t step_ut = USEC_PER_SEC;
debug(D_ANALYTICS, "Analytics thread starts"); netdata_log_debug(D_ANALYTICS, "Analytics thread starts");
//first delay after agent start //first delay after agent start
while (service_running(SERVICE_ANALYTICS) && likely(sec <= ANALYTICS_INIT_SLEEP_SEC)) { while (service_running(SERVICE_ANALYTICS) && likely(sec <= ANALYTICS_INIT_SLEEP_SEC)) {

View file

@ -286,7 +286,8 @@ static void process_nice_level(void) {
int nice_level = (int)config_get_number(CONFIG_SECTION_GLOBAL, "process nice level", 19); int nice_level = (int)config_get_number(CONFIG_SECTION_GLOBAL, "process nice level", 19);
if(nice(nice_level) == -1) if(nice(nice_level) == -1)
netdata_log_error("Cannot set netdata CPU nice level to %d.", nice_level); netdata_log_error("Cannot set netdata CPU nice level to %d.", nice_level);
else debug(D_SYSTEM, "Set netdata nice level to %d.", nice_level); else
netdata_log_debug(D_SYSTEM, "Set netdata nice level to %d.", nice_level);
#endif // HAVE_NICE #endif // HAVE_NICE
}; };
@ -521,7 +522,8 @@ int become_daemon(int dont_fork, const char *user)
if(become_user(user, pidfd) != 0) { if(become_user(user, pidfd) != 0) {
netdata_log_error("Cannot become user '%s'. Continuing as we are.", user); netdata_log_error("Cannot become user '%s'. Continuing as we are.", user);
} }
else debug(D_SYSTEM, "Successfully became user '%s'.", user); else
netdata_log_debug(D_SYSTEM, "Successfully became user '%s'.", user);
} }
else { else {
prepare_required_directories(getuid(), getgid()); prepare_required_directories(getuid(), getgid());

View file

@ -611,7 +611,7 @@ void web_server_config_options(void)
// killpid kills pid with SIGTERM. // killpid kills pid with SIGTERM.
int killpid(pid_t pid) { int killpid(pid_t pid) {
int ret; int ret;
debug(D_EXIT, "Request to kill pid %d", pid); netdata_log_debug(D_EXIT, "Request to kill pid %d", pid);
errno = 0; errno = 0;
ret = kill(pid, SIGTERM); ret = kill(pid, SIGTERM);
@ -1060,7 +1060,7 @@ static void get_netdata_configured_variables() {
} }
netdata_configured_hostname = config_get(CONFIG_SECTION_GLOBAL, "hostname", buf); netdata_configured_hostname = config_get(CONFIG_SECTION_GLOBAL, "hostname", buf);
debug(D_OPTIONS, "hostname set to '%s'", netdata_configured_hostname); netdata_log_debug(D_OPTIONS, "hostname set to '%s'", netdata_configured_hostname);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// get default database update frequency // get default database update frequency
@ -1390,7 +1390,7 @@ int main(int argc, char **argv) {
return 1; return 1;
} }
else { else {
debug(D_OPTIONS, "Configuration loaded from %s.", optarg); netdata_log_debug(D_OPTIONS, "Configuration loaded from %s.", optarg);
load_cloud_conf(1); load_cloud_conf(1);
config_loaded = 1; config_loaded = 1;
} }
@ -1876,7 +1876,7 @@ int main(int argc, char **argv) {
setenv("NETDATA_DEBUG_FLAGS", flags, 1); setenv("NETDATA_DEBUG_FLAGS", flags, 1);
debug_flags = strtoull(flags, NULL, 0); debug_flags = strtoull(flags, NULL, 0);
debug(D_OPTIONS, "Debug flags set to '0x%" PRIX64 "'.", debug_flags); netdata_log_debug(D_OPTIONS, "Debug flags set to '0x%" PRIX64 "'.", debug_flags);
if(debug_flags != 0) { if(debug_flags != 0) {
struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY }; struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
@ -2089,10 +2089,11 @@ int main(int argc, char **argv) {
if(st->enabled) { if(st->enabled) {
st->thread = mallocz(sizeof(netdata_thread_t)); st->thread = mallocz(sizeof(netdata_thread_t));
debug(D_SYSTEM, "Starting thread %s.", st->name); netdata_log_debug(D_SYSTEM, "Starting thread %s.", st->name);
netdata_thread_create(st->thread, st->name, NETDATA_THREAD_OPTION_DEFAULT, st->start_routine, st); netdata_thread_create(st->thread, st->name, NETDATA_THREAD_OPTION_DEFAULT, st->start_routine, st);
} }
else debug(D_SYSTEM, "Not starting thread %s.", st->name); else
netdata_log_debug(D_SYSTEM, "Not starting thread %s.", st->name);
} }
ml_start_threads(); ml_start_threads();
@ -2122,7 +2123,7 @@ int main(int argc, char **argv) {
struct netdata_static_thread *st = &static_threads[i]; struct netdata_static_thread *st = &static_threads[i];
st->thread = mallocz(sizeof(netdata_thread_t)); st->thread = mallocz(sizeof(netdata_thread_t));
st->enabled = 1; st->enabled = 1;
debug(D_SYSTEM, "Starting thread %s.", st->name); netdata_log_debug(D_SYSTEM, "Starting thread %s.", st->name);
netdata_thread_create(st->thread, st->name, NETDATA_THREAD_OPTION_DEFAULT, st->start_routine, st); netdata_thread_create(st->thread, st->name, NETDATA_THREAD_OPTION_DEFAULT, st->start_routine, st);
} }
} }

View file

@ -254,7 +254,7 @@ static void service_main_cleanup(void *ptr)
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr; struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
static_thread->enabled = NETDATA_MAIN_THREAD_EXITING; static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
debug(D_SYSTEM, "Cleaning up..."); netdata_log_debug(D_SYSTEM, "Cleaning up...");
worker_unregister(); worker_unregister();
static_thread->enabled = NETDATA_MAIN_THREAD_EXITED; static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
@ -290,7 +290,7 @@ void *service_main(void *ptr)
heartbeat_init(&hb); heartbeat_init(&hb);
usec_t step = USEC_PER_SEC * SERVICE_HEARTBEAT; usec_t step = USEC_PER_SEC * SERVICE_HEARTBEAT;
debug(D_SYSTEM, "Service thread starts"); netdata_log_debug(D_SYSTEM, "Service thread starts");
while (service_running(SERVICE_MAINTENANCE)) { while (service_running(SERVICE_MAINTENANCE)) {
worker_is_idle(); worker_is_idle();

View file

@ -125,7 +125,7 @@ static void reap_child(pid_t pid) {
siginfo_t i; siginfo_t i;
errno = 0; errno = 0;
debug(D_CHILDS, "SIGNAL: reap_child(%d)...", pid); netdata_log_debug(D_CHILDS, "SIGNAL: reap_child(%d)...", pid);
if (netdata_waitid(P_PID, (id_t)pid, &i, WEXITED|WNOHANG) == -1) { if (netdata_waitid(P_PID, (id_t)pid, &i, WEXITED|WNOHANG) == -1) {
if (errno != ECHILD) if (errno != ECHILD)
netdata_log_error("SIGNAL: waitid(%d): failed to wait for child", pid); netdata_log_error("SIGNAL: waitid(%d): failed to wait for child", pid);

View file

@ -9,12 +9,12 @@ static void after_extent_write_journalfile_v1_io(uv_fs_t* req)
struct generic_io_descriptor *io_descr = &wal->io_descr; struct generic_io_descriptor *io_descr = &wal->io_descr;
struct rrdengine_instance *ctx = io_descr->ctx; struct rrdengine_instance *ctx = io_descr->ctx;
debug(D_RRDENGINE, "%s: Journal block was written to disk.", __func__); netdata_log_debug(D_RRDENGINE, "%s: Journal block was written to disk.", __func__);
if (req->result < 0) { if (req->result < 0) {
ctx_io_error(ctx); ctx_io_error(ctx);
netdata_log_error("DBENGINE: %s: uv_fs_write: %s", __func__, uv_strerror((int)req->result)); netdata_log_error("DBENGINE: %s: uv_fs_write: %s", __func__, uv_strerror((int)req->result));
} else { } else {
debug(D_RRDENGINE, "%s: Journal block was written to disk.", __func__); netdata_log_debug(D_RRDENGINE, "%s: Journal block was written to disk.", __func__);
} }
uv_fs_req_cleanup(req); uv_fs_req_cleanup(req);
@ -740,7 +740,7 @@ static unsigned journalfile_replay_transaction(struct rrdengine_instance *ctx, s
*id = 0; *id = 0;
jf_header = buf; jf_header = buf;
if (STORE_PADDING == jf_header->type) { if (STORE_PADDING == jf_header->type) {
debug(D_RRDENGINE, "Skipping padding."); netdata_log_debug(D_RRDENGINE, "Skipping padding.");
return 0; return 0;
} }
if (sizeof(*jf_header) > max_size) { if (sizeof(*jf_header) > max_size) {
@ -758,14 +758,14 @@ static unsigned journalfile_replay_transaction(struct rrdengine_instance *ctx, s
crc = crc32(0L, Z_NULL, 0); crc = crc32(0L, Z_NULL, 0);
crc = crc32(crc, buf, sizeof(*jf_header) + payload_length); crc = crc32(crc, buf, sizeof(*jf_header) + payload_length);
ret = crc32cmp(jf_trailer->checksum, crc); ret = crc32cmp(jf_trailer->checksum, crc);
debug(D_RRDENGINE, "Transaction %"PRIu64" was read from disk. CRC32 check: %s", *id, ret ? "FAILED" : "SUCCEEDED"); netdata_log_debug(D_RRDENGINE, "Transaction %"PRIu64" was read from disk. CRC32 check: %s", *id, ret ? "FAILED" : "SUCCEEDED");
if (unlikely(ret)) { if (unlikely(ret)) {
netdata_log_error("DBENGINE: transaction %"PRIu64" was read from disk. CRC32 check: FAILED", *id); netdata_log_error("DBENGINE: transaction %"PRIu64" was read from disk. CRC32 check: FAILED", *id);
return size_bytes; return size_bytes;
} }
switch (jf_header->type) { switch (jf_header->type) {
case STORE_DATA: case STORE_DATA:
debug(D_RRDENGINE, "Replaying transaction %"PRIu64"", jf_header->id); netdata_log_debug(D_RRDENGINE, "Replaying transaction %"PRIu64"", jf_header->id);
journalfile_restore_extent_metadata(ctx, journalfile, buf + sizeof(*jf_header), payload_length); journalfile_restore_extent_metadata(ctx, journalfile, buf + sizeof(*jf_header), payload_length);
break; break;
default: default:

View file

@ -1457,7 +1457,7 @@ void async_cb(uv_async_t *handle)
{ {
uv_stop(handle->loop); uv_stop(handle->loop);
uv_update_time(handle->loop); uv_update_time(handle->loop);
debug(D_RRDENGINE, "%s called, active=%d.", __func__, uv_is_active((uv_handle_t *)handle)); netdata_log_debug(D_RRDENGINE, "%s called, active=%d.", __func__, uv_is_active((uv_handle_t *)handle));
} }
#define TIMER_PERIOD_MS (1000) #define TIMER_PERIOD_MS (1000)

View file

@ -206,7 +206,7 @@ RRDCALC *rrdcalc_acquired_to_rrdcalc(const RRDCALC_ACQUIRED *rca) {
static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) { static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) {
RRDHOST *host = st->rrdhost; RRDHOST *host = st->rrdhost;
debug(D_HEALTH, "Health linking alarm '%s.%s' to chart '%s' of host '%s'", rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdset_id(st), rrdhost_hostname(host)); netdata_log_debug(D_HEALTH, "Health linking alarm '%s.%s' to chart '%s' of host '%s'", rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdset_id(st), rrdhost_hostname(host));
rc->last_status_change_value = rc->value; rc->last_status_change_value = rc->value;
rc->last_status_change = now_realtime_sec(); rc->last_status_change = now_realtime_sec();
@ -222,13 +222,13 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) {
} }
if(!isnan(rc->green) && isnan(st->green)) { if(!isnan(rc->green) && isnan(st->green)) {
debug(D_HEALTH, "Health alarm '%s.%s' green threshold set from " NETDATA_DOUBLE_FORMAT_AUTO netdata_log_debug(D_HEALTH, "Health alarm '%s.%s' green threshold set from " NETDATA_DOUBLE_FORMAT_AUTO
" to " NETDATA_DOUBLE_FORMAT_AUTO ".", rrdset_id(rc->rrdset), rrdcalc_name(rc), rc->rrdset->green, rc->green); " to " NETDATA_DOUBLE_FORMAT_AUTO ".", rrdset_id(rc->rrdset), rrdcalc_name(rc), rc->rrdset->green, rc->green);
st->green = rc->green; st->green = rc->green;
} }
if(!isnan(rc->red) && isnan(st->red)) { if(!isnan(rc->red) && isnan(st->red)) {
debug(D_HEALTH, "Health alarm '%s.%s' red threshold set from " NETDATA_DOUBLE_FORMAT_AUTO " to " NETDATA_DOUBLE_FORMAT_AUTO netdata_log_debug(D_HEALTH, "Health alarm '%s.%s' red threshold set from " NETDATA_DOUBLE_FORMAT_AUTO " to " NETDATA_DOUBLE_FORMAT_AUTO
".", rrdset_id(rc->rrdset), rrdcalc_name(rc), rc->rrdset->red, rc->red); ".", rrdset_id(rc->rrdset), rrdcalc_name(rc), rc->rrdset->red, rc->red);
st->red = rc->red; st->red = rc->red;
} }
@ -317,7 +317,7 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
RRDSET *st = rc->rrdset; RRDSET *st = rc->rrdset;
if(!st) { if(!st) {
debug(D_HEALTH, "Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc));
netdata_log_error("Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_error("Requested to unlink RRDCALC '%s.%s' which is not linked to any RRDSET", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return; return;
} }
@ -357,7 +357,7 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
health_alarm_log_add_entry(host, ae); health_alarm_log_add_entry(host, ae);
} }
debug(D_HEALTH, "Health unlinking alarm '%s.%s' from chart '%s' of host '%s'", rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdset_id(st), rrdhost_hostname(host)); netdata_log_debug(D_HEALTH, "Health unlinking alarm '%s.%s' from chart '%s' of host '%s'", rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdset_id(st), rrdhost_hostname(host));
// unlink it // unlink it
@ -412,7 +412,7 @@ static inline bool rrdcalc_check_if_it_matches_rrdset(RRDCALC *rc, RRDSET *st) {
void rrdcalc_link_matching_alerts_to_rrdset(RRDSET *st) { void rrdcalc_link_matching_alerts_to_rrdset(RRDSET *st) {
RRDHOST *host = st->rrdhost; RRDHOST *host = st->rrdhost;
// debug(D_HEALTH, "find matching alarms for chart '%s'", st->id); // netdata_log_debug(D_HEALTH, "find matching alarms for chart '%s'", st->id);
RRDCALC *rc; RRDCALC *rc;
foreach_rrdcalc_in_rrdhost_read(host, rc) { foreach_rrdcalc_in_rrdhost_read(host, rc) {
@ -557,7 +557,7 @@ static void rrdcalc_rrdhost_insert_callback(const DICTIONARY_ITEM *item __maybe_
rc->critical->rrdcalc = rc; rc->critical->rrdcalc = rc;
} }
debug(D_HEALTH, "Health added alarm '%s.%s': exec '%s', recipient '%s', green " NETDATA_DOUBLE_FORMAT_AUTO netdata_log_debug(D_HEALTH, "Health added alarm '%s.%s': exec '%s', recipient '%s', green " NETDATA_DOUBLE_FORMAT_AUTO
", red " NETDATA_DOUBLE_FORMAT_AUTO ", red " NETDATA_DOUBLE_FORMAT_AUTO
", lookup: group %d, after %d, before %d, options %u, dimensions '%s', for each dimension '%s', update every %d, calculation '%s', warning '%s', critical '%s', source '%s', delay up %d, delay down %d, delay max %d, delay_multiplier %f, warn_repeat_every %u, crit_repeat_every %u", ", lookup: group %d, after %d, before %d, options %u, dimensions '%s', for each dimension '%s', update every %d, calculation '%s', warning '%s', critical '%s', source '%s', delay up %d, delay down %d, delay max %d, delay_multiplier %f, warn_repeat_every %u, crit_repeat_every %u",
rrdcalc_chart_name(rc), rrdcalc_chart_name(rc),

View file

@ -143,7 +143,7 @@ static void rrdcalctemplate_insert_callback(const DICTIONARY_ITEM *item __maybe_
bool *added = added_bool; bool *added = added_bool;
*added = true; *added = true;
debug(D_HEALTH, "Health configuration adding template '%s'" netdata_log_debug(D_HEALTH, "Health configuration adding template '%s'"
": context '%s'" ": context '%s'"
", exec '%s'" ", exec '%s'"
", recipient '%s'" ", recipient '%s'"

View file

@ -197,7 +197,7 @@ static void rrddim_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, v
ml_dimension_delete(rd); ml_dimension_delete(rd);
debug(D_RRD_CALLS, "rrddim_free() %s.%s", rrdset_name(st), rrddim_name(rd)); netdata_log_debug(D_RRD_CALLS, "rrddim_free() %s.%s", rrdset_name(st), rrddim_name(rd));
if (!rrddim_finalize_collection_and_check_retention(rd) && rd->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) { if (!rrddim_finalize_collection_and_check_retention(rd) && rd->rrd_memory_mode == RRD_MEMORY_MODE_DBENGINE) {
/* This metric has no data and no references */ /* This metric has no data and no references */
@ -318,13 +318,13 @@ static inline RRDDIM *rrddim_index_find(RRDSET *st, const char *id) {
// RRDDIM - find a dimension // RRDDIM - find a dimension
inline RRDDIM *rrddim_find(RRDSET *st, const char *id) { inline RRDDIM *rrddim_find(RRDSET *st, const char *id) {
debug(D_RRD_CALLS, "rrddim_find() for chart %s, dimension %s", rrdset_name(st), id); netdata_log_debug(D_RRD_CALLS, "rrddim_find() for chart %s, dimension %s", rrdset_name(st), id);
return rrddim_index_find(st, id); return rrddim_index_find(st, id);
} }
inline RRDDIM_ACQUIRED *rrddim_find_and_acquire(RRDSET *st, const char *id) { inline RRDDIM_ACQUIRED *rrddim_find_and_acquire(RRDSET *st, const char *id) {
debug(D_RRD_CALLS, "rrddim_find_and_acquire() for chart %s, dimension %s", rrdset_name(st), id); netdata_log_debug(D_RRD_CALLS, "rrddim_find_and_acquire() for chart %s, dimension %s", rrdset_name(st), id);
return (RRDDIM_ACQUIRED *)dictionary_get_and_acquire_item(st->rrddim_root_index, id); return (RRDDIM_ACQUIRED *)dictionary_get_and_acquire_item(st->rrddim_root_index, id);
} }
@ -361,7 +361,7 @@ inline int rrddim_reset_name(RRDSET *st, RRDDIM *rd, const char *name) {
if(unlikely(!name || !*name || !strcmp(rrddim_name(rd), name))) if(unlikely(!name || !*name || !strcmp(rrddim_name(rd), name)))
return 0; return 0;
debug(D_RRD_CALLS, "rrddim_reset_name() from %s.%s to %s.%s", rrdset_name(st), rrddim_name(rd), rrdset_name(st), name); netdata_log_debug(D_RRD_CALLS, "rrddim_reset_name() from %s.%s to %s.%s", rrdset_name(st), rrddim_name(rd), rrdset_name(st), name);
STRING *old = rd->name; STRING *old = rd->name;
rd->name = rrd_string_strdupz(name); rd->name = rrd_string_strdupz(name);
@ -379,7 +379,7 @@ inline int rrddim_set_algorithm(RRDSET *st, RRDDIM *rd, RRD_ALGORITHM algorithm)
if(unlikely(rd->algorithm == algorithm)) if(unlikely(rd->algorithm == algorithm))
return 0; return 0;
debug(D_RRD_CALLS, "Updating algorithm of dimension '%s/%s' from %s to %s", rrdset_id(st), rrddim_name(rd), rrd_algorithm_name(rd->algorithm), rrd_algorithm_name(algorithm)); netdata_log_debug(D_RRD_CALLS, "Updating algorithm of dimension '%s/%s' from %s to %s", rrdset_id(st), rrddim_name(rd), rrd_algorithm_name(rd->algorithm), rrd_algorithm_name(algorithm));
rd->algorithm = algorithm; rd->algorithm = algorithm;
rrddim_clear_exposed(rd); rrddim_clear_exposed(rd);
rrdset_flag_clear(st, RRDSET_FLAG_UPSTREAM_EXPOSED); rrdset_flag_clear(st, RRDSET_FLAG_UPSTREAM_EXPOSED);
@ -392,7 +392,7 @@ inline int rrddim_set_multiplier(RRDSET *st, RRDDIM *rd, int32_t multiplier) {
if(unlikely(rd->multiplier == multiplier)) if(unlikely(rd->multiplier == multiplier))
return 0; return 0;
debug(D_RRD_CALLS, "Updating multiplier of dimension '%s/%s' from %d to %d", netdata_log_debug(D_RRD_CALLS, "Updating multiplier of dimension '%s/%s' from %d to %d",
rrdset_id(st), rrddim_name(rd), rd->multiplier, multiplier); rrdset_id(st), rrddim_name(rd), rd->multiplier, multiplier);
rd->multiplier = multiplier; rd->multiplier = multiplier;
rrddim_clear_exposed(rd); rrddim_clear_exposed(rd);
@ -406,7 +406,7 @@ inline int rrddim_set_divisor(RRDSET *st, RRDDIM *rd, int32_t divisor) {
if(unlikely(rd->divisor == divisor)) if(unlikely(rd->divisor == divisor))
return 0; return 0;
debug(D_RRD_CALLS, "Updating divisor of dimension '%s/%s' from %d to %d", netdata_log_debug(D_RRD_CALLS, "Updating divisor of dimension '%s/%s' from %d to %d",
rrdset_id(st), rrddim_name(rd), rd->divisor, divisor); rrdset_id(st), rrddim_name(rd), rd->divisor, divisor);
rd->divisor = divisor; rd->divisor = divisor;
rrddim_clear_exposed(rd); rrddim_clear_exposed(rd);
@ -493,7 +493,7 @@ void rrddim_free(RRDSET *st, RRDDIM *rd) {
// RRDDIM - set dimension options // RRDDIM - set dimension options
int rrddim_hide(RRDSET *st, const char *id) { int rrddim_hide(RRDSET *st, const char *id) {
debug(D_RRD_CALLS, "rrddim_hide() for chart %s, dimension %s", rrdset_name(st), id); netdata_log_debug(D_RRD_CALLS, "rrddim_hide() for chart %s, dimension %s", rrdset_name(st), id);
RRDHOST *host = st->rrdhost; RRDHOST *host = st->rrdhost;
@ -513,7 +513,7 @@ int rrddim_hide(RRDSET *st, const char *id) {
} }
int rrddim_unhide(RRDSET *st, const char *id) { int rrddim_unhide(RRDSET *st, const char *id) {
debug(D_RRD_CALLS, "rrddim_unhide() for chart %s, dimension %s", rrdset_name(st), id); netdata_log_debug(D_RRD_CALLS, "rrddim_unhide() for chart %s, dimension %s", rrdset_name(st), id);
RRDHOST *host = st->rrdhost; RRDHOST *host = st->rrdhost;
RRDDIM *rd = rrddim_find(st, id); RRDDIM *rd = rrddim_find(st, id);
@ -533,7 +533,7 @@ int rrddim_unhide(RRDSET *st, const char *id) {
} }
inline void rrddim_is_obsolete(RRDSET *st, RRDDIM *rd) { inline void rrddim_is_obsolete(RRDSET *st, RRDDIM *rd) {
debug(D_RRD_CALLS, "rrddim_is_obsolete() for chart %s, dimension %s", rrdset_name(st), rrddim_name(rd)); netdata_log_debug(D_RRD_CALLS, "rrddim_is_obsolete() for chart %s, dimension %s", rrdset_name(st), rrddim_name(rd));
if(unlikely(rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED))) { if(unlikely(rrddim_flag_check(rd, RRDDIM_FLAG_ARCHIVED))) {
netdata_log_info("Cannot obsolete already archived dimension %s from chart %s", rrddim_name(rd), rrdset_name(st)); netdata_log_info("Cannot obsolete already archived dimension %s from chart %s", rrddim_name(rd), rrdset_name(st));
@ -546,7 +546,7 @@ inline void rrddim_is_obsolete(RRDSET *st, RRDDIM *rd) {
} }
inline void rrddim_isnot_obsolete(RRDSET *st __maybe_unused, RRDDIM *rd) { inline void rrddim_isnot_obsolete(RRDSET *st __maybe_unused, RRDDIM *rd) {
debug(D_RRD_CALLS, "rrddim_isnot_obsolete() for chart %s, dimension %s", rrdset_name(st), rrddim_name(rd)); netdata_log_debug(D_RRD_CALLS, "rrddim_isnot_obsolete() for chart %s, dimension %s", rrdset_name(st), rrddim_name(rd));
rrddim_flag_clear(rd, RRDDIM_FLAG_OBSOLETE); rrddim_flag_clear(rd, RRDDIM_FLAG_OBSOLETE);
rrdcontext_updated_rrddim_flags(rd); rrdcontext_updated_rrddim_flags(rd);
@ -563,7 +563,7 @@ inline collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_
} }
collected_number rrddim_timed_set_by_pointer(RRDSET *st __maybe_unused, RRDDIM *rd, struct timeval collected_time, collected_number value) { collected_number rrddim_timed_set_by_pointer(RRDSET *st __maybe_unused, RRDDIM *rd, struct timeval collected_time, collected_number value) {
debug(D_RRD_CALLS, "rrddim_set_by_pointer() for chart %s, dimension %s, value " COLLECTED_NUMBER_FORMAT, rrdset_name(st), rrddim_name(rd), value); netdata_log_debug(D_RRD_CALLS, "rrddim_set_by_pointer() for chart %s, dimension %s, value " COLLECTED_NUMBER_FORMAT, rrdset_name(st), rrddim_name(rd), value);
rd->collector.last_collected_time = collected_time; rd->collector.last_collected_time = collected_time;
rd->collector.collected_value = value; rd->collector.collected_value = value;

View file

@ -249,7 +249,7 @@ void rrddimvar_add_and_leave_released(RRDDIM *rd, RRDVAR_TYPE type, const char *
void rrddimvar_rename_all(RRDDIM *rd) { void rrddimvar_rename_all(RRDDIM *rd) {
RRDSET *st = rd->rrdset; RRDSET *st = rd->rrdset;
debug(D_VARIABLES, "RRDDIMVAR rename for chart id '%s' name '%s', dimension id '%s', name '%s'", rrdset_id(st), rrdset_name(st), rrddim_id(rd), rrddim_name(rd)); netdata_log_debug(D_VARIABLES, "RRDDIMVAR rename for chart id '%s' name '%s', dimension id '%s', name '%s'", rrdset_id(st), rrdset_name(st), rrddim_id(rd), rrddim_name(rd));
RRDDIMVAR *rs; RRDDIMVAR *rs;
dfe_start_write(st->rrddimvar_root_index, rs) { dfe_start_write(st->rrddimvar_root_index, rs) {
@ -262,7 +262,7 @@ void rrddimvar_rename_all(RRDDIM *rd) {
void rrddimvar_delete_all(RRDDIM *rd) { void rrddimvar_delete_all(RRDDIM *rd) {
RRDSET *st = rd->rrdset; RRDSET *st = rd->rrdset;
debug(D_VARIABLES, "RRDDIMVAR delete for chart id '%s' name '%s', dimension id '%s', name '%s'", rrdset_id(st), rrdset_name(st), rrddim_id(rd), rrddim_name(rd)); netdata_log_debug(D_VARIABLES, "RRDDIMVAR delete for chart id '%s' name '%s', dimension id '%s', name '%s'", rrdset_id(st), rrdset_name(st), rrddim_id(rd), rrddim_name(rd));
RRDDIMVAR *rs; RRDDIMVAR *rs;
dfe_start_write(st->rrddimvar_root_index, rs) { dfe_start_write(st->rrddimvar_root_index, rs) {

View file

@ -80,7 +80,7 @@ static inline void rrdhost_init() {
} }
RRDHOST_ACQUIRED *rrdhost_find_and_acquire(const char *machine_guid) { RRDHOST_ACQUIRED *rrdhost_find_and_acquire(const char *machine_guid) {
debug(D_RRD_CALLS, "rrdhost_find_and_acquire() host %s", machine_guid); netdata_log_debug(D_RRD_CALLS, "rrdhost_find_and_acquire() host %s", machine_guid);
return (RRDHOST_ACQUIRED *)dictionary_get_and_acquire_item(rrdhost_root_index, machine_guid); return (RRDHOST_ACQUIRED *)dictionary_get_and_acquire_item(rrdhost_root_index, machine_guid);
} }
@ -303,7 +303,7 @@ static RRDHOST *rrdhost_create(
int is_localhost, int is_localhost,
bool archived bool archived
) { ) {
debug(D_RRDHOST, "Host '%s': adding with guid '%s'", hostname, guid); netdata_log_debug(D_RRDHOST, "Host '%s': adding with guid '%s'", hostname, guid);
if(memory_mode == RRD_MEMORY_MODE_DBENGINE && !dbengine_enabled) { if(memory_mode == RRD_MEMORY_MODE_DBENGINE && !dbengine_enabled) {
netdata_log_error("memory mode 'dbengine' is not enabled, but host '%s' is configured for it. Falling back to 'alloc'", netdata_log_error("memory mode 'dbengine' is not enabled, but host '%s' is configured for it. Falling back to 'alloc'",
@ -724,7 +724,7 @@ RRDHOST *rrdhost_find_or_create(
, struct rrdhost_system_info *system_info , struct rrdhost_system_info *system_info
, bool archived , bool archived
) { ) {
debug(D_RRDHOST, "Searching for host '%s' with guid '%s'", hostname, guid); netdata_log_debug(D_RRDHOST, "Searching for host '%s' with guid '%s'", hostname, guid);
RRDHOST *host = rrdhost_find_by_guid(guid); RRDHOST *host = rrdhost_find_by_guid(guid);
if (unlikely(host && host->rrd_memory_mode != mode && rrdhost_flag_check(host, RRDHOST_FLAG_ARCHIVED))) { if (unlikely(host && host->rrd_memory_mode != mode && rrdhost_flag_check(host, RRDHOST_FLAG_ARCHIVED))) {
@ -1033,7 +1033,7 @@ int rrd_init(char *hostname, struct rrdhost_system_info *system_info, bool unitt
if(!unittest) if(!unittest)
metadata_sync_init(); metadata_sync_init();
debug(D_RRDHOST, "Initializing localhost with hostname '%s'", hostname); netdata_log_debug(D_RRDHOST, "Initializing localhost with hostname '%s'", hostname);
localhost = rrdhost_create( localhost = rrdhost_create(
hostname hostname
, registry_get_this_machine_hostname() , registry_get_this_machine_hostname()
@ -1455,7 +1455,7 @@ static void rrdhost_load_kubernetes_labels(void) {
return; return;
} }
debug(D_RRDHOST, "Attempting to fetch external labels via %s", label_script); netdata_log_debug(D_RRDHOST, "Attempting to fetch external labels via %s", label_script);
pid_t pid; pid_t pid;
FILE *fp_child_input; FILE *fp_child_input;

View file

@ -55,7 +55,7 @@ static STRING *rrdset_fix_name(RRDHOST *host, const char *chart_full_id, const c
strncpyz(new_name, sanitized_name, CONFIG_MAX_VALUE); strncpyz(new_name, sanitized_name, CONFIG_MAX_VALUE);
if(rrdset_index_find_name(host, new_name)) { if(rrdset_index_find_name(host, new_name)) {
debug(D_RRD_CALLS, "RRDSET: chart name '%s' on host '%s' already exists.", new_name, rrdhost_hostname(host)); netdata_log_debug(D_RRD_CALLS, "RRDSET: chart name '%s' on host '%s' already exists.", new_name, rrdhost_hostname(host));
if(!strcmp(chart_full_id, full_name) && (!current_name || !*current_name)) { if(!strcmp(chart_full_id, full_name) && (!current_name || !*current_name)) {
unsigned i = 1; unsigned i = 1;
@ -450,7 +450,7 @@ static RRDSET *rrdset_index_find(RRDHOST *host, const char *id) {
// RRDSET - find charts // RRDSET - find charts
inline RRDSET *rrdset_find(RRDHOST *host, const char *id) { inline RRDSET *rrdset_find(RRDHOST *host, const char *id) {
debug(D_RRD_CALLS, "rrdset_find() for chart '%s' in host '%s'", id, rrdhost_hostname(host)); netdata_log_debug(D_RRD_CALLS, "rrdset_find() for chart '%s' in host '%s'", id, rrdhost_hostname(host));
RRDSET *st = rrdset_index_find(host, id); RRDSET *st = rrdset_index_find(host, id);
if(st) if(st)
@ -460,7 +460,7 @@ inline RRDSET *rrdset_find(RRDHOST *host, const char *id) {
} }
inline RRDSET *rrdset_find_bytype(RRDHOST *host, const char *type, const char *id) { inline RRDSET *rrdset_find_bytype(RRDHOST *host, const char *type, const char *id) {
debug(D_RRD_CALLS, "rrdset_find_bytype() for chart '%s.%s' in host '%s'", type, id, rrdhost_hostname(host)); netdata_log_debug(D_RRD_CALLS, "rrdset_find_bytype() for chart '%s.%s' in host '%s'", type, id, rrdhost_hostname(host));
char buf[RRD_ID_LENGTH_MAX + 1]; char buf[RRD_ID_LENGTH_MAX + 1];
strncpyz(buf, type, RRD_ID_LENGTH_MAX - 1); strncpyz(buf, type, RRD_ID_LENGTH_MAX - 1);
@ -472,13 +472,13 @@ inline RRDSET *rrdset_find_bytype(RRDHOST *host, const char *type, const char *i
} }
inline RRDSET *rrdset_find_byname(RRDHOST *host, const char *name) { inline RRDSET *rrdset_find_byname(RRDHOST *host, const char *name) {
debug(D_RRD_CALLS, "rrdset_find_byname() for chart '%s' in host '%s'", name, rrdhost_hostname(host)); netdata_log_debug(D_RRD_CALLS, "rrdset_find_byname() for chart '%s' in host '%s'", name, rrdhost_hostname(host));
RRDSET *st = rrdset_index_find_name(host, name); RRDSET *st = rrdset_index_find_name(host, name);
return(st); return(st);
} }
RRDSET_ACQUIRED *rrdset_find_and_acquire(RRDHOST *host, const char *id) { RRDSET_ACQUIRED *rrdset_find_and_acquire(RRDHOST *host, const char *id) {
debug(D_RRD_CALLS, "rrdset_find_and_acquire() for host %s, chart %s", rrdhost_hostname(host), id); netdata_log_debug(D_RRD_CALLS, "rrdset_find_and_acquire() for host %s, chart %s", rrdhost_hostname(host), id);
return (RRDSET_ACQUIRED *)dictionary_get_and_acquire_item(host->rrdset_root_index, id); return (RRDSET_ACQUIRED *)dictionary_get_and_acquire_item(host->rrdset_root_index, id);
} }
@ -522,7 +522,7 @@ int rrdset_reset_name(RRDSET *st, const char *name) {
RRDHOST *host = st->rrdhost; RRDHOST *host = st->rrdhost;
debug(D_RRD_CALLS, "rrdset_reset_name() old: '%s', new: '%s'", rrdset_name(st), name); netdata_log_debug(D_RRD_CALLS, "rrdset_reset_name() old: '%s', new: '%s'", rrdset_name(st), name);
STRING *name_string = rrdset_fix_name(host, rrdset_id(st), rrdset_parts_type(st), string2str(st->name), name); STRING *name_string = rrdset_fix_name(host, rrdset_id(st), rrdset_parts_type(st), string2str(st->name), name);
if(!name_string) return 0; if(!name_string) return 0;
@ -745,7 +745,7 @@ inline void rrdset_update_heterogeneous_flag(RRDSET *st) {
// RRDSET - reset a chart // RRDSET - reset a chart
void rrdset_reset(RRDSET *st) { void rrdset_reset(RRDSET *st) {
debug(D_RRD_CALLS, "rrdset_reset() %s", rrdset_name(st)); netdata_log_debug(D_RRD_CALLS, "rrdset_reset() %s", rrdset_name(st));
st->last_collected_time.tv_sec = 0; st->last_collected_time.tv_sec = 0;
st->last_collected_time.tv_usec = 0; st->last_collected_time.tv_usec = 0;
@ -933,7 +933,7 @@ RRDSET *rrdset_create_custom(
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// allocate it // allocate it
debug(D_RRD_CALLS, "Creating RRD_STATS for '%s.%s'.", type, id); netdata_log_debug(D_RRD_CALLS, "Creating RRD_STATS for '%s.%s'.", type, id);
struct rrdset_constructor tmp = { struct rrdset_constructor tmp = {
.host = host, .host = host,
@ -1056,7 +1056,7 @@ void rrdset_timed_next(RRDSET *st, struct timeval now, usec_t duration_since_las
#endif #endif
} }
debug(D_RRD_CALLS, "rrdset_timed_next() for chart %s with duration since last update %llu usec", rrdset_name(st), duration_since_last_update); netdata_log_debug(D_RRD_CALLS, "rrdset_timed_next() for chart %s with duration since last update %llu usec", rrdset_name(st), duration_since_last_update);
rrdset_debug(st, "NEXT: %llu microseconds", duration_since_last_update); rrdset_debug(st, "NEXT: %llu microseconds", duration_since_last_update);
internal_error(discarded && discarded != duration_since_last_update, internal_error(discarded && discarded != duration_since_last_update,
@ -1514,7 +1514,7 @@ void rrdset_timed_done(RRDSET *st, struct timeval now, bool pending_rrdset_next)
if (pending_rrdset_next) if (pending_rrdset_next)
rrdset_timed_next(st, now, 0ULL); rrdset_timed_next(st, now, 0ULL);
debug(D_RRD_CALLS, "rrdset_done() for chart '%s'", rrdset_name(st)); netdata_log_debug(D_RRD_CALLS, "rrdset_done() for chart '%s'", rrdset_name(st));
RRDDIM *rd; RRDDIM *rd;
@ -1666,7 +1666,7 @@ void rrdset_timed_done(RRDSET *st, struct timeval now, bool pending_rrdset_next)
// if the new is smaller than the old (an overflow, or reset), set the old equal to the new // if the new is smaller than the old (an overflow, or reset), set the old equal to the new
// to reset the calculation (it will give zero as the calculation for this second) // to reset the calculation (it will give zero as the calculation for this second)
if(unlikely(rd->algorithm == RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL && rd->collector.last_collected_value > rd->collector.collected_value)) { if(unlikely(rd->algorithm == RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL && rd->collector.last_collected_value > rd->collector.collected_value)) {
debug(D_RRD_STATS, "'%s' / '%s': RESET or OVERFLOW. Last collected value = " COLLECTED_NUMBER_FORMAT ", current = " COLLECTED_NUMBER_FORMAT netdata_log_debug(D_RRD_STATS, "'%s' / '%s': RESET or OVERFLOW. Last collected value = " COLLECTED_NUMBER_FORMAT ", current = " COLLECTED_NUMBER_FORMAT
, rrdset_id(st) , rrdset_id(st)
, rrddim_name(rd) , rrddim_name(rd)
, rd->collector.last_collected_value , rd->collector.last_collected_value
@ -1770,7 +1770,7 @@ void rrdset_timed_done(RRDSET *st, struct timeval now, bool pending_rrdset_next)
// It is imperative to set the comparison to uint64_t since type collected_number is signed and // It is imperative to set the comparison to uint64_t since type collected_number is signed and
// produces wrong results as far as incremental counters are concerned. // produces wrong results as far as incremental counters are concerned.
if(unlikely((uint64_t)rd->collector.last_collected_value > (uint64_t)rd->collector.collected_value)) { if(unlikely((uint64_t)rd->collector.last_collected_value > (uint64_t)rd->collector.collected_value)) {
debug(D_RRD_STATS, "'%s' / '%s': RESET or OVERFLOW. Last collected value = " COLLECTED_NUMBER_FORMAT ", current = " COLLECTED_NUMBER_FORMAT netdata_log_debug(D_RRD_STATS, "'%s' / '%s': RESET or OVERFLOW. Last collected value = " COLLECTED_NUMBER_FORMAT ", current = " COLLECTED_NUMBER_FORMAT
, rrdset_id(st) , rrdset_id(st)
, rrddim_name(rd) , rrddim_name(rd)
, rd->collector.last_collected_value , rd->collector.last_collected_value

View file

@ -222,7 +222,7 @@ void rrdsetvar_add_and_leave_released(RRDSET *st, const char *name, RRDVAR_TYPE
} }
void rrdsetvar_rename_all(RRDSET *st) { void rrdsetvar_rename_all(RRDSET *st) {
debug(D_VARIABLES, "RRDSETVAR rename for chart id '%s' name '%s'", rrdset_id(st), rrdset_name(st)); netdata_log_debug(D_VARIABLES, "RRDSETVAR rename for chart id '%s' name '%s'", rrdset_id(st), rrdset_name(st));
RRDSETVAR *rs; RRDSETVAR *rs;
dfe_start_write(st->rrdsetvar_root_index, rs) { dfe_start_write(st->rrdsetvar_root_index, rs) {

View file

@ -67,7 +67,7 @@ static void aclk_database_enq_cmd(struct aclk_database_cmd *cmd)
/* wake up event loop */ /* wake up event loop */
int rc = uv_async_send(&aclk_sync_config.async); int rc = uv_async_send(&aclk_sync_config.async);
if (unlikely(rc)) if (unlikely(rc))
debug(D_ACLK_SYNC, "Failed to wake up event loop"); netdata_log_debug(D_ACLK_SYNC, "Failed to wake up event loop");
} }
enum { enum {
@ -226,14 +226,14 @@ static void sql_delete_aclk_table_list(char *host_guid)
uuid_unparse_lower(host_uuid, host_str); uuid_unparse_lower(host_uuid, host_str);
uuid_unparse_lower_fix(&host_uuid, uuid_str); uuid_unparse_lower_fix(&host_uuid, uuid_str);
debug(D_ACLK_SYNC, "Checking if I should delete aclk tables for node %s", host_str); netdata_log_debug(D_ACLK_SYNC, "Checking if I should delete aclk tables for node %s", host_str);
if (is_host_available(&host_uuid)) { if (is_host_available(&host_uuid)) {
debug(D_ACLK_SYNC, "Host %s exists, not deleting aclk sync tables", host_str); netdata_log_debug(D_ACLK_SYNC, "Host %s exists, not deleting aclk sync tables", host_str);
return; return;
} }
debug(D_ACLK_SYNC, "Host %s does NOT exist, can delete aclk sync tables", host_str); netdata_log_debug(D_ACLK_SYNC, "Host %s does NOT exist, can delete aclk sync tables", host_str);
sqlite3_stmt *res = NULL; sqlite3_stmt *res = NULL;
BUFFER *sql = buffer_create(ACLK_SYNC_QUERY_SIZE, &netdata_buffers_statistics.buffers_sqlite); BUFFER *sql = buffer_create(ACLK_SYNC_QUERY_SIZE, &netdata_buffers_statistics.buffers_sqlite);
@ -265,7 +265,7 @@ fail:
static int sql_check_aclk_table(void *data __maybe_unused, int argc __maybe_unused, char **argv __maybe_unused, char **column __maybe_unused) static int sql_check_aclk_table(void *data __maybe_unused, int argc __maybe_unused, char **argv __maybe_unused, char **column __maybe_unused)
{ {
debug(D_ACLK_SYNC,"Scheduling aclk sync table check for node %s", (char *) argv[0]); netdata_log_debug(D_ACLK_SYNC,"Scheduling aclk sync table check for node %s", (char *) argv[0]);
struct aclk_database_cmd cmd; struct aclk_database_cmd cmd;
memset(&cmd, 0, sizeof(cmd)); memset(&cmd, 0, sizeof(cmd));
cmd.opcode = ACLK_DATABASE_DELETE_HOST; cmd.opcode = ACLK_DATABASE_DELETE_HOST;
@ -280,7 +280,7 @@ static int sql_check_aclk_table(void *data __maybe_unused, int argc __maybe_unus
static void sql_check_aclk_table_list(void) static void sql_check_aclk_table_list(void)
{ {
char *err_msg = NULL; char *err_msg = NULL;
debug(D_ACLK_SYNC,"Cleaning tables for nodes that do not exist"); netdata_log_debug(D_ACLK_SYNC,"Cleaning tables for nodes that do not exist");
int rc = sqlite3_exec_monitored(db_meta, SQL_SELECT_ACLK_ACTIVE_LIST, sql_check_aclk_table, NULL, &err_msg); int rc = sqlite3_exec_monitored(db_meta, SQL_SELECT_ACLK_ACTIVE_LIST, sql_check_aclk_table, NULL, &err_msg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
error_report("Query failed when trying to check for obsolete ACLK sync tables, %s", err_msg); error_report("Query failed when trying to check for obsolete ACLK sync tables, %s", err_msg);
@ -305,7 +305,7 @@ static int sql_maint_aclk_sync_database(void *data __maybe_unused, int argc __ma
static void sql_maint_aclk_sync_database_all(void) static void sql_maint_aclk_sync_database_all(void)
{ {
char *err_msg = NULL; char *err_msg = NULL;
debug(D_ACLK_SYNC,"Cleaning tables for nodes that do not exist"); netdata_log_debug(D_ACLK_SYNC,"Cleaning tables for nodes that do not exist");
int rc = sqlite3_exec_monitored(db_meta, SQL_SELECT_ACLK_ALERT_LIST, sql_maint_aclk_sync_database, NULL, &err_msg); int rc = sqlite3_exec_monitored(db_meta, SQL_SELECT_ACLK_ALERT_LIST, sql_maint_aclk_sync_database, NULL, &err_msg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
error_report("Query failed when trying to check for obsolete ACLK sync tables, %s", err_msg); error_report("Query failed when trying to check for obsolete ACLK sync tables, %s", err_msg);
@ -444,7 +444,7 @@ static void aclk_synchronization(void *arg __maybe_unused)
sql_process_queue_removed_alerts_to_aclk(cmd.param[0]); sql_process_queue_removed_alerts_to_aclk(cmd.param[0]);
break; break;
default: default:
debug(D_ACLK_SYNC, "%s: default.", __func__); netdata_log_debug(D_ACLK_SYNC, "%s: default.", __func__);
break; break;
} }
if (cmd.completion) if (cmd.completion)

View file

@ -321,7 +321,7 @@ int init_database_batch(sqlite3 *database, int rebuild, int init_type, const cha
int rc; int rc;
char *err_msg = NULL; char *err_msg = NULL;
for (int i = 0; batch[i]; i++) { for (int i = 0; batch[i]; i++) {
debug(D_METADATALOG, "Executing %s", batch[i]); netdata_log_debug(D_METADATALOG, "Executing %s", batch[i]);
rc = sqlite3_exec_monitored(database, batch[i], 0, 0, &err_msg); rc = sqlite3_exec_monitored(database, batch[i], 0, 0, &err_msg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
error_report("SQLite error during database %s, rc = %d (%s)", init_type ? "cleanup" : "setup", rc, err_msg); error_report("SQLite error during database %s, rc = %d (%s)", init_type ? "cleanup" : "setup", rc, err_msg);

View file

@ -152,17 +152,16 @@ void aws_kinesis_connector_worker(void *instance_p)
} }
char error_message[ERROR_LINE_MAX + 1] = ""; char error_message[ERROR_LINE_MAX + 1] = "";
debug( netdata_log_debug(D_EXPORTING,
D_EXPORTING, "EXPORTING: kinesis_put_record(): dest = %s, id = %s, key = %s, stream = %s, partition_key = %s, \ "
"EXPORTING: kinesis_put_record(): dest = %s, id = %s, key = %s, stream = %s, partition_key = %s, \ " buffer = %zu, record = %zu",
buffer = %zu, record = %zu", instance->config.destination,
instance->config.destination, connector_specific_config->auth_key_id,
connector_specific_config->auth_key_id, connector_specific_config->secure_key,
connector_specific_config->secure_key, connector_specific_config->stream_name,
connector_specific_config->stream_name, partition_key,
partition_key, buffer_len,
buffer_len, record_len);
record_len);
kinesis_put_record( kinesis_put_record(
connector_specific_data, connector_specific_config->stream_name, partition_key, first_char, record_len); connector_specific_data, connector_specific_config->stream_name, partition_key, first_char, record_len);

View file

@ -69,18 +69,18 @@ int rrdset_is_exportable(struct instance *instance, RRDSET *st)
*flags |= RRDSET_FLAG_EXPORTING_SEND; *flags |= RRDSET_FLAG_EXPORTING_SEND;
else { else {
*flags |= RRDSET_FLAG_EXPORTING_IGNORE; *flags |= RRDSET_FLAG_EXPORTING_IGNORE;
debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", rrdset_id(st), rrdhost_hostname(host)); netdata_log_debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", rrdset_id(st), rrdhost_hostname(host));
return 0; return 0;
} }
} }
if(unlikely(!rrdset_is_available_for_exporting_and_alarms(st))) { if(unlikely(!rrdset_is_available_for_exporting_and_alarms(st))) {
debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.", rrdset_id(st), rrdhost_hostname(host)); netdata_log_debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.", rrdset_id(st), rrdhost_hostname(host));
return 0; return 0;
} }
if(unlikely(st->rrd_memory_mode == RRD_MEMORY_MODE_NONE && !(EXPORTING_OPTIONS_DATA_SOURCE(instance->config.options) == EXPORTING_SOURCE_DATA_AS_COLLECTED))) { if(unlikely(st->rrd_memory_mode == RRD_MEMORY_MODE_NONE && !(EXPORTING_OPTIONS_DATA_SOURCE(instance->config.options) == EXPORTING_SOURCE_DATA_AS_COLLECTED))) {
debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting engine requires database access.", rrdset_id(st), rrdhost_hostname(host), rrd_memory_mode_name(host->rrd_memory_mode)); netdata_log_debug(D_EXPORTING, "EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting engine requires database access.", rrdset_id(st), rrdhost_hostname(host), rrd_memory_mode_name(host->rrd_memory_mode));
return 0; return 0;
} }

View file

@ -329,7 +329,7 @@ void mongodb_connector_worker(void *instance_p)
data_size += insert[i]->len; data_size += insert[i]->len;
} }
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: mongodb_insert(): destination = %s, database = %s, collection = %s, data size = %zu", "EXPORTING: mongodb_insert(): destination = %s, database = %s, collection = %s, data size = %zu",
instance->config.destination, instance->config.destination,

View file

@ -107,7 +107,7 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data(
if (unlikely(before < first_t || after > last_t)) { if (unlikely(before < first_t || after > last_t)) {
// the chart has not been updated in the wanted timeframe // the chart has not been updated in the wanted timeframe
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: %s.%s.%s: aligned timeframe %lu to %lu is outside the chart's database range %lu to %lu", "EXPORTING: %s.%s.%s: aligned timeframe %lu to %lu is outside the chart's database range %lu to %lu",
rrdhost_hostname(host), rrdhost_hostname(host),
@ -142,7 +142,7 @@ NETDATA_DOUBLE exporting_calculate_value_from_stored_data(
global_statistics_exporters_query_completed(points_read); global_statistics_exporters_query_completed(points_read);
if (unlikely(!counter)) { if (unlikely(!counter)) {
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: %s.%s.%s: no values stored in database for range %lu to %lu", "EXPORTING: %s.%s.%s: no values stored in database for range %lu to %lu",
rrdhost_hostname(host), rrdhost_hostname(host),

View file

@ -41,7 +41,7 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN
rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_SEND); rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_SEND);
} else { } else {
rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_IGNORE); rrdset_flag_set(st, RRDSET_FLAG_EXPORTING_IGNORE);
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.", "EXPORTING: not sending chart '%s' of host '%s', because it is disabled for exporting.",
rrdset_id(st), rrdset_id(st),
@ -51,7 +51,7 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN
} }
if (unlikely(!rrdset_is_available_for_exporting_and_alarms(st))) { if (unlikely(!rrdset_is_available_for_exporting_and_alarms(st))) {
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.", "EXPORTING: not sending chart '%s' of host '%s', because it is not available for exporting.",
rrdset_id(st), rrdset_id(st),
@ -62,7 +62,7 @@ inline int can_send_rrdset(struct instance *instance, RRDSET *st, SIMPLE_PATTERN
if (unlikely( if (unlikely(
st->rrd_memory_mode == RRD_MEMORY_MODE_NONE && st->rrd_memory_mode == RRD_MEMORY_MODE_NONE &&
!(EXPORTING_OPTIONS_DATA_SOURCE(instance->config.options) == EXPORTING_SOURCE_DATA_AS_COLLECTED))) { !(EXPORTING_OPTIONS_DATA_SOURCE(instance->config.options) == EXPORTING_SOURCE_DATA_AS_COLLECTED))) {
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting connector requires database access.", "EXPORTING: not sending chart '%s' of host '%s' because its memory mode is '%s' and the exporting connector requires database access.",
rrdset_id(st), rrdset_id(st),

View file

@ -244,7 +244,7 @@ int format_dimension_prometheus_remote_write(struct instance *instance, RRDDIM *
// we need as-collected / raw data // we need as-collected / raw data
if (unlikely(rd->collector.last_collected_time.tv_sec < instance->after)) { if (unlikely(rd->collector.last_collected_time.tv_sec < instance->after)) {
debug( netdata_log_debug(
D_EXPORTING, D_EXPORTING,
"EXPORTING: not sending dimension '%s' of chart '%s' from host '%s', " "EXPORTING: not sending dimension '%s' of chart '%s' from host '%s', "
"its last data collection (%lu) is not within our timeframe (%lu to %lu)", "its last data collection (%lu) is not within our timeframe (%lu to %lu)",

View file

@ -141,7 +141,7 @@ void pubsub_connector_worker(void *instance_p)
goto cleanup; goto cleanup;
} }
debug( netdata_log_debug(
D_EXPORTING, "EXPORTING: pubsub_publish(): project = %s, topic = %s, buffer = %zu", D_EXPORTING, "EXPORTING: pubsub_publish(): project = %s, topic = %s, buffer = %zu",
connector_specific_config->project_id, connector_specific_config->topic_id, buffer_len); connector_specific_config->project_id, connector_specific_config->topic_id, buffer_len);

View file

@ -40,12 +40,11 @@ int exporting_discard_response(BUFFER *buffer, struct instance *instance) {
} }
*d = '\0'; *d = '\0';
debug( netdata_log_debug(D_EXPORTING,
D_EXPORTING, "EXPORTING: received %zu bytes from %s connector instance. Ignoring them. Sample: '%s'",
"EXPORTING: received %zu bytes from %s connector instance. Ignoring them. Sample: '%s'", buffer_strlen(buffer),
buffer_strlen(buffer), instance->config.name,
instance->config.name, sample);
sample);
#else #else
UNUSED(instance); UNUSED(instance);
#endif /* NETDATA_INTERNAL_CHECKS */ #endif /* NETDATA_INTERNAL_CHECKS */

View file

@ -312,10 +312,10 @@ static void health_silencers_init(void) {
* Initialize the health thread. * Initialize the health thread.
*/ */
void health_init(void) { void health_init(void) {
debug(D_HEALTH, "Health configuration initializing"); netdata_log_debug(D_HEALTH, "Health configuration initializing");
if(!(default_health_enabled = (unsigned int)config_get_boolean(CONFIG_SECTION_HEALTH, "enabled", default_health_enabled))) { if(!(default_health_enabled = (unsigned int)config_get_boolean(CONFIG_SECTION_HEALTH, "enabled", default_health_enabled))) {
debug(D_HEALTH, "Health is disabled."); netdata_log_debug(D_HEALTH, "Health is disabled.");
return; return;
} }
@ -427,13 +427,13 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
if(unlikely(ae->new_status < RRDCALC_STATUS_CLEAR)) { if(unlikely(ae->new_status < RRDCALC_STATUS_CLEAR)) {
// do not send notifications for internal statuses // do not send notifications for internal statuses
debug(D_HEALTH, "Health not sending notification for alarm '%s.%s' status %s (internal statuses)", ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status)); netdata_log_debug(D_HEALTH, "Health not sending notification for alarm '%s.%s' status %s (internal statuses)", ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status));
goto done; goto done;
} }
if(unlikely(ae->new_status <= RRDCALC_STATUS_CLEAR && (ae->flags & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION))) { if(unlikely(ae->new_status <= RRDCALC_STATUS_CLEAR && (ae->flags & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION))) {
// do not send notifications for disabled statuses // do not send notifications for disabled statuses
debug(D_HEALTH, "Health not sending notification for alarm '%s.%s' status %s (it has no-clear-notification enabled)", ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status)); netdata_log_debug(D_HEALTH, "Health not sending notification for alarm '%s.%s' status %s (it has no-clear-notification enabled)", ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status));
log_health("[%s]: Health not sending notification for alarm '%s.%s' status %s (it has no-clear-notification enabled)", rrdhost_hostname(host), ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status)); log_health("[%s]: Health not sending notification for alarm '%s.%s' status %s (it has no-clear-notification enabled)", rrdhost_hostname(host), ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status));
// mark it as run, so that we will send the same alarm if it happens again // mark it as run, so that we will send the same alarm if it happens again
goto done; goto done;
@ -450,7 +450,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
// we have executed this alarm notification in the past // we have executed this alarm notification in the past
if(last_executed_status == ae->new_status && !(ae->flags & HEALTH_ENTRY_FLAG_IS_REPEATING)) { if(last_executed_status == ae->new_status && !(ae->flags & HEALTH_ENTRY_FLAG_IS_REPEATING)) {
// don't send the notification for the same status again // don't send the notification for the same status again
debug(D_HEALTH, "Health not sending again notification for alarm '%s.%s' status %s", ae_chart_name(ae), ae_name(ae) netdata_log_debug(D_HEALTH, "Health not sending again notification for alarm '%s.%s' status %s", ae_chart_name(ae), ae_name(ae)
, rrdcalc_status2string(ae->new_status)); , rrdcalc_status2string(ae->new_status));
log_health("[%s]: Health not sending again notification for alarm '%s.%s' status %s", rrdhost_hostname(host), ae_chart_name(ae), ae_name(ae) log_health("[%s]: Health not sending again notification for alarm '%s.%s' status %s", rrdhost_hostname(host), ae_chart_name(ae), ae_name(ae)
, rrdcalc_status2string(ae->new_status)); , rrdcalc_status2string(ae->new_status));
@ -462,7 +462,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
// so, don't send CLEAR notifications // so, don't send CLEAR notifications
if(unlikely(ae->new_status == RRDCALC_STATUS_CLEAR)) { if(unlikely(ae->new_status == RRDCALC_STATUS_CLEAR)) {
if((!(ae->flags & HEALTH_ENTRY_RUN_ONCE)) || (ae->flags & HEALTH_ENTRY_RUN_ONCE && ae->old_status < RRDCALC_STATUS_RAISED) ) { if((!(ae->flags & HEALTH_ENTRY_RUN_ONCE)) || (ae->flags & HEALTH_ENTRY_RUN_ONCE && ae->old_status < RRDCALC_STATUS_RAISED) ) {
debug(D_HEALTH, "Health not sending notification for first initialization of alarm '%s.%s' status %s" netdata_log_debug(D_HEALTH, "Health not sending notification for first initialization of alarm '%s.%s' status %s"
, ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status)); , ae_chart_name(ae), ae_name(ae), rrdcalc_status2string(ae->new_status));
goto done; goto done;
} }
@ -583,7 +583,7 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
ae->flags |= HEALTH_ENTRY_FLAG_EXEC_RUN; ae->flags |= HEALTH_ENTRY_FLAG_EXEC_RUN;
ae->exec_run_timestamp = now_realtime_sec(); /* will be updated by real time after spawning */ ae->exec_run_timestamp = now_realtime_sec(); /* will be updated by real time after spawning */
debug(D_HEALTH, "executing command '%s'", command_to_run); netdata_log_debug(D_HEALTH, "executing command '%s'", command_to_run);
ae->flags |= HEALTH_ENTRY_FLAG_EXEC_IN_PROGRESS; ae->flags |= HEALTH_ENTRY_FLAG_EXEC_IN_PROGRESS;
ae->exec_spawn_serial = spawn_enq_cmd(command_to_run); ae->exec_spawn_serial = spawn_enq_cmd(command_to_run);
enqueue_alarm_notify_in_progress(ae); enqueue_alarm_notify_in_progress(ae);
@ -608,7 +608,7 @@ static inline void health_alarm_wait_for_execution(ALARM_ENTRY *ae) {
return; return;
spawn_wait_cmd(ae->exec_spawn_serial, &ae->exec_code, &ae->exec_run_timestamp); spawn_wait_cmd(ae->exec_spawn_serial, &ae->exec_code, &ae->exec_run_timestamp);
debug(D_HEALTH, "done executing command - returned with code %d", ae->exec_code); netdata_log_debug(D_HEALTH, "done executing command - returned with code %d", ae->exec_code);
ae->flags &= ~HEALTH_ENTRY_FLAG_EXEC_IN_PROGRESS; ae->flags &= ~HEALTH_ENTRY_FLAG_EXEC_IN_PROGRESS;
if(ae->exec_code != 0) if(ae->exec_code != 0)
@ -618,7 +618,7 @@ static inline void health_alarm_wait_for_execution(ALARM_ENTRY *ae) {
} }
static inline void health_process_notifications(RRDHOST *host, ALARM_ENTRY *ae) { static inline void health_process_notifications(RRDHOST *host, ALARM_ENTRY *ae) {
debug(D_HEALTH, "Health alarm '%s.%s' = " NETDATA_DOUBLE_FORMAT_AUTO " - changed status from %s to %s", netdata_log_debug(D_HEALTH, "Health alarm '%s.%s' = " NETDATA_DOUBLE_FORMAT_AUTO " - changed status from %s to %s",
ae->chart?ae_chart_name(ae):"NOCHART", ae_name(ae), ae->chart?ae_chart_name(ae):"NOCHART", ae_name(ae),
ae->new_value, ae->new_value,
rrdcalc_status2string(ae->old_status), rrdcalc_status2string(ae->old_status),
@ -691,7 +691,7 @@ static inline void health_alarm_log_process(RRDHOST *host) {
static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run) { static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run) {
if(unlikely(!rc->rrdset)) { if(unlikely(!rc->rrdset)) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. It is not linked to a chart.", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. It is not linked to a chart.", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return 0; return 0;
} }
@ -702,27 +702,27 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
*next_run = rc->next_update; *next_run = rc->next_update;
} }
debug(D_HEALTH, "Health not examining alarm '%s.%s' yet (will do in %d secs).", rrdcalc_chart_name(rc), rrdcalc_name(rc), (int) (rc->next_update - now)); netdata_log_debug(D_HEALTH, "Health not examining alarm '%s.%s' yet (will do in %d secs).", rrdcalc_chart_name(rc), rrdcalc_name(rc), (int) (rc->next_update - now));
return 0; return 0;
} }
if(unlikely(!rc->update_every)) { if(unlikely(!rc->update_every)) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. It does not have an update frequency", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. It does not have an update frequency", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return 0; return 0;
} }
if(unlikely(rrdset_flag_check(rc->rrdset, RRDSET_FLAG_OBSOLETE))) { if(unlikely(rrdset_flag_check(rc->rrdset, RRDSET_FLAG_OBSOLETE))) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart has been marked as obsolete", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart has been marked as obsolete", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return 0; return 0;
} }
if(unlikely(rrdset_flag_check(rc->rrdset, RRDSET_FLAG_ARCHIVED))) { if(unlikely(rrdset_flag_check(rc->rrdset, RRDSET_FLAG_ARCHIVED))) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart has been marked as archived", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. The chart has been marked as archived", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return 0; return 0;
} }
if(unlikely(!rc->rrdset->last_collected_time.tv_sec || rc->rrdset->counter_done < 2)) { if(unlikely(!rc->rrdset->last_collected_time.tv_sec || rc->rrdset->counter_done < 2)) {
debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not fully collected yet.", rrdcalc_chart_name(rc), rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Health not running alarm '%s.%s'. Chart is not fully collected yet.", rrdcalc_chart_name(rc), rrdcalc_name(rc));
return 0; return 0;
} }
@ -731,7 +731,7 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
time_t last = rrdset_last_entry_s(rc->rrdset); time_t last = rrdset_last_entry_s(rc->rrdset);
if(unlikely(now + update_every < first /* || now - update_every > last */)) { if(unlikely(now + update_every < first /* || now - update_every > last */)) {
debug(D_HEALTH netdata_log_debug(D_HEALTH
, "Health not examining alarm '%s.%s' yet (wanted time is out of bounds - we need %lu but got %lu - %lu)." , "Health not examining alarm '%s.%s' yet (wanted time is out of bounds - we need %lu but got %lu - %lu)."
, rrdcalc_chart_name(rc), rrdcalc_name(rc), (unsigned long) now, (unsigned long) first , rrdcalc_chart_name(rc), rrdcalc_name(rc), (unsigned long) now, (unsigned long) first
, (unsigned long) last); , (unsigned long) last);
@ -742,7 +742,7 @@ static inline int rrdcalc_isrunnable(RRDCALC *rc, time_t now, time_t *next_run)
time_t needed = now + rc->before + rc->after; time_t needed = now + rc->before + rc->after;
if(needed + update_every < first || needed - update_every > last) { if(needed + update_every < first || needed - update_every > last) {
debug(D_HEALTH netdata_log_debug(D_HEALTH
, "Health not examining alarm '%s.%s' yet (not enough data yet - we need %lu but got %lu - %lu)." , "Health not examining alarm '%s.%s' yet (not enough data yet - we need %lu but got %lu - %lu)."
, rrdcalc_chart_name(rc), rrdcalc_name(rc), (unsigned long) needed, (unsigned long) first , rrdcalc_chart_name(rc), rrdcalc_name(rc), (unsigned long) needed, (unsigned long) first
, (unsigned long) last); , (unsigned long) last);
@ -851,20 +851,20 @@ static void health_sleep(time_t next_run, unsigned int loop __maybe_unused) {
time_t now = now_realtime_sec(); time_t now = now_realtime_sec();
if(now < next_run) { if(now < next_run) {
worker_is_idle(); worker_is_idle();
debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration in %d secs", loop, (int) (next_run - now)); netdata_log_debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration in %d secs", loop, (int) (next_run - now));
while (now < next_run && service_running(SERVICE_HEALTH)) { while (now < next_run && service_running(SERVICE_HEALTH)) {
sleep_usec(USEC_PER_SEC); sleep_usec(USEC_PER_SEC);
now = now_realtime_sec(); now = now_realtime_sec();
} }
} }
else { else {
debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration now", loop); netdata_log_debug(D_HEALTH, "Health monitoring iteration no %u done. Next iteration now", loop);
} }
} }
static SILENCE_TYPE check_silenced(RRDCALC *rc, const char *host, SILENCERS *silencers) { static SILENCE_TYPE check_silenced(RRDCALC *rc, const char *host, SILENCERS *silencers) {
SILENCER *s; SILENCER *s;
debug(D_HEALTH, "Checking if alarm was silenced via the command API. Alarm info name:%s context:%s chart:%s host:%s family:%s", netdata_log_debug(D_HEALTH, "Checking if alarm was silenced via the command API. Alarm info name:%s context:%s chart:%s host:%s family:%s",
rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host, (rc->rrdset)?rrdset_family(rc->rrdset):""); rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host, (rc->rrdset)?rrdset_family(rc->rrdset):"");
for (s = silencers->silencers; s!=NULL; s=s->next){ for (s = silencers->silencers; s!=NULL; s=s->next){
@ -875,11 +875,11 @@ static SILENCE_TYPE check_silenced(RRDCALC *rc, const char *host, SILENCERS *sil
(!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart))) && (!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart))) &&
(!s->families_pattern || (rc->rrdset && rc->rrdset->family && s->families_pattern && simple_pattern_matches_string(s->families_pattern, rc->rrdset->family))) (!s->families_pattern || (rc->rrdset && rc->rrdset->family && s->families_pattern && simple_pattern_matches_string(s->families_pattern, rc->rrdset->family)))
) { ) {
debug(D_HEALTH, "Alarm matches command API silence entry %s:%s:%s:%s:%s", s->alarms,s->charts, s->contexts, s->hosts, s->families); netdata_log_debug(D_HEALTH, "Alarm matches command API silence entry %s:%s:%s:%s:%s", s->alarms,s->charts, s->contexts, s->hosts, s->families);
if (unlikely(silencers->stype == STYPE_NONE)) { if (unlikely(silencers->stype == STYPE_NONE)) {
debug(D_HEALTH, "Alarm %s matched a silence entry, but no SILENCE or DISABLE command was issued via the command API. The match has no effect.", rrdcalc_name(rc)); netdata_log_debug(D_HEALTH, "Alarm %s matched a silence entry, but no SILENCE or DISABLE command was issued via the command API. The match has no effect.", rrdcalc_name(rc));
} else { } else {
debug(D_HEALTH, "Alarm %s via the command API - name:%s context:%s chart:%s host:%s family:%s" netdata_log_debug(D_HEALTH, "Alarm %s via the command API - name:%s context:%s chart:%s host:%s family:%s"
, (silencers->stype == STYPE_DISABLE_ALARMS)?"Disabled":"Silenced" , (silencers->stype == STYPE_DISABLE_ALARMS)?"Disabled":"Silenced"
, rrdcalc_name(rc) , rrdcalc_name(rc)
, (rc->rrdset)?rrdset_context(rc->rrdset):"" , (rc->rrdset)?rrdset_context(rc->rrdset):""
@ -1031,7 +1031,7 @@ void *health_main(void *ptr) {
while(service_running(SERVICE_HEALTH)) { while(service_running(SERVICE_HEALTH)) {
loop++; loop++;
debug(D_HEALTH, "Health monitoring iteration no %u started", loop); netdata_log_debug(D_HEALTH, "Health monitoring iteration no %u started", loop);
time_t now = now_realtime_sec(); time_t now = now_realtime_sec();
int runnable = 0, apply_hibernation_delay = 0; int runnable = 0, apply_hibernation_delay = 0;
@ -1202,7 +1202,7 @@ void *health_main(void *ptr) {
rc->value = NAN; rc->value = NAN;
rc->run_flags |= RRDCALC_FLAG_DB_ERROR; rc->run_flags |= RRDCALC_FLAG_DB_ERROR;
debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': database lookup returned error %d", netdata_log_debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': database lookup returned error %d",
rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), ret rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), ret
); );
} else } else
@ -1213,14 +1213,14 @@ void *health_main(void *ptr) {
rc->value = NAN; rc->value = NAN;
rc->run_flags |= RRDCALC_FLAG_DB_NAN; rc->run_flags |= RRDCALC_FLAG_DB_NAN;
debug(D_HEALTH, netdata_log_debug(D_HEALTH,
"Health on host '%s', alarm '%s.%s': database lookup returned empty value (possibly value is not collected yet)", "Health on host '%s', alarm '%s.%s': database lookup returned empty value (possibly value is not collected yet)",
rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc) rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc)
); );
} else } else
rc->run_flags &= ~RRDCALC_FLAG_DB_NAN; rc->run_flags &= ~RRDCALC_FLAG_DB_NAN;
debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': database lookup gave value " NETDATA_DOUBLE_FORMAT, netdata_log_debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': database lookup gave value " NETDATA_DOUBLE_FORMAT,
rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), rc->value rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), rc->value
); );
} }
@ -1236,14 +1236,14 @@ void *health_main(void *ptr) {
rc->value = NAN; rc->value = NAN;
rc->run_flags |= RRDCALC_FLAG_CALC_ERROR; rc->run_flags |= RRDCALC_FLAG_CALC_ERROR;
debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': expression '%s' failed: %s", netdata_log_debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': expression '%s' failed: %s",
rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc),
rc->calculation->parsed_as, buffer_tostring(rc->calculation->error_msg) rc->calculation->parsed_as, buffer_tostring(rc->calculation->error_msg)
); );
} else { } else {
rc->run_flags &= ~RRDCALC_FLAG_CALC_ERROR; rc->run_flags &= ~RRDCALC_FLAG_CALC_ERROR;
debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': expression '%s' gave value " netdata_log_debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': expression '%s' gave value "
NETDATA_DOUBLE_FORMAT NETDATA_DOUBLE_FORMAT
": %s (source: %s)", rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), ": %s (source: %s)", rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc),
rc->calculation->parsed_as, rc->calculation->result, rc->calculation->parsed_as, rc->calculation->result,
@ -1280,14 +1280,14 @@ void *health_main(void *ptr) {
// calculation failed // calculation failed
rc->run_flags |= RRDCALC_FLAG_WARN_ERROR; rc->run_flags |= RRDCALC_FLAG_WARN_ERROR;
debug(D_HEALTH, netdata_log_debug(D_HEALTH,
"Health on host '%s', alarm '%s.%s': warning expression failed with error: %s", "Health on host '%s', alarm '%s.%s': warning expression failed with error: %s",
rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc),
buffer_tostring(rc->warning->error_msg) buffer_tostring(rc->warning->error_msg)
); );
} else { } else {
rc->run_flags &= ~RRDCALC_FLAG_WARN_ERROR; rc->run_flags &= ~RRDCALC_FLAG_WARN_ERROR;
debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': warning expression gave value " netdata_log_debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': warning expression gave value "
NETDATA_DOUBLE_FORMAT NETDATA_DOUBLE_FORMAT
": %s (source: %s)", rrdhost_hostname(host), rrdcalc_chart_name(rc), ": %s (source: %s)", rrdhost_hostname(host), rrdcalc_chart_name(rc),
rrdcalc_name(rc), rc->warning->result, buffer_tostring(rc->warning->error_msg), rrdcalc_source(rc) rrdcalc_name(rc), rc->warning->result, buffer_tostring(rc->warning->error_msg), rrdcalc_source(rc)
@ -1306,14 +1306,14 @@ void *health_main(void *ptr) {
// calculation failed // calculation failed
rc->run_flags |= RRDCALC_FLAG_CRIT_ERROR; rc->run_flags |= RRDCALC_FLAG_CRIT_ERROR;
debug(D_HEALTH, netdata_log_debug(D_HEALTH,
"Health on host '%s', alarm '%s.%s': critical expression failed with error: %s", "Health on host '%s', alarm '%s.%s': critical expression failed with error: %s",
rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdhost_hostname(host), rrdcalc_chart_name(rc), rrdcalc_name(rc),
buffer_tostring(rc->critical->error_msg) buffer_tostring(rc->critical->error_msg)
); );
} else { } else {
rc->run_flags &= ~RRDCALC_FLAG_CRIT_ERROR; rc->run_flags &= ~RRDCALC_FLAG_CRIT_ERROR;
debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': critical expression gave value " netdata_log_debug(D_HEALTH, "Health on host '%s', alarm '%s.%s': critical expression gave value "
NETDATA_DOUBLE_FORMAT NETDATA_DOUBLE_FORMAT
": %s (source: %s)", rrdhost_hostname(host), rrdcalc_chart_name(rc), ": %s (source: %s)", rrdhost_hostname(host), rrdcalc_chart_name(rc),
rrdcalc_name(rc), rc->critical->result, buffer_tostring(rc->critical->error_msg), rrdcalc_name(rc), rc->critical->result, buffer_tostring(rc->critical->error_msg),
@ -1515,7 +1515,7 @@ void *health_main(void *ptr) {
} }
rc->run_flags |= RRDCALC_FLAG_RUN_ONCE; rc->run_flags |= RRDCALC_FLAG_RUN_ONCE;
health_process_notifications(host, ae); health_process_notifications(host, ae);
debug(D_HEALTH, "Notification sent for the repeating alarm %u.", ae->alarm_id); netdata_log_debug(D_HEALTH, "Notification sent for the repeating alarm %u.", ae->alarm_id);
health_alarm_wait_for_execution(ae); health_alarm_wait_for_execution(ae);
health_alarm_log_free_one_nochecks_nounlink(ae); health_alarm_log_free_one_nochecks_nounlink(ae);
} }

View file

@ -308,7 +308,7 @@ static inline int health_parse_db_lookup(
RRDR_TIME_GROUPING *group_method, int *after, int *before, int *every, RRDR_TIME_GROUPING *group_method, int *after, int *before, int *every,
RRDCALC_OPTIONS *options, STRING **dimensions, STRING **foreachdim RRDCALC_OPTIONS *options, STRING **dimensions, STRING **foreachdim
) { ) {
debug(D_HEALTH, "Health configuration parsing database lookup %zu@%s: %s", line, filename, string); netdata_log_debug(D_HEALTH, "Health configuration parsing database lookup %zu@%s: %s", line, filename, string);
if(*dimensions) string_freez(*dimensions); if(*dimensions) string_freez(*dimensions);
if(*foreachdim) string_freez(*foreachdim); if(*foreachdim) string_freez(*foreachdim);
@ -507,7 +507,7 @@ int sql_store_hashes = 1;
static int health_readfile(const char *filename, void *data) { static int health_readfile(const char *filename, void *data) {
RRDHOST *host = (RRDHOST *)data; RRDHOST *host = (RRDHOST *)data;
debug(D_HEALTH, "Health configuration reading file '%s'", filename); netdata_log_debug(D_HEALTH, "Health configuration reading file '%s'", filename);
static uint32_t static uint32_t
hash_alarm = 0, hash_alarm = 0,
@ -738,10 +738,10 @@ static int health_readfile(const char *filename, void *data) {
if(!simple_pattern_matches_string(os_pattern, host->os)) { if(!simple_pattern_matches_string(os_pattern, host->os)) {
if(rc) if(rc)
debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, os_match); netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, os_match);
if(rt) if(rt)
debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, os_match); netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: host O/S does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, os_match);
ignore_this = 1; ignore_this = 1;
} }
@ -755,10 +755,10 @@ static int health_readfile(const char *filename, void *data) {
if(!simple_pattern_matches_string(host_pattern, host->hostname)) { if(!simple_pattern_matches_string(host_pattern, host->hostname)) {
if(rc) if(rc)
debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, host_match); netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring alarm '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalc_name(rc), line, filename, host_match);
if(rt) if(rt)
debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, host_match); netdata_log_debug(D_HEALTH, "HEALTH on '%s' ignoring template '%s' defined at %zu@%s: hostname does not match '%s'", rrdhost_hostname(host), rrdcalctemplate_name(rt), line, filename, host_match);
ignore_this = 1; ignore_this = 1;
} }
@ -1328,7 +1328,7 @@ void sql_refresh_hashes(void)
void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path, const char *subpath) { void health_readdir(RRDHOST *host, const char *user_path, const char *stock_path, const char *subpath) {
if(unlikely((!host->health.health_enabled) && !rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH)) || if(unlikely((!host->health.health_enabled) && !rrdhost_flag_check(host, RRDHOST_FLAG_INITIALIZED_HEALTH)) ||
!service_running(SERVICE_HEALTH)) { !service_running(SERVICE_HEALTH)) {
debug(D_HEALTH, "CONFIG health is not enabled for host '%s'", rrdhost_hostname(host)); netdata_log_debug(D_HEALTH, "CONFIG health is not enabled for host '%s'", rrdhost_hostname(host));
return; return;
} }

View file

@ -37,7 +37,7 @@ inline ALARM_ENTRY* health_create_alarm_entry(
int delay, int delay,
HEALTH_ENTRY_FLAGS flags HEALTH_ENTRY_FLAGS flags
) { ) {
debug(D_HEALTH, "Health adding alarm log entry with id: %u", host->health_log.next_log_id); netdata_log_debug(D_HEALTH, "Health adding alarm log entry with id: %u", host->health_log.next_log_id);
ALARM_ENTRY *ae = callocz(1, sizeof(ALARM_ENTRY)); ALARM_ENTRY *ae = callocz(1, sizeof(ALARM_ENTRY));
ae->name = string_dup(name); ae->name = string_dup(name);
@ -89,7 +89,7 @@ inline void health_alarm_log_add_entry(
RRDHOST *host, RRDHOST *host,
ALARM_ENTRY *ae ALARM_ENTRY *ae
) { ) {
debug(D_HEALTH, "Health adding alarm log entry with id: %u", ae->unique_id); netdata_log_debug(D_HEALTH, "Health adding alarm log entry with id: %u", ae->unique_id);
__atomic_add_fetch(&host->health_transitions, 1, __ATOMIC_RELAXED); __atomic_add_fetch(&host->health_transitions, 1, __ATOMIC_RELAXED);

View file

@ -107,7 +107,7 @@ void buffer_vsprintf(BUFFER *wb, const char *fmt, va_list args)
do { do {
need += space_remaining * 2; need += space_remaining * 2;
debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote); netdata_log_debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote);
buffer_need_bytes(wb, need); buffer_need_bytes(wb, need);
space_remaining = wb->size - wb->len - 1; space_remaining = wb->size - wb->len - 1;
@ -131,7 +131,7 @@ void buffer_sprintf(BUFFER *wb, const char *fmt, ...)
do { do {
need += space_remaining * 2; need += space_remaining * 2;
debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote); netdata_log_debug(D_WEB_BUFFER, "web_buffer_sprintf(): increasing web_buffer at position %zu, size = %zu, by %zu bytes (wrote = %zu)\n", wb->len, wb->size, need, wrote);
buffer_need_bytes(wb, need); buffer_need_bytes(wb, need);
space_remaining = wb->size - wb->len - 1; space_remaining = wb->size - wb->len - 1;
@ -246,7 +246,7 @@ BUFFER *buffer_create(size_t size, size_t *statistics)
{ {
BUFFER *b; BUFFER *b;
debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size); netdata_log_debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size);
b = callocz(1, sizeof(BUFFER)); b = callocz(1, sizeof(BUFFER));
b->buffer = mallocz(size + sizeof(BUFFER_OVERFLOW_EOF) + 2); b->buffer = mallocz(size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
@ -268,7 +268,7 @@ void buffer_free(BUFFER *b) {
buffer_overflow_check(b); buffer_overflow_check(b);
debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size); netdata_log_debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size);
if(b->statistics) if(b->statistics)
__atomic_sub_fetch(b->statistics, b->size + sizeof(BUFFER) + sizeof(BUFFER_OVERFLOW_EOF) + 2, __ATOMIC_RELAXED); __atomic_sub_fetch(b->statistics, b->size + sizeof(BUFFER) + sizeof(BUFFER_OVERFLOW_EOF) + 2, __ATOMIC_RELAXED);
@ -290,7 +290,7 @@ void buffer_increase(BUFFER *b, size_t free_size_required) {
size_t optimal = (b->size > 5*1024*1024) ? b->size / 2 : b->size; size_t optimal = (b->size > 5*1024*1024) ? b->size / 2 : b->size;
if(optimal > wanted) wanted = optimal; if(optimal > wanted) wanted = optimal;
debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + wanted); netdata_log_debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + wanted);
b->buffer = reallocz(b->buffer, b->size + wanted + sizeof(BUFFER_OVERFLOW_EOF) + 2); b->buffer = reallocz(b->buffer, b->size + wanted + sizeof(BUFFER_OVERFLOW_EOF) + 2);
b->size += wanted; b->size += wanted;

View file

@ -164,7 +164,7 @@ static inline struct section *appconfig_section_find(struct config *root, const
} }
static inline struct section *appconfig_section_create(struct config *root, const char *section) { static inline struct section *appconfig_section_create(struct config *root, const char *section) {
debug(D_CONFIG, "Creating section '%s'.", section); netdata_log_debug(D_CONFIG, "Creating section '%s'.", section);
struct section *co = callocz(1, sizeof(struct section)); struct section *co = callocz(1, sizeof(struct section));
co->name = strdupz(section); co->name = strdupz(section);
@ -194,7 +194,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti
struct section *co; struct section *co;
struct config_option *cv, *cv_next; struct config_option *cv, *cv_next;
debug(D_CONFIG, "Destroying section '%s'.", section); netdata_log_debug(D_CONFIG, "Destroying section '%s'.", section);
co = appconfig_section_find(root, section); co = appconfig_section_find(root, section);
if(!co) { if(!co) {
@ -259,7 +259,7 @@ void appconfig_section_destroy_non_loaded(struct config *root, const char *secti
void appconfig_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name) void appconfig_section_option_destroy_non_loaded(struct config *root, const char *section, const char *name)
{ {
debug(D_CONFIG, "Destroying section option '%s -> %s'.", section, name); netdata_log_debug(D_CONFIG, "Destroying section option '%s -> %s'.", section, name);
struct section *co; struct section *co;
co = appconfig_section_find(root, section); co = appconfig_section_find(root, section);
@ -310,7 +310,7 @@ void appconfig_section_option_destroy_non_loaded(struct config *root, const char
// config name-value methods // config name-value methods
static inline struct config_option *appconfig_value_create(struct section *co, const char *name, const char *value) { static inline struct config_option *appconfig_value_create(struct section *co, const char *name, const char *value) {
debug(D_CONFIG, "Creating config entry for name '%s', value '%s', in section '%s'.", name, value, co->name); netdata_log_debug(D_CONFIG, "Creating config entry for name '%s', value '%s', in section '%s'.", name, value, co->name);
struct config_option *cv = callocz(1, sizeof(struct config_option)); struct config_option *cv = callocz(1, sizeof(struct config_option));
cv->name = strdupz(name); cv->name = strdupz(name);
@ -341,7 +341,7 @@ static inline struct config_option *appconfig_value_create(struct section *co, c
int appconfig_exists(struct config *root, const char *section, const char *name) { int appconfig_exists(struct config *root, const char *section, const char *name) {
struct config_option *cv; struct config_option *cv;
debug(D_CONFIG, "request to get config in section '%s', name '%s'", section, name); netdata_log_debug(D_CONFIG, "request to get config in section '%s', name '%s'", section, name);
struct section *co = appconfig_section_find(root, section); struct section *co = appconfig_section_find(root, section);
if(!co) return 0; if(!co) return 0;
@ -356,7 +356,7 @@ int appconfig_move(struct config *root, const char *section_old, const char *nam
struct config_option *cv_old, *cv_new; struct config_option *cv_old, *cv_new;
int ret = -1; int ret = -1;
debug(D_CONFIG, "request to rename config in section '%s', old name '%s', to section '%s', new name '%s'", section_old, name_old, section_new, name_new); netdata_log_debug(D_CONFIG, "request to rename config in section '%s', old name '%s', to section '%s', new name '%s'", section_old, name_old, section_new, name_new);
struct section *co_old = appconfig_section_find(root, section_old); struct section *co_old = appconfig_section_find(root, section_old);
if(!co_old) return ret; if(!co_old) return ret;
@ -439,9 +439,9 @@ char *appconfig_get_by_section(struct section *co, const char *name, const char
char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value) char *appconfig_get(struct config *root, const char *section, const char *name, const char *default_value)
{ {
if (default_value == NULL) if (default_value == NULL)
debug(D_CONFIG, "request to get config in section '%s', name '%s' or fail", section, name); netdata_log_debug(D_CONFIG, "request to get config in section '%s', name '%s' or fail", section, name);
else else
debug(D_CONFIG, "request to get config in section '%s', name '%s', default_value '%s'", section, name, default_value); netdata_log_debug(D_CONFIG, "request to get config in section '%s', name '%s', default_value '%s'", section, name, default_value);
struct section *co = appconfig_section_find(root, section); struct section *co = appconfig_section_find(root, section);
if (!co && !default_value) if (!co && !default_value)
@ -532,7 +532,7 @@ const char *appconfig_set_default(struct config *root, const char *section, cons
{ {
struct config_option *cv; struct config_option *cv;
debug(D_CONFIG, "request to set default config in section '%s', name '%s', value '%s'", section, name, value); netdata_log_debug(D_CONFIG, "request to set default config in section '%s', name '%s', value '%s'", section, name, value);
struct section *co = appconfig_section_find(root, section); struct section *co = appconfig_section_find(root, section);
if(!co) return appconfig_set(root, section, name, value); if(!co) return appconfig_set(root, section, name, value);
@ -559,7 +559,7 @@ const char *appconfig_set(struct config *root, const char *section, const char *
{ {
struct config_option *cv; struct config_option *cv;
debug(D_CONFIG, "request to set config in section '%s', name '%s', value '%s'", section, name, value); netdata_log_debug(D_CONFIG, "request to set config in section '%s', name '%s', value '%s'", section, name, value);
struct section *co = appconfig_section_find(root, section); struct section *co = appconfig_section_find(root, section);
if(!co) co = appconfig_section_create(root, section); if(!co) co = appconfig_section_create(root, section);
@ -649,7 +649,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
if(!filename) filename = CONFIG_DIR "/" CONFIG_FILENAME; if(!filename) filename = CONFIG_DIR "/" CONFIG_FILENAME;
debug(D_CONFIG, "CONFIG: opening config file '%s'", filename); netdata_log_debug(D_CONFIG, "CONFIG: opening config file '%s'", filename);
FILE *fp = fopen(filename, "r"); FILE *fp = fopen(filename, "r");
if(!fp) { if(!fp) {
@ -669,7 +669,7 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
s = trim(buffer); s = trim(buffer);
if(!s || *s == '#') { if(!s || *s == '#') {
debug(D_CONFIG, "CONFIG: ignoring line %d of file '%s', it is empty.", line, filename); netdata_log_debug(D_CONFIG, "CONFIG: ignoring line %d of file '%s', it is empty.", line, filename);
continue; continue;
} }
@ -778,12 +778,12 @@ int appconfig_load(struct config *root, char *filename, int overwrite_used, cons
} }
} else { } else {
if (((cv->flags & CONFIG_VALUE_USED) && overwrite_used) || !(cv->flags & CONFIG_VALUE_USED)) { if (((cv->flags & CONFIG_VALUE_USED) && overwrite_used) || !(cv->flags & CONFIG_VALUE_USED)) {
debug( netdata_log_debug(
D_CONFIG, "CONFIG: line %d of file '%s', overwriting '%s/%s'.", line, filename, co->name, cv->name); D_CONFIG, "CONFIG: line %d of file '%s', overwriting '%s/%s'.", line, filename, co->name, cv->name);
freez(cv->value); freez(cv->value);
cv->value = strdupz(value); cv->value = strdupz(value);
} else } else
debug( netdata_log_debug(
D_CONFIG, D_CONFIG,
"CONFIG: ignoring line %d of file '%s', '%s/%s' is already present and used.", "CONFIG: ignoring line %d of file '%s', '%s/%s' is already present and used.",
line, line,

View file

@ -1065,7 +1065,7 @@ static size_t hashtable_destroy_unsafe(DICTIONARY *dict) {
JU_ERRNO(&J_Error), JU_ERRID(&J_Error)); JU_ERRNO(&J_Error), JU_ERRID(&J_Error));
} }
debug(D_DICTIONARY, "Dictionary: hash table freed %lu bytes", ret); netdata_log_debug(D_DICTIONARY, "Dictionary: hash table freed %lu bytes", ret);
dict->index.JudyHSArray = NULL; dict->index.JudyHSArray = NULL;
return (size_t)ret; return (size_t)ret;
@ -1376,7 +1376,7 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *
if(unlikely(is_view_dictionary(dict))) if(unlikely(is_view_dictionary(dict)))
fatal("DICTIONARY: %s() should never be called on views.", __FUNCTION__ ); fatal("DICTIONARY: %s() should never be called on views.", __FUNCTION__ );
debug(D_DICTIONARY, "Dictionary entry with name '%s' found. Changing its value.", item_get_name(item)); netdata_log_debug(D_DICTIONARY, "Dictionary entry with name '%s' found. Changing its value.", item_get_name(item));
DICTIONARY_VALUE_RESETS_PLUS1(dict); DICTIONARY_VALUE_RESETS_PLUS1(dict);
@ -1388,12 +1388,12 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *
dictionary_execute_delete_callback(dict, item); dictionary_execute_delete_callback(dict, item);
if(likely(dict->options & DICT_OPTION_VALUE_LINK_DONT_CLONE)) { if(likely(dict->options & DICT_OPTION_VALUE_LINK_DONT_CLONE)) {
debug(D_DICTIONARY, "Dictionary: linking value to '%s'", item_get_name(item)); netdata_log_debug(D_DICTIONARY, "Dictionary: linking value to '%s'", item_get_name(item));
item->shared->value = value; item->shared->value = value;
item->shared->value_len = value_len; item->shared->value_len = value_len;
} }
else { else {
debug(D_DICTIONARY, "Dictionary: cloning value to '%s'", item_get_name(item)); netdata_log_debug(D_DICTIONARY, "Dictionary: cloning value to '%s'", item_get_name(item));
void *old_value = item->shared->value; void *old_value = item->shared->value;
void *new_value = NULL; void *new_value = NULL;
@ -1405,7 +1405,7 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *
item->shared->value = new_value; item->shared->value = new_value;
item->shared->value_len = value_len; item->shared->value_len = value_len;
debug(D_DICTIONARY, "Dictionary: freeing old value of '%s'", item_get_name(item)); netdata_log_debug(D_DICTIONARY, "Dictionary: freeing old value of '%s'", item_get_name(item));
dict_item_value_freez(dict, old_value); dict_item_value_freez(dict, old_value);
} }
@ -1413,7 +1413,7 @@ static void dict_item_reset_value_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *
} }
static size_t dict_item_free_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *item) { static size_t dict_item_free_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *item) {
debug(D_DICTIONARY, "Destroying name value entry for name '%s'.", item_get_name(item)); netdata_log_debug(D_DICTIONARY, "Destroying name value entry for name '%s'.", item_get_name(item));
if(!item_flag_check(item, ITEM_FLAG_DELETED)) if(!item_flag_check(item, ITEM_FLAG_DELETED))
DICTIONARY_ENTRIES_MINUS1(dict); DICTIONARY_ENTRIES_MINUS1(dict);
@ -1428,7 +1428,7 @@ static size_t dict_item_free_with_hooks(DICTIONARY *dict, DICTIONARY_ITEM *item)
dictionary_execute_delete_callback(dict, item); dictionary_execute_delete_callback(dict, item);
if(unlikely(!(dict->options & DICT_OPTION_VALUE_LINK_DONT_CLONE))) { if(unlikely(!(dict->options & DICT_OPTION_VALUE_LINK_DONT_CLONE))) {
debug(D_DICTIONARY, "Dictionary freeing value of '%s'", item_get_name(item)); netdata_log_debug(D_DICTIONARY, "Dictionary freeing value of '%s'", item_get_name(item));
dict_item_value_freez(dict, item->shared->value); dict_item_value_freez(dict, item->shared->value);
item->shared->value = NULL; item->shared->value = NULL;
} }
@ -1554,7 +1554,7 @@ static bool dict_item_del(DICTIONARY *dict, const char *name, ssize_t name_len)
if(name_len == -1) if(name_len == -1)
name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too
debug(D_DICTIONARY, "DEL dictionary entry with name '%s'.", name); netdata_log_debug(D_DICTIONARY, "DEL dictionary entry with name '%s'.", name);
// Unfortunately, the JudyHSDel() does not return the value of the // Unfortunately, the JudyHSDel() does not return the value of the
// item that was deleted, so we have to find it before we delete it, // item that was deleted, so we have to find it before we delete it,
@ -1605,7 +1605,7 @@ static DICTIONARY_ITEM *dict_item_add_or_reset_value_and_acquire(DICTIONARY *dic
if(name_len == -1) if(name_len == -1)
name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too
debug(D_DICTIONARY, "SET dictionary entry with name '%s'.", name); netdata_log_debug(D_DICTIONARY, "SET dictionary entry with name '%s'.", name);
// DISCUSSION: // DISCUSSION:
// Is it better to gain a read-lock and do a hashtable_get_unsafe() // Is it better to gain a read-lock and do a hashtable_get_unsafe()
@ -1724,7 +1724,7 @@ static DICTIONARY_ITEM *dict_item_find_and_acquire(DICTIONARY *dict, const char
if(name_len == -1) if(name_len == -1)
name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too name_len = (ssize_t)strlen(name) + 1; // we need the terminating null too
debug(D_DICTIONARY, "GET dictionary entry with name '%s'.", name); netdata_log_debug(D_DICTIONARY, "GET dictionary entry with name '%s'.", name);
dictionary_index_lock_rdlock(dict); dictionary_index_lock_rdlock(dict);

View file

@ -44,7 +44,6 @@ static int clean_kprobe_event(FILE *out, char *filename, char *father_pid, netda
int clean_kprobe_events(FILE *out, int pid, netdata_ebpf_events_t *ptr) int clean_kprobe_events(FILE *out, int pid, netdata_ebpf_events_t *ptr)
{ {
debug(D_EXIT, "Cleaning parent process events.");
char filename[FILENAME_MAX + 1]; char filename[FILENAME_MAX + 1];
snprintf(filename, FILENAME_MAX, "%s%s", NETDATA_DEBUGFS, "kprobe_events"); snprintf(filename, FILENAME_MAX, "%s%s", NETDATA_DEBUGFS, "kprobe_events");

View file

@ -11,7 +11,7 @@ SILENCERS *silencers;
*/ */
SILENCER *create_silencer(void) { SILENCER *create_silencer(void) {
SILENCER *t = callocz(1, sizeof(SILENCER)); SILENCER *t = callocz(1, sizeof(SILENCER));
debug(D_HEALTH, "HEALTH command API: Created empty silencer"); netdata_log_debug(D_HEALTH, "HEALTH command API: Created empty silencer");
return t; return t;
} }
@ -27,7 +27,7 @@ void health_silencers_add(SILENCER *silencer) {
// Add the created instance to the linked list in silencers // Add the created instance to the linked list in silencers
silencer->next = silencers->silencers; silencer->next = silencers->silencers;
silencers->silencers = silencer; silencers->silencers = silencer;
debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms, netdata_log_debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms,
silencer->charts, silencer->contexts, silencer->hosts, silencer->families silencer->charts, silencer->contexts, silencer->hosts, silencer->families
); );
} }
@ -116,7 +116,7 @@ int health_silencers_json_read_callback(JSON_ENTRY *e)
e->callback_function = health_silencers_json_read_callback; e->callback_function = health_silencers_json_read_callback;
if(strcmp(e->name,"")) { if(strcmp(e->name,"")) {
// init silencer // init silencer
debug(D_HEALTH, "JSON: Got object with a name, initializing new silencer for %s",e->name); netdata_log_debug(D_HEALTH, "JSON: Got object with a name, initializing new silencer for %s",e->name);
#endif #endif
e->callback_data = create_silencer(); e->callback_data = create_silencer();
if(e->callback_data) { if(e->callback_data) {
@ -133,18 +133,18 @@ int health_silencers_json_read_callback(JSON_ENTRY *e)
case JSON_STRING: case JSON_STRING:
if(!strcmp(e->name,"type")) { if(!strcmp(e->name,"type")) {
debug(D_HEALTH, "JSON: Processing type=%s",e->data.string); netdata_log_debug(D_HEALTH, "JSON: Processing type=%s",e->data.string);
if (!strcmp(e->data.string,"SILENCE")) silencers->stype = STYPE_SILENCE_NOTIFICATIONS; if (!strcmp(e->data.string,"SILENCE")) silencers->stype = STYPE_SILENCE_NOTIFICATIONS;
else if (!strcmp(e->data.string,"DISABLE")) silencers->stype = STYPE_DISABLE_ALARMS; else if (!strcmp(e->data.string,"DISABLE")) silencers->stype = STYPE_DISABLE_ALARMS;
} else { } else {
debug(D_HEALTH, "JSON: Adding %s=%s", e->name, e->data.string); netdata_log_debug(D_HEALTH, "JSON: Adding %s=%s", e->name, e->data.string);
if (e->callback_data) if (e->callback_data)
(void)health_silencers_addparam(e->callback_data, e->name, e->data.string); (void)health_silencers_addparam(e->callback_data, e->name, e->data.string);
} }
break; break;
case JSON_BOOLEAN: case JSON_BOOLEAN:
debug(D_HEALTH, "JSON: Processing all_alarms"); netdata_log_debug(D_HEALTH, "JSON: Processing all_alarms");
silencers->all_alarms=e->data.boolean?1:0; silencers->all_alarms=e->data.boolean?1:0;
break; break;

View file

@ -1529,7 +1529,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
char *udir = strdupz_path_subpath(user_path, subpath); char *udir = strdupz_path_subpath(user_path, subpath);
char *sdir = strdupz_path_subpath(stock_path, subpath); char *sdir = strdupz_path_subpath(stock_path, subpath);
debug(D_HEALTH, "CONFIG traversing user-config directory '%s', stock config directory '%s'", udir, sdir); netdata_log_debug(D_HEALTH, "CONFIG traversing user-config directory '%s', stock config directory '%s'", udir, sdir);
DIR *dir = opendir(udir); DIR *dir = opendir(udir);
if (!dir) { if (!dir) {
@ -1543,7 +1543,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
(de->d_name[0] == '.' && de->d_name[1] == '\0') || (de->d_name[0] == '.' && de->d_name[1] == '\0') ||
(de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0') (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')
) { ) {
debug(D_HEALTH, "CONFIG ignoring user-config directory '%s/%s'", udir, de->d_name); netdata_log_debug(D_HEALTH, "CONFIG ignoring user-config directory '%s/%s'", udir, de->d_name);
continue; continue;
} }
@ -1558,20 +1558,20 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
if(path_is_file(udir, de->d_name) && if(path_is_file(udir, de->d_name) &&
len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) { len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) {
char *filename = strdupz_path_subpath(udir, de->d_name); char *filename = strdupz_path_subpath(udir, de->d_name);
debug(D_HEALTH, "CONFIG calling callback for user file '%s'", filename); netdata_log_debug(D_HEALTH, "CONFIG calling callback for user file '%s'", filename);
callback(filename, data); callback(filename, data);
freez(filename); freez(filename);
continue; continue;
} }
} }
debug(D_HEALTH, "CONFIG ignoring user-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type); netdata_log_debug(D_HEALTH, "CONFIG ignoring user-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type);
} }
closedir(dir); closedir(dir);
} }
debug(D_HEALTH, "CONFIG traversing stock config directory '%s', user config directory '%s'", sdir, udir); netdata_log_debug(D_HEALTH, "CONFIG traversing stock config directory '%s', user config directory '%s'", sdir, udir);
dir = opendir(sdir); dir = opendir(sdir);
if (!dir) { if (!dir) {
@ -1586,7 +1586,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
(de->d_name[0] == '.' && de->d_name[1] == '\0') || (de->d_name[0] == '.' && de->d_name[1] == '\0') ||
(de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0') (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0')
) { ) {
debug(D_HEALTH, "CONFIG ignoring stock config directory '%s/%s'", sdir, de->d_name); netdata_log_debug(D_HEALTH, "CONFIG ignoring stock config directory '%s/%s'", sdir, de->d_name);
continue; continue;
} }
@ -1606,7 +1606,7 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
if(path_is_file(sdir, de->d_name) && !path_is_file(udir, de->d_name) && if(path_is_file(sdir, de->d_name) && !path_is_file(udir, de->d_name) &&
len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) { len > 5 && !strcmp(&de->d_name[len - 5], ".conf")) {
char *filename = strdupz_path_subpath(sdir, de->d_name); char *filename = strdupz_path_subpath(sdir, de->d_name);
debug(D_HEALTH, "CONFIG calling callback for stock file '%s'", filename); netdata_log_debug(D_HEALTH, "CONFIG calling callback for stock file '%s'", filename);
callback(filename, data); callback(filename, data);
freez(filename); freez(filename);
continue; continue;
@ -1614,13 +1614,13 @@ void recursive_config_double_dir_load(const char *user_path, const char *stock_p
} }
debug(D_HEALTH, "CONFIG ignoring stock-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type); netdata_log_debug(D_HEALTH, "CONFIG ignoring stock-config file '%s/%s' of type %d", udir, de->d_name, (int)de->d_type);
} }
} }
closedir(dir); closedir(dir);
} }
debug(D_HEALTH, "CONFIG done traversing user-config directory '%s', stock config directory '%s'", udir, sdir); netdata_log_debug(D_HEALTH, "CONFIG done traversing user-config directory '%s', stock config directory '%s'", udir, sdir);
freez(udir); freez(udir);
freez(sdir); freez(sdir);

View file

@ -135,29 +135,29 @@ int __netdata_mutex_unlock(netdata_mutex_t *mutex) {
int netdata_mutex_init_debug(const char *file __maybe_unused, const char *function __maybe_unused, int netdata_mutex_init_debug(const char *file __maybe_unused, const char *function __maybe_unused,
const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { const unsigned long line __maybe_unused, netdata_mutex_t *mutex) {
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) from %lu@%s, %s()", mutex, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) from %lu@%s, %s()", mutex, line, file, function);
int ret = __netdata_mutex_init(mutex); int ret = __netdata_mutex_init(mutex);
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_init(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function);
return ret; return ret;
} }
int netdata_mutex_destroy_debug(const char *file __maybe_unused, const char *function __maybe_unused, int netdata_mutex_destroy_debug(const char *file __maybe_unused, const char *function __maybe_unused,
const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { const unsigned long line __maybe_unused, netdata_mutex_t *mutex) {
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) from %lu@%s, %s()", mutex, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) from %lu@%s, %s()", mutex, line, file, function);
int ret = __netdata_mutex_destroy(mutex); int ret = __netdata_mutex_destroy(mutex);
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_destroy(%p) = %d, from %lu@%s, %s()", mutex, ret, line, file, function);
return ret; return ret;
} }
int netdata_mutex_lock_debug(const char *file __maybe_unused, const char *function __maybe_unused, int netdata_mutex_lock_debug(const char *file __maybe_unused, const char *function __maybe_unused,
const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { const unsigned long line __maybe_unused, netdata_mutex_t *mutex) {
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) from %lu@%s, %s()", mutex, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) from %lu@%s, %s()", mutex, line, file, function);
usec_t start_s = now_monotonic_high_precision_usec(); usec_t start_s = now_monotonic_high_precision_usec();
int ret = __netdata_mutex_lock(mutex); int ret = __netdata_mutex_lock(mutex);
@ -167,14 +167,14 @@ int netdata_mutex_lock_debug(const char *file __maybe_unused, const char *functi
(void)start_s; (void)start_s;
(void)end_s; (void)end_s;
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_lock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function);
return ret; return ret;
} }
int netdata_mutex_trylock_debug(const char *file __maybe_unused, const char *function __maybe_unused, int netdata_mutex_trylock_debug(const char *file __maybe_unused, const char *function __maybe_unused,
const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { const unsigned long line __maybe_unused, netdata_mutex_t *mutex) {
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) from %lu@%s, %s()", mutex, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) from %lu@%s, %s()", mutex, line, file, function);
usec_t start_s = now_monotonic_high_precision_usec(); usec_t start_s = now_monotonic_high_precision_usec();
int ret = __netdata_mutex_trylock(mutex); int ret = __netdata_mutex_trylock(mutex);
@ -184,14 +184,14 @@ int netdata_mutex_trylock_debug(const char *file __maybe_unused, const char *fun
(void)start_s; (void)start_s;
(void)end_s; (void)end_s;
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_trylock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function);
return ret; return ret;
} }
int netdata_mutex_unlock_debug(const char *file __maybe_unused, const char *function __maybe_unused, int netdata_mutex_unlock_debug(const char *file __maybe_unused, const char *function __maybe_unused,
const unsigned long line __maybe_unused, netdata_mutex_t *mutex) { const unsigned long line __maybe_unused, netdata_mutex_t *mutex) {
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) from %lu@%s, %s()", mutex, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) from %lu@%s, %s()", mutex, line, file, function);
usec_t start_s = now_monotonic_high_precision_usec(); usec_t start_s = now_monotonic_high_precision_usec();
int ret = __netdata_mutex_unlock(mutex); int ret = __netdata_mutex_unlock(mutex);
@ -201,7 +201,7 @@ int netdata_mutex_unlock_debug(const char *file __maybe_unused, const char *func
(void)start_s; (void)start_s;
(void)end_s; (void)end_s;
debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function); netdata_log_debug(D_LOCKS, "MUTEX_LOCK: netdata_mutex_unlock(%p) = %d in %llu usec, from %lu@%s, %s()", mutex, ret, end_s - start_s, line, file, function);
return ret; return ret;
} }

View file

@ -109,11 +109,11 @@ typedef struct error_with_limit {
#define error_limit_static_thread_var(var, log_every_secs, sleep_usecs) static __thread ERROR_LIMIT var = { .last_logged = 0, .count = 0, .log_every = (log_every_secs), .sleep_ut = (sleep_usecs) } #define error_limit_static_thread_var(var, log_every_secs, sleep_usecs) static __thread ERROR_LIMIT var = { .last_logged = 0, .count = 0, .log_every = (log_every_secs), .sleep_ut = (sleep_usecs) }
#ifdef NETDATA_INTERNAL_CHECKS #ifdef NETDATA_INTERNAL_CHECKS
#define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0) #define netdata_log_debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
#define internal_error(condition, args...) do { if(unlikely(condition)) error_int(0, "IERR", __FILE__, __FUNCTION__, __LINE__, ##args); } while(0) #define internal_error(condition, args...) do { if(unlikely(condition)) error_int(0, "IERR", __FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
#define internal_fatal(condition, args...) do { if(unlikely(condition)) fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0) #define internal_fatal(condition, args...) do { if(unlikely(condition)) fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
#else #else
#define debug(type, args...) debug_dummy() #define netdata_log_debug(type, args...) debug_dummy()
#define internal_error(args...) debug_dummy() #define internal_error(args...) debug_dummy()
#define internal_fatal(args...) debug_dummy() #define internal_fatal(args...) debug_dummy()
#endif #endif

View file

@ -75,7 +75,7 @@ long get_system_cpus_with_cache(bool cache, bool for_netdata) {
if(processors[index] < 1) if(processors[index] < 1)
processors[index] = 1; processors[index] = 1;
debug(D_SYSTEM, "System has %ld processors.", processors[index]); netdata_log_debug(D_SYSTEM, "System has %ld processors.", processors[index]);
return processors[index]; return processors[index];
#endif /* __APPLE__, __FreeBSD__ */ #endif /* __APPLE__, __FreeBSD__ */

View file

@ -384,7 +384,7 @@ int netdata_pclose(FILE *fp_child_input, FILE *fp_child_output, pid_t pid) {
int ret; int ret;
siginfo_t info; siginfo_t info;
debug(D_EXIT, "Request to netdata_pclose() on pid %d", pid); netdata_log_debug(D_EXIT, "Request to netdata_pclose() on pid %d", pid);
if (fp_child_input) if (fp_child_input)
fclose(fp_child_input); fclose(fp_child_input);

View file

@ -48,11 +48,11 @@ char *procfile_filename(procfile *ff) {
// An array of words // An array of words
static inline void procfile_words_add(procfile *ff, char *str) { static inline void procfile_words_add(procfile *ff, char *str) {
// debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str);
pfwords *fw = ff->words; pfwords *fw = ff->words;
if(unlikely(fw->len == fw->size)) { if(unlikely(fw->len == fw->size)) {
// debug(D_PROCFILE, PF_PREFIX ": expanding words"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding words");
size_t minimum = PFWORDS_INCREASE_STEP; size_t minimum = PFWORDS_INCREASE_STEP;
size_t optimal = fw->size / 2; size_t optimal = fw->size / 2;
size_t wanted = (optimal > minimum)?optimal:minimum; size_t wanted = (optimal > minimum)?optimal:minimum;
@ -66,7 +66,7 @@ static inline void procfile_words_add(procfile *ff, char *str) {
NEVERNULL NEVERNULL
static inline pfwords *procfile_words_create(void) { static inline pfwords *procfile_words_create(void) {
// debug(D_PROCFILE, PF_PREFIX ": initializing words"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": initializing words");
size_t size = (procfile_adaptive_initial_allocation) ? procfile_max_words : PFWORDS_INCREASE_STEP; size_t size = (procfile_adaptive_initial_allocation) ? procfile_max_words : PFWORDS_INCREASE_STEP;
@ -77,12 +77,12 @@ static inline pfwords *procfile_words_create(void) {
} }
static inline void procfile_words_reset(pfwords *fw) { static inline void procfile_words_reset(pfwords *fw) {
// debug(D_PROCFILE, PF_PREFIX ": resetting words"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting words");
fw->len = 0; fw->len = 0;
} }
static inline void procfile_words_free(pfwords *fw) { static inline void procfile_words_free(pfwords *fw) {
// debug(D_PROCFILE, PF_PREFIX ": freeing words"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": freeing words");
freez(fw); freez(fw);
} }
@ -93,11 +93,11 @@ static inline void procfile_words_free(pfwords *fw) {
NEVERNULL NEVERNULL
static inline size_t *procfile_lines_add(procfile *ff) { static inline size_t *procfile_lines_add(procfile *ff) {
// debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word);
pflines *fl = ff->lines; pflines *fl = ff->lines;
if(unlikely(fl->len == fl->size)) { if(unlikely(fl->len == fl->size)) {
// debug(D_PROCFILE, PF_PREFIX ": expanding lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding lines");
size_t minimum = PFLINES_INCREASE_STEP; size_t minimum = PFLINES_INCREASE_STEP;
size_t optimal = fl->size / 2; size_t optimal = fl->size / 2;
size_t wanted = (optimal > minimum)?optimal:minimum; size_t wanted = (optimal > minimum)?optimal:minimum;
@ -115,7 +115,7 @@ static inline size_t *procfile_lines_add(procfile *ff) {
NEVERNULL NEVERNULL
static inline pflines *procfile_lines_create(void) { static inline pflines *procfile_lines_create(void) {
// debug(D_PROCFILE, PF_PREFIX ": initializing lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": initializing lines");
size_t size = (unlikely(procfile_adaptive_initial_allocation)) ? procfile_max_words : PFLINES_INCREASE_STEP; size_t size = (unlikely(procfile_adaptive_initial_allocation)) ? procfile_max_words : PFLINES_INCREASE_STEP;
@ -126,13 +126,13 @@ static inline pflines *procfile_lines_create(void) {
} }
static inline void procfile_lines_reset(pflines *fl) { static inline void procfile_lines_reset(pflines *fl) {
// debug(D_PROCFILE, PF_PREFIX ": resetting lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting lines");
fl->len = 0; fl->len = 0;
} }
static inline void procfile_lines_free(pflines *fl) { static inline void procfile_lines_free(pflines *fl) {
// debug(D_PROCFILE, PF_PREFIX ": freeing lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": freeing lines");
freez(fl); freez(fl);
} }
@ -144,7 +144,7 @@ static inline void procfile_lines_free(pflines *fl) {
void procfile_close(procfile *ff) { void procfile_close(procfile *ff) {
if(unlikely(!ff)) return; if(unlikely(!ff)) return;
debug(D_PROCFILE, PF_PREFIX ": Closing file '%s'", procfile_filename(ff)); netdata_log_debug(D_PROCFILE, PF_PREFIX ": Closing file '%s'", procfile_filename(ff));
freez(ff->filename); freez(ff->filename);
procfile_lines_free(ff->lines); procfile_lines_free(ff->lines);
@ -156,7 +156,7 @@ void procfile_close(procfile *ff) {
NOINLINE NOINLINE
static void procfile_parser(procfile *ff) { static void procfile_parser(procfile *ff) {
// debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename);
char *s = ff->data // our current position char *s = ff->data // our current position
, *e = &ff->data[ff->len] // the terminating null , *e = &ff->data[ff->len] // the terminating null
@ -206,7 +206,7 @@ static void procfile_parser(procfile *ff) {
(*line_words)++; (*line_words)++;
t = ++s; t = ++s;
// debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words);
line_words = procfile_lines_add(ff); line_words = procfile_lines_add(ff);
} }
@ -275,7 +275,7 @@ static void procfile_parser(procfile *ff) {
} }
procfile *procfile_readall(procfile *ff) { procfile *procfile_readall(procfile *ff) {
// debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename);
ff->len = 0; // zero the used size ff->len = 0; // zero the used size
ssize_t r = 1; // read at least once ssize_t r = 1; // read at least once
@ -288,12 +288,12 @@ procfile *procfile_readall(procfile *ff) {
size_t optimal = ff->size / 2; size_t optimal = ff->size / 2;
size_t wanted = (optimal > minimum)?optimal:minimum; size_t wanted = (optimal > minimum)?optimal:minimum;
debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s' by %zu bytes.", procfile_filename(ff), wanted); netdata_log_debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s' by %zu bytes.", procfile_filename(ff), wanted);
ff = reallocz(ff, sizeof(procfile) + ff->size + wanted); ff = reallocz(ff, sizeof(procfile) + ff->size + wanted);
ff->size += wanted; ff->size += wanted;
} }
debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s)); netdata_log_debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s));
r = read(ff->fd, &ff->data[s], ff->size - s); r = read(ff->fd, &ff->data[s], ff->size - s);
if(unlikely(r == -1)) { if(unlikely(r == -1)) {
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); 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);
@ -306,7 +306,7 @@ procfile *procfile_readall(procfile *ff) {
ff->len += r; ff->len += r;
} }
// debug(D_PROCFILE, "Rewinding file '%s'", ff->filename); // netdata_log_debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);
if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) { if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) {
if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff)); if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) collector_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG)) else if(unlikely(ff->flags & PROCFILE_FLAG_ERROR_ON_ERROR_LOG))
@ -325,7 +325,7 @@ procfile *procfile_readall(procfile *ff) {
if(unlikely(ff->words->len > procfile_max_words)) procfile_max_words = ff->words->len; if(unlikely(ff->words->len > procfile_max_words)) procfile_max_words = ff->words->len;
} }
// debug(D_PROCFILE, "File '%s' updated.", ff->filename); // netdata_log_debug(D_PROCFILE, "File '%s' updated.", ff->filename);
return ff; return ff;
} }
@ -403,7 +403,7 @@ void procfile_set_open_close(procfile *ff, const char *open, const char *close)
} }
procfile *procfile_open(const char *filename, const char *separators, uint32_t flags) { procfile *procfile_open(const char *filename, const char *separators, uint32_t flags) {
debug(D_PROCFILE, PF_PREFIX ": Opening file '%s'", filename); netdata_log_debug(D_PROCFILE, PF_PREFIX ": Opening file '%s'", filename);
int fd = open(filename, procfile_open_flags, 0666); int fd = open(filename, procfile_open_flags, 0666);
if(unlikely(fd == -1)) { if(unlikely(fd == -1)) {
@ -430,7 +430,7 @@ procfile *procfile_open(const char *filename, const char *separators, uint32_t f
procfile_set_separators(ff, separators); procfile_set_separators(ff, separators);
debug(D_PROCFILE, "File '%s' opened.", filename); netdata_log_debug(D_PROCFILE, "File '%s' opened.", filename);
return ff; return ff;
} }
@ -469,17 +469,17 @@ void procfile_print(procfile *ff) {
char *s; char *s;
(void)s; (void)s;
debug(D_PROCFILE, "File '%s' with %zu lines and %zu words", procfile_filename(ff), ff->lines->len, ff->words->len); netdata_log_debug(D_PROCFILE, "File '%s' with %zu lines and %zu words", procfile_filename(ff), ff->lines->len, ff->words->len);
for(l = 0; likely(l < lines) ;l++) { for(l = 0; likely(l < lines) ;l++) {
size_t words = procfile_linewords(ff, l); size_t words = procfile_linewords(ff, l);
debug(D_PROCFILE, " line %zu starts at word %zu and has %zu words", l, ff->lines->lines[l].first, ff->lines->lines[l].words); netdata_log_debug(D_PROCFILE, " line %zu starts at word %zu and has %zu words", l, ff->lines->lines[l].first, ff->lines->lines[l].words);
size_t w; size_t w;
for(w = 0; likely(w < words) ;w++) { for(w = 0; likely(w < words) ;w++) {
s = procfile_lineword(ff, l, w); s = procfile_lineword(ff, l, w);
debug(D_PROCFILE, " [%zu.%zu] '%s'", l, w, s); netdata_log_debug(D_PROCFILE, " [%zu.%zu] '%s'", l, w, s);
} }
} }
} }

View file

@ -326,10 +326,10 @@ extern void simple_pattern_dump(uint64_t debug_type, SIMPLE_PATTERN *p)
{ {
struct simple_pattern *root = (struct simple_pattern *)p; struct simple_pattern *root = (struct simple_pattern *)p;
if(root==NULL) { if(root==NULL) {
debug(debug_type,"dump_pattern(NULL)"); netdata_log_debug(debug_type,"dump_pattern(NULL)");
return; return;
} }
debug(debug_type,"dump_pattern(%p) child=%p next=%p mode=%u match=%s", root, root->child, root->next, root->mode, netdata_log_debug(debug_type,"dump_pattern(%p) child=%p next=%p mode=%u match=%s", root, root->child, root->next, root->mode,
root->match); root->match);
if(root->child!=NULL) if(root->child!=NULL)
simple_pattern_dump(debug_type, (SIMPLE_PATTERN*)root->child); simple_pattern_dump(debug_type, (SIMPLE_PATTERN*)root->child);

View file

@ -406,7 +406,7 @@ bool netdata_ssl_accept(NETDATA_SSL *ssl) {
static void netdata_ssl_info_callback(const SSL *ssl, int where, int ret __maybe_unused) { static void netdata_ssl_info_callback(const SSL *ssl, int where, int ret __maybe_unused) {
(void)ssl; (void)ssl;
if (where & SSL_CB_ALERT) { if (where & SSL_CB_ALERT) {
debug(D_WEB_CLIENT,"SSL INFO CALLBACK %s %s", SSL_alert_type_string(ret), SSL_alert_desc_string_long(ret)); netdata_log_debug(D_WEB_CLIENT,"SSL INFO CALLBACK %s %s", SSL_alert_type_string(ret), SSL_alert_desc_string_long(ret));
} }
} }
@ -559,7 +559,7 @@ static SSL_CTX * netdata_ssl_create_server_ctx(unsigned long mode) {
#if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_095) #if (OPENSSL_VERSION_NUMBER < OPENSSL_VERSION_095)
SSL_CTX_set_verify_depth(ctx,1); SSL_CTX_set_verify_depth(ctx,1);
#endif #endif
debug(D_WEB_CLIENT,"SSL GLOBAL CONTEXT STARTED\n"); netdata_log_debug(D_WEB_CLIENT,"SSL GLOBAL CONTEXT STARTED\n");
SSL_CTX_set_mode(ctx, mode); SSL_CTX_set_mode(ctx, mode);

View file

@ -216,7 +216,7 @@ char *strdup_client_description(int family, const char *protocol, const char *ip
int create_listen_socket_unix(const char *path, int listen_backlog) { int create_listen_socket_unix(const char *path, int listen_backlog) {
int sock; int sock;
debug(D_LISTENER, "LISTENER: UNIX creating new listening socket on path '%s'", path); netdata_log_debug(D_LISTENER, "LISTENER: UNIX creating new listening socket on path '%s'", path);
sock = socket(AF_UNIX, SOCK_STREAM, 0); sock = socket(AF_UNIX, SOCK_STREAM, 0);
if(sock < 0) { if(sock < 0) {
@ -253,14 +253,14 @@ int create_listen_socket_unix(const char *path, int listen_backlog) {
return -1; return -1;
} }
debug(D_LISTENER, "LISTENER: Listening on UNIX path '%s'", path); netdata_log_debug(D_LISTENER, "LISTENER: Listening on UNIX path '%s'", path);
return sock; return sock;
} }
int create_listen_socket4(int socktype, const char *ip, uint16_t port, int listen_backlog) { int create_listen_socket4(int socktype, const char *ip, uint16_t port, int listen_backlog) {
int sock; int sock;
debug(D_LISTENER, "LISTENER: IPv4 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype); netdata_log_debug(D_LISTENER, "LISTENER: IPv4 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype);
sock = socket(AF_INET, socktype, 0); sock = socket(AF_INET, socktype, 0);
if(sock < 0) { if(sock < 0) {
@ -297,7 +297,7 @@ int create_listen_socket4(int socktype, const char *ip, uint16_t port, int liste
return -1; return -1;
} }
debug(D_LISTENER, "LISTENER: Listening on IPv4 ip '%s' port %d, socktype %d", ip, port, socktype); netdata_log_debug(D_LISTENER, "LISTENER: Listening on IPv4 ip '%s' port %d, socktype %d", ip, port, socktype);
return sock; return sock;
} }
@ -305,7 +305,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
int sock; int sock;
int ipv6only = 1; int ipv6only = 1;
debug(D_LISTENER, "LISTENER: IPv6 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype); netdata_log_debug(D_LISTENER, "LISTENER: IPv6 creating new listening socket on ip '%s' port %d, socktype %d", ip, port, socktype);
sock = socket(AF_INET6, socktype, 0); sock = socket(AF_INET6, socktype, 0);
if (sock < 0) { if (sock < 0) {
@ -349,7 +349,7 @@ int create_listen_socket6(int socktype, uint32_t scope_id, const char *ip, int p
return -1; return -1;
} }
debug(D_LISTENER, "LISTENER: Listening on IPv6 ip '%s' port %d, socktype %d", ip, port, socktype); netdata_log_debug(D_LISTENER, "LISTENER: Listening on IPv6 ip '%s' port %d, socktype %d", ip, port, socktype);
return sock; return sock;
} }
@ -603,7 +603,7 @@ static inline int bind_to_this(LISTEN_SOCKETS *sockets, const char *definition,
} }
default: default:
debug(D_LISTENER, "LISTENER: Unknown socket family %d", family); netdata_log_debug(D_LISTENER, "LISTENER: Unknown socket family %d", family);
break; break;
} }
@ -635,7 +635,7 @@ int listen_sockets_setup(LISTEN_SOCKETS *sockets) {
} }
else sockets->default_port = (uint16_t)new_port; else sockets->default_port = (uint16_t)new_port;
debug(D_OPTIONS, "LISTENER: Default listen port set to %d.", sockets->default_port); netdata_log_debug(D_OPTIONS, "LISTENER: Default listen port set to %d.", sockets->default_port);
char *s = appconfig_get(sockets->config, sockets->config_section, "bind to", sockets->default_bind_to); char *s = appconfig_get(sockets->config, sockets->config_section, "bind to", sockets->default_bind_to);
while(*s) { while(*s) {
@ -697,7 +697,7 @@ static inline int connect_to_unix(const char *path, struct timeval *timeout) {
return -1; return -1;
} }
debug(D_CONNECT_TO, "Connected to UNIX socket on path '%s'.", path); netdata_log_debug(D_CONNECT_TO, "Connected to UNIX socket on path '%s'.", path);
return fd; return fd;
} }
@ -748,7 +748,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
sizeof(servBfr), sizeof(servBfr),
NI_NUMERICHOST | NI_NUMERICSERV); NI_NUMERICHOST | NI_NUMERICSERV);
debug(D_CONNECT_TO, "Address info: host = '%s', service = '%s', ai_flags = 0x%02X, ai_family = %d (PF_INET = %d, PF_INET6 = %d), ai_socktype = %d (SOCK_STREAM = %d, SOCK_DGRAM = %d), ai_protocol = %d (IPPROTO_TCP = %d, IPPROTO_UDP = %d), ai_addrlen = %lu (sockaddr_in = %lu, sockaddr_in6 = %lu)", netdata_log_debug(D_CONNECT_TO, "Address info: host = '%s', service = '%s', ai_flags = 0x%02X, ai_family = %d (PF_INET = %d, PF_INET6 = %d), ai_socktype = %d (SOCK_STREAM = %d, SOCK_DGRAM = %d), ai_protocol = %d (IPPROTO_TCP = %d, IPPROTO_UDP = %d), ai_addrlen = %lu (sockaddr_in = %lu, sockaddr_in6 = %lu)",
hostBfr, hostBfr,
servBfr, servBfr,
(unsigned int)ai->ai_flags, (unsigned int)ai->ai_flags,
@ -770,7 +770,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
struct sockaddr_in *pSadrIn = (struct sockaddr_in *)ai->ai_addr; struct sockaddr_in *pSadrIn = (struct sockaddr_in *)ai->ai_addr;
(void)pSadrIn; (void)pSadrIn;
debug(D_CONNECT_TO, "ai_addr = sin_family: %d (AF_INET = %d, AF_INET6 = %d), sin_addr: '%s', sin_port: '%s'", netdata_log_debug(D_CONNECT_TO, "ai_addr = sin_family: %d (AF_INET = %d, AF_INET6 = %d), sin_addr: '%s', sin_port: '%s'",
pSadrIn->sin_family, pSadrIn->sin_family,
AF_INET, AF_INET,
AF_INET6, AF_INET6,
@ -783,7 +783,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
struct sockaddr_in6 *pSadrIn6 = (struct sockaddr_in6 *) ai->ai_addr; struct sockaddr_in6 *pSadrIn6 = (struct sockaddr_in6 *) ai->ai_addr;
(void)pSadrIn6; (void)pSadrIn6;
debug(D_CONNECT_TO,"ai_addr = sin6_family: %d (AF_INET = %d, AF_INET6 = %d), sin6_addr: '%s', sin6_port: '%s', sin6_flowinfo: %u, sin6_scope_id: %u", netdata_log_debug(D_CONNECT_TO,"ai_addr = sin6_family: %d (AF_INET = %d, AF_INET6 = %d), sin6_addr: '%s', sin6_port: '%s', sin6_flowinfo: %u, sin6_scope_id: %u",
pSadrIn6->sin6_family, pSadrIn6->sin6_family,
AF_INET, AF_INET,
AF_INET6, AF_INET6,
@ -795,7 +795,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
} }
default: { default: {
debug(D_CONNECT_TO, "Unknown protocol family %d.", ai->ai_family); netdata_log_debug(D_CONNECT_TO, "Unknown protocol family %d.", ai->ai_family);
continue; continue;
} }
} }
@ -854,7 +854,7 @@ int connect_to_this_ip46(int protocol, int socktype, const char *host, uint32_t
} }
if(fd != -1) if(fd != -1)
debug(D_CONNECT_TO, "Connected to '%s' on port '%s'.", hostBfr, servBfr); netdata_log_debug(D_CONNECT_TO, "Connected to '%s' on port '%s'.", hostBfr, servBfr);
} }
} }
@ -930,7 +930,7 @@ int connect_to_this(const char *definition, int default_port, struct timeval *ti
service = e; service = e;
} }
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); netdata_log_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);
if(!*host) { if(!*host) {
netdata_log_error("Definition '%s' does not specify a host.", definition); netdata_log_error("Definition '%s' does not specify a host.", definition);
@ -1189,7 +1189,7 @@ int accept4(int sock, struct sockaddr *addr, socklen_t *addrlen, int flags) {
int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsize, SIMPLE_PATTERN *access_list, int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsize, SIMPLE_PATTERN *access_list,
const char *patname, int allow_dns) const char *patname, int allow_dns)
{ {
debug(D_LISTENER,"checking %s... (allow_dns=%d)", patname, allow_dns); netdata_log_debug(D_LISTENER,"checking %s... (allow_dns=%d)", patname, allow_dns);
if (!access_list) if (!access_list)
return 1; return 1;
if (simple_pattern_matches(access_list, client_ip)) if (simple_pattern_matches(access_list, client_ip))
@ -1231,7 +1231,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi
inet_ntop(AF_INET6, &((struct sockaddr_in6*)(scan->ai_addr))->sin6_addr, address, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, &((struct sockaddr_in6*)(scan->ai_addr))->sin6_addr, address, INET6_ADDRSTRLEN);
break; break;
} }
debug(D_LISTENER, "Incoming ip %s rev-resolved onto %s, validating against forward-resolution %s", netdata_log_debug(D_LISTENER, "Incoming ip %s rev-resolved onto %s, validating against forward-resolution %s",
client_ip, client_host, address); client_ip, client_host, address);
if (!strcmp(client_ip, address)) { if (!strcmp(client_ip, address)) {
validated = 1; validated = 1;
@ -1248,7 +1248,7 @@ int connection_allowed(int fd, char *client_ip, char *client_host, size_t hostsi
freeaddrinfo(addr_infos); freeaddrinfo(addr_infos);
} }
if (!simple_pattern_matches(access_list, client_host)) { if (!simple_pattern_matches(access_list, client_host)) {
debug(D_LISTENER, "Incoming connection on '%s' (%s) does not match allowed pattern for %s", netdata_log_debug(D_LISTENER, "Incoming connection on '%s' (%s) does not match allowed pattern for %s",
client_ip, client_host, patname); client_ip, client_host, patname);
return 0; return 0;
} }
@ -1284,26 +1284,26 @@ int accept_socket(int fd, int flags, char *client_ip, size_t ipsize, char *clien
switch (((struct sockaddr *)&sadr)->sa_family) { switch (((struct sockaddr *)&sadr)->sa_family) {
case AF_UNIX: case AF_UNIX:
debug(D_LISTENER, "New UNIX domain web client from %s on socket %d.", client_ip, fd); netdata_log_debug(D_LISTENER, "New UNIX domain web client from %s on socket %d.", client_ip, fd);
// set the port - certain versions of libc return garbage on unix sockets // set the port - certain versions of libc return garbage on unix sockets
strncpyz(client_port, "UNIX", portsize); strncpyz(client_port, "UNIX", portsize);
break; break;
case AF_INET: case AF_INET:
debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd); netdata_log_debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd);
break; break;
case AF_INET6: case AF_INET6:
if (strncmp(client_ip, "::ffff:", 7) == 0) { if (strncmp(client_ip, "::ffff:", 7) == 0) {
memmove(client_ip, &client_ip[7], strlen(&client_ip[7]) + 1); memmove(client_ip, &client_ip[7], strlen(&client_ip[7]) + 1);
debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd); netdata_log_debug(D_LISTENER, "New IPv4 web client from %s port %s on socket %d.", client_ip, client_port, fd);
} }
else else
debug(D_LISTENER, "New IPv6 web client from %s port %s on socket %d.", client_ip, client_port, fd); netdata_log_debug(D_LISTENER, "New IPv6 web client from %s port %s on socket %d.", client_ip, client_port, fd);
break; break;
default: default:
debug(D_LISTENER, "New UNKNOWN web client from %s port %s on socket %d.", client_ip, client_port, fd); netdata_log_debug(D_LISTENER, "New UNKNOWN web client from %s port %s on socket %d.", client_ip, client_port, fd);
break; break;
} }
if (!connection_allowed(nfd, client_ip, client_host, hostsize, access_list, "connection", allow_dns)) { if (!connection_allowed(nfd, client_ip, client_host, hostsize, access_list, "connection", allow_dns)) {
@ -1344,7 +1344,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p
, int (*snd_callback)(POLLINFO * /*pi*/, short int * /*events*/) , int (*snd_callback)(POLLINFO * /*pi*/, short int * /*events*/)
, void *data , void *data
) { ) {
debug(D_POLLFD, "POLLFD: ADD: request to add fd %d, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", fd, p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); netdata_log_debug(D_POLLFD, "POLLFD: ADD: request to add fd %d, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", fd, p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1);
if(unlikely(fd < 0)) return NULL; if(unlikely(fd < 0)) return NULL;
@ -1356,7 +1356,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p
if(unlikely(!p->first_free)) { if(unlikely(!p->first_free)) {
size_t new_slots = p->slots + POLL_FDS_INCREASE_STEP; size_t new_slots = p->slots + POLL_FDS_INCREASE_STEP;
debug(D_POLLFD, "POLLFD: ADD: increasing size (current = %zu, new = %zu, used = %zu, min = %zu, max = %zu)", p->slots, new_slots, p->used, p->min, p->max); netdata_log_debug(D_POLLFD, "POLLFD: ADD: increasing size (current = %zu, new = %zu, used = %zu, min = %zu, max = %zu)", p->slots, new_slots, p->used, p->min, p->max);
p->fds = reallocz(p->fds, sizeof(struct pollfd) * new_slots); p->fds = reallocz(p->fds, sizeof(struct pollfd) * new_slots);
p->inf = reallocz(p->inf, sizeof(POLLINFO) * new_slots); p->inf = reallocz(p->inf, sizeof(POLLINFO) * new_slots);
@ -1364,7 +1364,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p
// reset all the newly added slots // reset all the newly added slots
ssize_t i; ssize_t i;
for(i = new_slots - 1; i >= (ssize_t)p->slots ; i--) { for(i = new_slots - 1; i >= (ssize_t)p->slots ; i--) {
debug(D_POLLFD, "POLLFD: ADD: resetting new slot %zd", i); netdata_log_debug(D_POLLFD, "POLLFD: ADD: resetting new slot %zd", i);
p->fds[i].fd = -1; p->fds[i].fd = -1;
p->fds[i].events = 0; p->fds[i].events = 0;
p->fds[i].revents = 0; p->fds[i].revents = 0;
@ -1395,7 +1395,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p
POLLINFO *pi = p->first_free; POLLINFO *pi = p->first_free;
p->first_free = p->first_free->next; p->first_free = p->first_free->next;
debug(D_POLLFD, "POLLFD: ADD: selected slot %zu, next free is %zd", pi->slot, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); netdata_log_debug(D_POLLFD, "POLLFD: ADD: selected slot %zu, next free is %zd", pi->slot, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1);
struct pollfd *pf = &p->fds[pi->slot]; struct pollfd *pf = &p->fds[pi->slot];
pf->fd = fd; pf->fd = fd;
@ -1437,7 +1437,7 @@ inline POLLINFO *poll_add_fd(POLLJOB *p
} }
netdata_thread_enable_cancelability(); netdata_thread_enable_cancelability();
debug(D_POLLFD, "POLLFD: ADD: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); netdata_log_debug(D_POLLFD, "POLLFD: ADD: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1);
return pi; return pi;
} }
@ -1446,7 +1446,7 @@ inline void poll_close_fd(POLLINFO *pi) {
POLLJOB *p = pi->p; POLLJOB *p = pi->p;
struct pollfd *pf = &p->fds[pi->slot]; struct pollfd *pf = &p->fds[pi->slot];
debug(D_POLLFD, "POLLFD: DEL: request to clear slot %zu (fd %d), old next free was %zd", pi->slot, pf->fd, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); netdata_log_debug(D_POLLFD, "POLLFD: DEL: request to clear slot %zu (fd %d), old next free was %zd", pi->slot, pf->fd, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1);
if(unlikely(pf->fd == -1)) return; if(unlikely(pf->fd == -1)) return;
@ -1499,7 +1499,7 @@ inline void poll_close_fd(POLLINFO *pi) {
} }
netdata_thread_enable_cancelability(); netdata_thread_enable_cancelability();
debug(D_POLLFD, "POLLFD: DEL: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1); netdata_log_debug(D_POLLFD, "POLLFD: DEL: completed, slots = %zu, used = %zu, min = %zu, max = %zu, next free = %zd", p->slots, p->used, p->min, p->max, p->first_free?(ssize_t)p->first_free->slot:(ssize_t)-1);
} }
void *poll_default_add_callback(POLLINFO *pi, short int *events, void *data) { void *poll_default_add_callback(POLLINFO *pi, short int *events, void *data) {
@ -1586,7 +1586,7 @@ static inline int poll_process_send(POLLJOB *p, POLLINFO *pi, struct pollfd *pf,
pi->last_sent_t = now; pi->last_sent_t = now;
pi->send_count++; pi->send_count++;
debug(D_POLLFD, "POLLFD: LISTENER: sending data to socket on slot %zu (fd %d)", pi->slot, pf->fd); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: sending data to socket on slot %zu (fd %d)", pi->slot, pf->fd);
pf->events = 0; pf->events = 0;
@ -1607,7 +1607,7 @@ static inline int poll_process_tcp_read(POLLJOB *p, POLLINFO *pi, struct pollfd
pi->last_received_t = now; pi->last_received_t = now;
pi->recv_count++; pi->recv_count++;
debug(D_POLLFD, "POLLFD: LISTENER: reading data from TCP client slot %zu (fd %d)", pi->slot, pf->fd); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: reading data from TCP client slot %zu (fd %d)", pi->slot, pf->fd);
pf->events = 0; pf->events = 0;
@ -1628,7 +1628,7 @@ static inline int poll_process_udp_read(POLLINFO *pi, struct pollfd *pf, time_t
pi->last_received_t = now; pi->last_received_t = now;
pi->recv_count++; pi->recv_count++;
debug(D_POLLFD, "POLLFD: LISTENER: reading data from UDP slot %zu (fd %d)", pi->slot, pf->fd); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: reading data from UDP slot %zu (fd %d)", pi->slot, pf->fd);
// TODO: access_list is not applied to UDP // TODO: access_list is not applied to UDP
// but checking the access list on every UDP packet will destroy // but checking the access list on every UDP packet will destroy
@ -1648,13 +1648,13 @@ static int poll_process_new_tcp_connection(POLLJOB *p, POLLINFO *pi, struct poll
pi->last_received_t = now; pi->last_received_t = now;
pi->recv_count++; pi->recv_count++;
debug(D_POLLFD, "POLLFD: LISTENER: accepting connections from slot %zu (fd %d)", pi->slot, pf->fd); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: accepting connections from slot %zu (fd %d)", pi->slot, pf->fd);
char client_ip[INET6_ADDRSTRLEN] = ""; char client_ip[INET6_ADDRSTRLEN] = "";
char client_port[NI_MAXSERV] = ""; char client_port[NI_MAXSERV] = "";
char client_host[NI_MAXHOST] = ""; char client_host[NI_MAXHOST] = "";
debug(D_POLLFD, "POLLFD: LISTENER: calling accept4() slot %zu (fd %d)", pi->slot, pf->fd); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: calling accept4() slot %zu (fd %d)", pi->slot, pf->fd);
int nfd = accept_socket( int nfd = accept_socket(
pf->fd,SOCK_NONBLOCK, pf->fd,SOCK_NONBLOCK,
@ -1665,7 +1665,7 @@ static int poll_process_new_tcp_connection(POLLJOB *p, POLLINFO *pi, struct poll
if (unlikely(nfd < 0)) { if (unlikely(nfd < 0)) {
// accept failed // accept failed
debug(D_POLLFD, "POLLFD: LISTENER: accept4() slot %zu (fd %d) failed.", pi->slot, pf->fd); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: accept4() slot %zu (fd %d) failed.", pi->slot, pf->fd);
if(unlikely(errno == EMFILE)) { if(unlikely(errno == EMFILE)) {
error_limit_static_global_var(erl, 10, 1000); error_limit_static_global_var(erl, 10, 1000);
@ -1797,7 +1797,7 @@ void poll_events(LISTEN_SOCKETS *sockets
now_usec = now_boottime_usec(); now_usec = now_boottime_usec();
if(unlikely(timer_usec && now_usec >= next_timer_usec)) { if(unlikely(timer_usec && now_usec >= next_timer_usec)) {
debug(D_POLLFD, "Calling timer callback after %zu usec", (size_t)(now_usec - last_timer_usec)); netdata_log_debug(D_POLLFD, "Calling timer callback after %zu usec", (size_t)(now_usec - last_timer_usec));
last_timer_usec = now_usec; last_timer_usec = now_usec;
p.tmr_callback(p.timer_data); p.tmr_callback(p.timer_data);
now_usec = now_boottime_usec(); now_usec = now_boottime_usec();
@ -1822,7 +1822,7 @@ void poll_events(LISTEN_SOCKETS *sockets
} }
} }
debug(D_POLLFD, "POLLFD: LISTENER: Waiting on %zu sockets for %zu ms...", p.max + 1, (size_t)timeout_ms); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: Waiting on %zu sockets for %zu ms...", p.max + 1, (size_t)timeout_ms);
retval = poll(p.fds, p.max + 1, timeout_ms); retval = poll(p.fds, p.max + 1, timeout_ms);
time_t now = now_boottime_sec(); time_t now = now_boottime_sec();
@ -1831,7 +1831,7 @@ void poll_events(LISTEN_SOCKETS *sockets
break; break;
} }
else if(unlikely(!retval)) { else if(unlikely(!retval)) {
debug(D_POLLFD, "POLLFD: LISTENER: poll() timeout."); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: poll() timeout.");
} }
else { else {
POLLINFO *pi; POLLINFO *pi;
@ -1987,5 +1987,5 @@ void poll_events(LISTEN_SOCKETS *sockets
} }
netdata_thread_cleanup_pop(1); netdata_thread_cleanup_pop(1);
debug(D_POLLFD, "POLLFD: LISTENER: cleanup completed"); netdata_log_debug(D_POLLFD, "POLLFD: LISTENER: cleanup completed");
} }

View file

@ -133,7 +133,7 @@ size_t netdata_threads_init(void) {
if(i != 0) if(i != 0)
fatal("pthread_attr_getstacksize() failed with code %d.", i); fatal("pthread_attr_getstacksize() failed with code %d.", i);
else else
debug(D_OPTIONS, "initial pthread stack size is %zu bytes", stacksize); netdata_log_debug(D_OPTIONS, "initial pthread stack size is %zu bytes", stacksize);
return stacksize; return stacksize;
} }

View file

@ -4,7 +4,7 @@
#include "registry_internals.h" #include "registry_internals.h"
int registry_db_should_be_saved(void) { int registry_db_should_be_saved(void) {
debug(D_REGISTRY, "log entries %llu, max %llu", registry.log_count, registry.save_registry_every_entries); netdata_log_debug(D_REGISTRY, "log entries %llu, max %llu", registry.log_count, registry.save_registry_every_entries);
return registry.log_count > registry.save_registry_every_entries; return registry.log_count > registry.save_registry_every_entries;
} }
@ -12,7 +12,7 @@ int registry_db_should_be_saved(void) {
// INTERNAL FUNCTIONS FOR SAVING REGISTRY OBJECTS // INTERNAL FUNCTIONS FOR SAVING REGISTRY OBJECTS
static int registry_machine_save_url(REGISTRY_MACHINE_URL *mu, FILE *fp) { static int registry_machine_save_url(REGISTRY_MACHINE_URL *mu, FILE *fp) {
debug(D_REGISTRY, "REGISTRY: registry_machine_save_url('%s')", string2str(mu->url)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_save_url('%s')", string2str(mu->url));
int ret = fprintf(fp, "V\t%08x\t%08x\t%08x\t%02x\t%s\n", int ret = fprintf(fp, "V\t%08x\t%08x\t%08x\t%02x\t%s\n",
mu->first_t, mu->first_t,
@ -32,7 +32,7 @@ static int registry_machine_save(const DICTIONARY_ITEM *item __maybe_unused, voi
REGISTRY_MACHINE *m = entry; REGISTRY_MACHINE *m = entry;
FILE *fp = file; FILE *fp = file;
debug(D_REGISTRY, "REGISTRY: registry_machine_save('%s')", m->guid); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_save('%s')", m->guid);
int ret = fprintf(fp, "M\t%08x\t%08x\t%08x\t%s\n", int ret = fprintf(fp, "M\t%08x\t%08x\t%08x\t%s\n",
m->first_t, m->first_t,
@ -57,7 +57,7 @@ static int registry_machine_save(const DICTIONARY_ITEM *item __maybe_unused, voi
} }
static inline int registry_person_save_url(REGISTRY_PERSON_URL *pu, FILE *fp) { static inline int registry_person_save_url(REGISTRY_PERSON_URL *pu, FILE *fp) {
debug(D_REGISTRY, "REGISTRY: registry_person_save_url('%s')", string2str(pu->url)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_person_save_url('%s')", string2str(pu->url));
int ret = fprintf(fp, "U\t%08x\t%08x\t%08x\t%02x\t%s\t%s\t%s\n", int ret = fprintf(fp, "U\t%08x\t%08x\t%08x\t%02x\t%s\t%s\t%s\n",
pu->first_t, pu->first_t,
@ -78,7 +78,7 @@ static inline int registry_person_save(const DICTIONARY_ITEM *item __maybe_unuse
REGISTRY_PERSON *p = entry; REGISTRY_PERSON *p = entry;
FILE *fp = file; FILE *fp = file;
debug(D_REGISTRY, "REGISTRY: registry_person_save('%s')", p->guid); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_person_save('%s')", p->guid);
int ret = fprintf(fp, "P\t%08x\t%08x\t%08x\t%s\n", int ret = fprintf(fp, "P\t%08x\t%08x\t%08x\t%s\n",
p->first_t, p->first_t,
@ -120,7 +120,7 @@ int registry_db_save(void) {
snprintfz(old_filename, FILENAME_MAX, "%s.old", registry.db_filename); snprintfz(old_filename, FILENAME_MAX, "%s.old", registry.db_filename);
snprintfz(tmp_filename, FILENAME_MAX, "%s.tmp", registry.db_filename); snprintfz(tmp_filename, FILENAME_MAX, "%s.tmp", registry.db_filename);
debug(D_REGISTRY, "REGISTRY: Creating file '%s'", tmp_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: Creating file '%s'", tmp_filename);
FILE *fp = fopen(tmp_filename, "w"); FILE *fp = fopen(tmp_filename, "w");
if(!fp) { if(!fp) {
netdata_log_error("REGISTRY: Cannot create file: %s", tmp_filename); netdata_log_error("REGISTRY: Cannot create file: %s", tmp_filename);
@ -130,7 +130,7 @@ int registry_db_save(void) {
// dictionary_walkthrough_read() has its own locking, so this is safe to do // dictionary_walkthrough_read() has its own locking, so this is safe to do
debug(D_REGISTRY, "REGISTRY: saving all machines"); netdata_log_debug(D_REGISTRY, "REGISTRY: saving all machines");
int bytes1 = dictionary_walkthrough_read(registry.machines, registry_machine_save, fp); int bytes1 = dictionary_walkthrough_read(registry.machines, registry_machine_save, fp);
if(bytes1 < 0) { if(bytes1 < 0) {
netdata_log_error("REGISTRY: Cannot save registry machines - return value %d", bytes1); netdata_log_error("REGISTRY: Cannot save registry machines - return value %d", bytes1);
@ -138,9 +138,9 @@ int registry_db_save(void) {
error_log_limit_reset(); error_log_limit_reset();
return bytes1; return bytes1;
} }
debug(D_REGISTRY, "REGISTRY: saving machines took %d bytes", bytes1); netdata_log_debug(D_REGISTRY, "REGISTRY: saving machines took %d bytes", bytes1);
debug(D_REGISTRY, "Saving all persons"); netdata_log_debug(D_REGISTRY, "Saving all persons");
int bytes2 = dictionary_walkthrough_read(registry.persons, registry_person_save, fp); int bytes2 = dictionary_walkthrough_read(registry.persons, registry_person_save, fp);
if(bytes2 < 0) { if(bytes2 < 0) {
netdata_log_error("REGISTRY: Cannot save registry persons - return value %d", bytes2); netdata_log_error("REGISTRY: Cannot save registry persons - return value %d", bytes2);
@ -148,7 +148,7 @@ int registry_db_save(void) {
error_log_limit_reset(); error_log_limit_reset();
return bytes2; return bytes2;
} }
debug(D_REGISTRY, "REGISTRY: saving persons took %d bytes", bytes2); netdata_log_debug(D_REGISTRY, "REGISTRY: saving persons took %d bytes", bytes2);
// save the totals // save the totals
fprintf(fp, "T\t%016llx\t%016llx\t%016llx\t%016llx\t%016llx\t%016llx\n", fprintf(fp, "T\t%016llx\t%016llx\t%016llx\t%016llx\t%016llx\t%016llx\n",
@ -165,34 +165,34 @@ int registry_db_save(void) {
errno = 0; errno = 0;
// remove the .old db // remove the .old db
debug(D_REGISTRY, "REGISTRY: Removing old db '%s'", old_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: Removing old db '%s'", old_filename);
if(unlink(old_filename) == -1 && errno != ENOENT) if(unlink(old_filename) == -1 && errno != ENOENT)
netdata_log_error("REGISTRY: cannot remove old registry file '%s'", old_filename); netdata_log_error("REGISTRY: cannot remove old registry file '%s'", old_filename);
// rename the db to .old // rename the db to .old
debug(D_REGISTRY, "REGISTRY: Link current db '%s' to .old: '%s'", registry.db_filename, old_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: Link current db '%s' to .old: '%s'", registry.db_filename, old_filename);
if(link(registry.db_filename, old_filename) == -1 && errno != ENOENT) if(link(registry.db_filename, old_filename) == -1 && errno != ENOENT)
netdata_log_error("REGISTRY: cannot move file '%s' to '%s'. Saving registry DB failed!", registry.db_filename, old_filename); netdata_log_error("REGISTRY: cannot move file '%s' to '%s'. Saving registry DB failed!", registry.db_filename, old_filename);
else { else {
// remove the database (it is saved in .old) // remove the database (it is saved in .old)
debug(D_REGISTRY, "REGISTRY: removing db '%s'", registry.db_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: removing db '%s'", registry.db_filename);
if (unlink(registry.db_filename) == -1 && errno != ENOENT) if (unlink(registry.db_filename) == -1 && errno != ENOENT)
netdata_log_error("REGISTRY: cannot remove old registry file '%s'", registry.db_filename); netdata_log_error("REGISTRY: cannot remove old registry file '%s'", registry.db_filename);
// move the .tmp to make it active // move the .tmp to make it active
debug(D_REGISTRY, "REGISTRY: linking tmp db '%s' to active db '%s'", tmp_filename, registry.db_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: linking tmp db '%s' to active db '%s'", tmp_filename, registry.db_filename);
if (link(tmp_filename, registry.db_filename) == -1) { if (link(tmp_filename, registry.db_filename) == -1) {
netdata_log_error("REGISTRY: cannot move file '%s' to '%s'. Saving registry DB failed!", tmp_filename, netdata_log_error("REGISTRY: cannot move file '%s' to '%s'. Saving registry DB failed!", tmp_filename,
registry.db_filename); registry.db_filename);
// move the .old back // move the .old back
debug(D_REGISTRY, "REGISTRY: linking old db '%s' to active db '%s'", old_filename, registry.db_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: linking old db '%s' to active db '%s'", old_filename, registry.db_filename);
if(link(old_filename, registry.db_filename) == -1) if(link(old_filename, registry.db_filename) == -1)
netdata_log_error("REGISTRY: cannot move file '%s' to '%s'. Recovering the old registry DB failed!", old_filename, registry.db_filename); netdata_log_error("REGISTRY: cannot move file '%s' to '%s'. Recovering the old registry DB failed!", old_filename, registry.db_filename);
} }
else { else {
debug(D_REGISTRY, "REGISTRY: removing tmp db '%s'", tmp_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: removing tmp db '%s'", tmp_filename);
if(unlink(tmp_filename) == -1) if(unlink(tmp_filename) == -1)
netdata_log_error("REGISTRY: cannot remove tmp registry file '%s'", tmp_filename); netdata_log_error("REGISTRY: cannot remove tmp registry file '%s'", tmp_filename);
@ -219,7 +219,7 @@ size_t registry_db_load(void) {
STRING *u = NULL; STRING *u = NULL;
size_t line = 0; size_t line = 0;
debug(D_REGISTRY, "REGISTRY: loading active db from: '%s'", registry.db_filename); netdata_log_debug(D_REGISTRY, "REGISTRY: loading active db from: '%s'", registry.db_filename);
FILE *fp = fopen(registry.db_filename, "r"); FILE *fp = fopen(registry.db_filename, "r");
if(!fp) { if(!fp) {
netdata_log_error("REGISTRY: cannot open registry file: '%s'", registry.db_filename); netdata_log_error("REGISTRY: cannot open registry file: '%s'", registry.db_filename);
@ -232,7 +232,7 @@ size_t registry_db_load(void) {
while((s = fgets_trim_len(buf, 4096, fp, &len))) { while((s = fgets_trim_len(buf, 4096, fp, &len))) {
line++; line++;
debug(D_REGISTRY, "REGISTRY: read line %zu to length %zu: %s", line, len, s); netdata_log_debug(D_REGISTRY, "REGISTRY: read line %zu to length %zu: %s", line, len, s);
switch(*s) { switch(*s) {
case 'U': // person URL case 'U': // person URL
if(unlikely(!p)) { if(unlikely(!p)) {
@ -284,7 +284,7 @@ size_t registry_db_load(void) {
pu->last_t = (uint32_t)strtoul(&s[11], NULL, 16); pu->last_t = (uint32_t)strtoul(&s[11], NULL, 16);
pu->usages = (uint32_t)strtoul(&s[20], NULL, 16); pu->usages = (uint32_t)strtoul(&s[20], NULL, 16);
pu->flags = (uint8_t)strtoul(&s[29], NULL, 16); pu->flags = (uint8_t)strtoul(&s[29], NULL, 16);
debug(D_REGISTRY, "REGISTRY: loaded person URL '%s' with name '%s' of machine '%s', first: %u, last: %u, usages: %u, flags: %02x", netdata_log_debug(D_REGISTRY, "REGISTRY: loaded person URL '%s' with name '%s' of machine '%s', first: %u, last: %u, usages: %u, flags: %02x",
string2str(u), string2str(pu->machine_name), m->guid, pu->first_t, pu->last_t, pu->usages, pu->flags); string2str(u), string2str(pu->machine_name), m->guid, pu->first_t, pu->last_t, pu->usages, pu->flags);
string_freez(u); string_freez(u);
@ -302,7 +302,7 @@ size_t registry_db_load(void) {
p = registry_person_allocate(&s[29], (time_t)strtoul(&s[2], NULL, 16)); p = registry_person_allocate(&s[29], (time_t)strtoul(&s[2], NULL, 16));
p->last_t = (uint32_t)strtoul(&s[11], NULL, 16); p->last_t = (uint32_t)strtoul(&s[11], NULL, 16);
p->usages = (uint32_t)strtoul(&s[20], NULL, 16); p->usages = (uint32_t)strtoul(&s[20], NULL, 16);
debug(D_REGISTRY, "REGISTRY: loaded person '%s', first: %u, last: %u, usages: %u", p->guid, p->first_t, p->last_t, p->usages); netdata_log_debug(D_REGISTRY, "REGISTRY: loaded person '%s', first: %u, last: %u, usages: %u", p->guid, p->first_t, p->last_t, p->usages);
break; break;
case 'V': // machine URL case 'V': // machine URL
@ -336,7 +336,7 @@ size_t registry_db_load(void) {
mu->last_t = (uint32_t)strtoul(&s[11], NULL, 16); mu->last_t = (uint32_t)strtoul(&s[11], NULL, 16);
mu->usages = (uint32_t)strtoul(&s[20], NULL, 16); mu->usages = (uint32_t)strtoul(&s[20], NULL, 16);
mu->flags = (uint8_t)strtoul(&s[29], NULL, 16); mu->flags = (uint8_t)strtoul(&s[29], NULL, 16);
debug(D_REGISTRY, "Registry loaded machine URL '%s', machine '%s', first: %u, last: %u, usages: %u, flags: %02x", netdata_log_debug(D_REGISTRY, "Registry loaded machine URL '%s', machine '%s', first: %u, last: %u, usages: %u, flags: %02x",
string2str(u), m->guid, mu->first_t, mu->last_t, mu->usages, mu->flags); string2str(u), m->guid, mu->first_t, mu->last_t, mu->usages, mu->flags);
string_freez(u); string_freez(u);
@ -354,7 +354,7 @@ size_t registry_db_load(void) {
m = registry_machine_allocate(&s[29], (time_t)strtoul(&s[2], NULL, 16)); m = registry_machine_allocate(&s[29], (time_t)strtoul(&s[2], NULL, 16));
m->last_t = (uint32_t)strtoul(&s[11], NULL, 16); m->last_t = (uint32_t)strtoul(&s[11], NULL, 16);
m->usages = (uint32_t)strtoul(&s[20], NULL, 16); m->usages = (uint32_t)strtoul(&s[20], NULL, 16);
debug(D_REGISTRY, "REGISTRY: loaded machine '%s', first: %u, last: %u, usages: %u", m->guid, m->first_t, m->last_t, m->usages); netdata_log_debug(D_REGISTRY, "REGISTRY: loaded machine '%s', first: %u, last: %u, usages: %u", m->guid, m->first_t, m->last_t, m->usages);
break; break;
case 'T': // totals case 'T': // totals

View file

@ -210,7 +210,7 @@ static int machine_delete_callback(const DICTIONARY_ITEM *item __maybe_unused, v
static int registry_person_del_callback(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *d __maybe_unused) { static int registry_person_del_callback(const DICTIONARY_ITEM *item __maybe_unused, void *entry, void *d __maybe_unused) {
REGISTRY_PERSON *p = (REGISTRY_PERSON *)entry; REGISTRY_PERSON *p = (REGISTRY_PERSON *)entry;
debug(D_REGISTRY, "Registry: registry_person_del('%s'): deleting person", p->guid); netdata_log_debug(D_REGISTRY, "Registry: registry_person_del('%s'): deleting person", p->guid);
while(p->person_urls) while(p->person_urls)
registry_person_unlink_from_url(p, (REGISTRY_PERSON_URL *)p->person_urls); registry_person_unlink_from_url(p, (REGISTRY_PERSON_URL *)p->person_urls);
@ -218,7 +218,7 @@ static int registry_person_del_callback(const DICTIONARY_ITEM *item __maybe_unus
//debug(D_REGISTRY, "Registry: deleting person '%s' from persons registry", p->guid); //debug(D_REGISTRY, "Registry: deleting person '%s' from persons registry", p->guid);
//dictionary_del(registry.persons, p->guid); //dictionary_del(registry.persons, p->guid);
debug(D_REGISTRY, "Registry: freeing person '%s'", p->guid); netdata_log_debug(D_REGISTRY, "Registry: freeing person '%s'", p->guid);
freez(p); freez(p);
return 1; return 1;
@ -227,12 +227,12 @@ static int registry_person_del_callback(const DICTIONARY_ITEM *item __maybe_unus
void registry_free(void) { void registry_free(void) {
if(!registry.enabled) return; if(!registry.enabled) return;
debug(D_REGISTRY, "Registry: destroying persons dictionary"); netdata_log_debug(D_REGISTRY, "Registry: destroying persons dictionary");
dictionary_walkthrough_read(registry.persons, registry_person_del_callback, NULL); dictionary_walkthrough_read(registry.persons, registry_person_del_callback, NULL);
dictionary_destroy(registry.persons); dictionary_destroy(registry.persons);
registry.persons = NULL; registry.persons = NULL;
debug(D_REGISTRY, "Registry: destroying machines dictionary"); netdata_log_debug(D_REGISTRY, "Registry: destroying machines dictionary");
dictionary_walkthrough_read(registry.machines, machine_delete_callback, NULL); dictionary_walkthrough_read(registry.machines, machine_delete_callback, NULL);
dictionary_destroy(registry.machines); dictionary_destroy(registry.machines);
registry.machines = NULL; registry.machines = NULL;

View file

@ -142,7 +142,7 @@ REGISTRY_PERSON_URL *registry_verify_request(const char *person_guid, char *mach
// REGISTRY REQUESTS // REGISTRY REQUESTS
REGISTRY_PERSON *registry_request_access(const char *person_guid, char *machine_guid, char *url, char *name, time_t when) { REGISTRY_PERSON *registry_request_access(const char *person_guid, char *machine_guid, char *url, char *name, time_t when) {
debug(D_REGISTRY, "registry_request_access('%s', '%s', '%s'): NEW REQUEST", (person_guid)?person_guid:"", machine_guid, url); netdata_log_debug(D_REGISTRY, "registry_request_access('%s', '%s', '%s'): NEW REQUEST", (person_guid)?person_guid:"", machine_guid, url);
bool is_dummy = is_dummy_person(person_guid); bool is_dummy = is_dummy_person(person_guid);

View file

@ -70,7 +70,7 @@ ssize_t registry_log_load(void) {
// otherwise we will append to it the values we read // otherwise we will append to it the values we read
registry_log_close(); registry_log_close();
debug(D_REGISTRY, "Registry: loading active db from: %s", registry.log_filename); netdata_log_debug(D_REGISTRY, "Registry: loading active db from: %s", registry.log_filename);
FILE *fp = fopen(registry.log_filename, "r"); FILE *fp = fopen(registry.log_filename, "r");
if(!fp) if(!fp)
netdata_log_error("Registry: cannot open registry file: %s", registry.log_filename); netdata_log_error("Registry: cannot open registry file: %s", registry.log_filename);

View file

@ -7,7 +7,7 @@
// MACHINE // MACHINE
REGISTRY_MACHINE *registry_machine_find(const char *machine_guid) { REGISTRY_MACHINE *registry_machine_find(const char *machine_guid) {
debug(D_REGISTRY, "REGISTRY: registry_machine_find('%s')", machine_guid); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_find('%s')", machine_guid);
return dictionary_get(registry.machines, machine_guid); return dictionary_get(registry.machines, machine_guid);
} }
@ -28,7 +28,7 @@ void registry_machine_url_unlink_from_machine_and_free(REGISTRY_MACHINE *m, REGI
} }
REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, STRING *u, time_t when) { REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, STRING *u, time_t when) {
debug(D_REGISTRY, "REGISTRY: registry_machine_url_allocate('%s', '%s'): allocating %zu bytes", m->guid, string2str(u), sizeof(REGISTRY_MACHINE_URL)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_url_allocate('%s', '%s'): allocating %zu bytes", m->guid, string2str(u), sizeof(REGISTRY_MACHINE_URL));
REGISTRY_MACHINE_URL *mu = aral_mallocz(registry.machine_urls_aral); REGISTRY_MACHINE_URL *mu = aral_mallocz(registry.machine_urls_aral);
@ -37,7 +37,7 @@ REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, STRING
mu->url = string_dup(u); mu->url = string_dup(u);
mu->flags = REGISTRY_URL_FLAGS_DEFAULT; mu->flags = REGISTRY_URL_FLAGS_DEFAULT;
debug(D_REGISTRY, "REGISTRY: registry_machine_url_allocate('%s', '%s'): indexing URL in machine", m->guid, string2str(u)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_url_allocate('%s', '%s'): indexing URL in machine", m->guid, string2str(u));
DOUBLE_LINKED_LIST_PREPEND_ITEM_UNSAFE(m->machine_urls, mu, prev, next); DOUBLE_LINKED_LIST_PREPEND_ITEM_UNSAFE(m->machine_urls, mu, prev, next);
@ -45,7 +45,7 @@ REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, STRING
} }
REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t when) { REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t when) {
debug(D_REGISTRY, "REGISTRY: registry_machine_allocate('%s'): creating new machine, sizeof(MACHINE)=%zu", machine_guid, sizeof(REGISTRY_MACHINE)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_allocate('%s'): creating new machine, sizeof(MACHINE)=%zu", machine_guid, sizeof(REGISTRY_MACHINE));
REGISTRY_MACHINE *m = aral_mallocz(registry.machines_aral); REGISTRY_MACHINE *m = aral_mallocz(registry.machines_aral);
@ -89,16 +89,16 @@ REGISTRY_MACHINE *registry_machine_find_or_create(const char *machine_guid, time
// LINKING OF OBJECTS // LINKING OF OBJECTS
REGISTRY_MACHINE_URL *registry_machine_link_to_url(REGISTRY_MACHINE *m, STRING *url, time_t when) { REGISTRY_MACHINE_URL *registry_machine_link_to_url(REGISTRY_MACHINE *m, STRING *url, time_t when) {
debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): searching for URL in machine", m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): searching for URL in machine", m->guid, string2str(url));
REGISTRY_MACHINE_URL *mu = registry_machine_url_find(m, url); REGISTRY_MACHINE_URL *mu = registry_machine_url_find(m, url);
if(!mu) { if(!mu) {
debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): not found", m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): not found", m->guid, string2str(url));
mu = registry_machine_url_allocate(m, url, when); mu = registry_machine_url_allocate(m, url, when);
registry.machines_urls_count++; registry.machines_urls_count++;
} }
else { else {
debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): found", m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): found", m->guid, string2str(url));
mu->usages++; mu->usages++;
if(likely(mu->last_t < (uint32_t)when)) mu->last_t = (uint32_t)when; if(likely(mu->last_t < (uint32_t)when)) mu->last_t = (uint32_t)when;
} }
@ -107,7 +107,7 @@ REGISTRY_MACHINE_URL *registry_machine_link_to_url(REGISTRY_MACHINE *m, STRING *
if(likely(m->last_t < (uint32_t)when)) m->last_t = (uint32_t)when; if(likely(m->last_t < (uint32_t)when)) m->last_t = (uint32_t)when;
if(mu->flags & REGISTRY_URL_FLAGS_EXPIRED) { if(mu->flags & REGISTRY_URL_FLAGS_EXPIRED) {
debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): accessing an expired URL.", m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "REGISTRY: registry_machine_link_to_url('%s', '%s'): accessing an expired URL.", m->guid, string2str(url));
mu->flags &= ~REGISTRY_URL_FLAGS_EXPIRED; mu->flags &= ~REGISTRY_URL_FLAGS_EXPIRED;
} }

View file

@ -7,7 +7,7 @@
// PERSON_URL INDEX // PERSON_URL INDEX
inline REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, STRING *url) { inline REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, STRING *url) {
debug(D_REGISTRY, "Registry: registry_person_url_index_find('%s', '%s')", p->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "Registry: registry_person_url_index_find('%s', '%s')", p->guid, string2str(url));
REGISTRY_PERSON_URL *pu; REGISTRY_PERSON_URL *pu;
for(pu = p->person_urls ; pu ;pu = pu->next) for(pu = p->person_urls ; pu ;pu = pu->next)
@ -31,7 +31,7 @@ inline REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, RE
// PERSON_URL // PERSON_URL
REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when) { REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when) {
debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): allocating %zu bytes", p->guid, m->guid, string2str(url), sizeof(REGISTRY_PERSON_URL) + machine_name_len); netdata_log_debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): allocating %zu bytes", p->guid, m->guid, string2str(url), sizeof(REGISTRY_PERSON_URL) + machine_name_len);
// protection from too big names // protection from too big names
if(machine_name_len > registry.max_name_length) if(machine_name_len > registry.max_name_length)
@ -50,7 +50,7 @@ REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_M
pu->flags = REGISTRY_URL_FLAGS_DEFAULT; pu->flags = REGISTRY_URL_FLAGS_DEFAULT;
m->links++; m->links++;
debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): indexing URL in person", p->guid, m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): indexing URL in person", p->guid, m->guid, string2str(url));
REGISTRY_PERSON_URL *tpu = registry_person_url_index_add(p, pu); REGISTRY_PERSON_URL *tpu = registry_person_url_index_add(p, pu);
if(tpu != pu) { if(tpu != pu) {
netdata_log_error("Registry: Attempted to add duplicate person url '%s' with name '%s' to person '%s'", string2str(url), machine_name, p->guid); netdata_log_error("Registry: Attempted to add duplicate person url '%s' with name '%s' to person '%s'", string2str(url), machine_name, p->guid);
@ -64,7 +64,7 @@ REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_M
} }
void registry_person_url_deindex_and_free(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) { void registry_person_url_deindex_and_free(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) {
debug(D_REGISTRY, "registry_person_url_deindex_and_free('%s', '%s')", p->guid, string2str(pu->url)); netdata_log_debug(D_REGISTRY, "registry_person_url_deindex_and_free('%s', '%s')", p->guid, string2str(pu->url));
REGISTRY_PERSON_URL *tpu = registry_person_url_index_del(p, pu); REGISTRY_PERSON_URL *tpu = registry_person_url_index_del(p, pu);
if(tpu) { if(tpu) {
@ -77,7 +77,7 @@ void registry_person_url_deindex_and_free(REGISTRY_PERSON *p, REGISTRY_PERSON_UR
// this function is needed to change the name of a PERSON_URL // this function is needed to change the name of a PERSON_URL
REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when, REGISTRY_PERSON_URL *pu) { REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when, REGISTRY_PERSON_URL *pu) {
debug(D_REGISTRY, "registry_person_url_reallocate('%s', '%s', '%s'): allocating %zu bytes", p->guid, m->guid, string2str(url), sizeof(REGISTRY_PERSON_URL) + machine_name_len); netdata_log_debug(D_REGISTRY, "registry_person_url_reallocate('%s', '%s', '%s'): allocating %zu bytes", p->guid, m->guid, string2str(url), sizeof(REGISTRY_PERSON_URL) + machine_name_len);
// keep a backup // keep a backup
REGISTRY_PERSON_URL pu2 = { REGISTRY_PERSON_URL pu2 = {
@ -108,12 +108,12 @@ REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY
// PERSON // PERSON
REGISTRY_PERSON *registry_person_find(const char *person_guid) { REGISTRY_PERSON *registry_person_find(const char *person_guid) {
debug(D_REGISTRY, "Registry: registry_person_find('%s')", person_guid); netdata_log_debug(D_REGISTRY, "Registry: registry_person_find('%s')", person_guid);
return dictionary_get(registry.persons, person_guid); return dictionary_get(registry.persons, person_guid);
} }
REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when) { REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when) {
debug(D_REGISTRY, "Registry: registry_person_allocate('%s'): allocating new person, sizeof(PERSON)=%zu", (person_guid)?person_guid:"", sizeof(REGISTRY_PERSON)); netdata_log_debug(D_REGISTRY, "Registry: registry_person_allocate('%s'): allocating new person, sizeof(PERSON)=%zu", (person_guid)?person_guid:"", sizeof(REGISTRY_PERSON));
REGISTRY_PERSON *p = aral_mallocz(registry.persons_aral); REGISTRY_PERSON *p = aral_mallocz(registry.persons_aral);
if(!person_guid) { if(!person_guid) {
@ -122,9 +122,9 @@ REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when)
uuid_generate(uuid); uuid_generate(uuid);
uuid_unparse_lower(uuid, p->guid); uuid_unparse_lower(uuid, p->guid);
debug(D_REGISTRY, "Registry: Checking if the generated person guid '%s' is unique", p->guid); netdata_log_debug(D_REGISTRY, "Registry: Checking if the generated person guid '%s' is unique", p->guid);
if (!dictionary_get(registry.persons, p->guid)) { if (!dictionary_get(registry.persons, p->guid)) {
debug(D_REGISTRY, "Registry: generated person guid '%s' is unique", p->guid); netdata_log_debug(D_REGISTRY, "Registry: generated person guid '%s' is unique", p->guid);
break; break;
} }
else else
@ -151,7 +151,7 @@ REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when)
// 3. if it is not valid, create a new one // 3. if it is not valid, create a new one
// 4. return it // 4. return it
REGISTRY_PERSON *registry_person_find_or_create(const char *person_guid, time_t when, bool is_dummy) { REGISTRY_PERSON *registry_person_find_or_create(const char *person_guid, time_t when, bool is_dummy) {
debug(D_REGISTRY, "Registry: registry_person_find_or_create('%s'): creating dictionary of urls", person_guid); netdata_log_debug(D_REGISTRY, "Registry: registry_person_find_or_create('%s'): creating dictionary of urls", person_guid);
char buf[GUID_LEN + 1]; char buf[GUID_LEN + 1];
REGISTRY_PERSON *p = NULL; REGISTRY_PERSON *p = NULL;
@ -181,28 +181,28 @@ REGISTRY_PERSON *registry_person_find_or_create(const char *person_guid, time_t
// LINKING OF OBJECTS // LINKING OF OBJECTS
REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when) { REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when) {
debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): searching for URL in person", p->guid, m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): searching for URL in person", p->guid, m->guid, string2str(url));
REGISTRY_PERSON_URL *pu = registry_person_url_index_find(p, url); REGISTRY_PERSON_URL *pu = registry_person_url_index_find(p, url);
if(!pu) { if(!pu) {
debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): not found", p->guid, m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): not found", p->guid, m->guid, string2str(url));
pu = registry_person_url_allocate(p, m, url, machine_name, machine_name_len, when); pu = registry_person_url_allocate(p, m, url, machine_name, machine_name_len, when);
registry.persons_urls_count++; registry.persons_urls_count++;
} }
else { else {
debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): found", p->guid, m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): found", p->guid, m->guid, string2str(url));
pu->usages++; pu->usages++;
if(likely(pu->last_t < (uint32_t)when)) pu->last_t = (uint32_t)when; if(likely(pu->last_t < (uint32_t)when)) pu->last_t = (uint32_t)when;
if(pu->machine != m) { if(pu->machine != m) {
REGISTRY_MACHINE_URL *mu = registry_machine_url_find(pu->machine, url); REGISTRY_MACHINE_URL *mu = registry_machine_url_find(pu->machine, url);
if(mu) { if(mu) {
debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): URL switched machines (old was '%s') - expiring it from previous machine.", netdata_log_debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): URL switched machines (old was '%s') - expiring it from previous machine.",
p->guid, m->guid, string2str(url), pu->machine->guid); p->guid, m->guid, string2str(url), pu->machine->guid);
mu->flags |= REGISTRY_URL_FLAGS_EXPIRED; mu->flags |= REGISTRY_URL_FLAGS_EXPIRED;
} }
else { else {
debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): URL switched machines (old was '%s') - but the URL is not linked to the old machine.", netdata_log_debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): URL switched machines (old was '%s') - but the URL is not linked to the old machine.",
p->guid, m->guid, string2str(url), pu->machine->guid); p->guid, m->guid, string2str(url), pu->machine->guid);
} }
@ -220,7 +220,7 @@ REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MA
if(likely(p->last_t < (uint32_t)when)) p->last_t = (uint32_t)when; if(likely(p->last_t < (uint32_t)when)) p->last_t = (uint32_t)when;
if(pu->flags & REGISTRY_URL_FLAGS_EXPIRED) { if(pu->flags & REGISTRY_URL_FLAGS_EXPIRED) {
debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): accessing an expired URL. Re-enabling URL.", p->guid, m->guid, string2str(url)); netdata_log_debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): accessing an expired URL. Re-enabling URL.", p->guid, m->guid, string2str(url));
pu->flags &= ~REGISTRY_URL_FLAGS_EXPIRED; pu->flags &= ~REGISTRY_URL_FLAGS_EXPIRED;
} }

View file

@ -96,7 +96,7 @@ size_t rrdpush_compress(struct compressor_state *state, const char *data, size_t
uint32_t len = ((compressed_data_size & 0x7f) | 0x80 | (((compressed_data_size & (0x7f << 7)) << 1) | 0x8000)) << 8; uint32_t len = ((compressed_data_size & 0x7f) | 0x80 | (((compressed_data_size & (0x7f << 7)) << 1) | 0x8000)) << 8;
*(uint32_t *)state->compression_result_buffer = len | RRDPUSH_COMPRESSION_SIGNATURE; *(uint32_t *)state->compression_result_buffer = len | RRDPUSH_COMPRESSION_SIGNATURE;
*out = state->compression_result_buffer; *out = state->compression_result_buffer;
debug(D_STREAM, "%s: Compressed data header: %ld", STREAM_COMPRESSION_MSG, compressed_data_size); netdata_log_debug(D_STREAM, "%s: Compressed data header: %ld", STREAM_COMPRESSION_MSG, compressed_data_size);
return compressed_data_size + RRDPUSH_COMPRESSION_SIGNATURE_SIZE; return compressed_data_size + RRDPUSH_COMPRESSION_SIGNATURE_SIZE;
} }

View file

@ -734,7 +734,7 @@ static void rrdpush_receive(struct receiver_state *rpt)
sprintf(initial_response, "%s", START_STREAMING_PROMPT_V1); sprintf(initial_response, "%s", START_STREAMING_PROMPT_V1);
} }
debug(D_STREAM, "Initial response to %s: %s", rpt->client_ip, initial_response); netdata_log_debug(D_STREAM, "Initial response to %s: %s", rpt->client_ip, initial_response);
ssize_t bytes_sent = send_timeout( ssize_t bytes_sent = send_timeout(
#ifdef ENABLE_HTTPS #ifdef ENABLE_HTTPS
&rpt->ssl, &rpt->ssl,

View file

@ -1185,7 +1185,7 @@ int rrdpush_receiver_thread_spawn(struct web_client *w, char *decoded_query_stri
} }
} }
debug(D_SYSTEM, "starting STREAM receive thread."); netdata_log_debug(D_SYSTEM, "starting STREAM receive thread.");
rrdpush_receiver_takeover_web_connection(w, rpt); rrdpush_receiver_takeover_web_connection(w, rpt);

View file

@ -203,7 +203,7 @@ static inline void rrdpush_sender_add_host_variable_to_buffer(BUFFER *wb, const
, rrdvar2number(rva) , rrdvar2number(rva)
); );
debug(D_STREAM, "RRDVAR pushed HOST VARIABLE %s = " NETDATA_DOUBLE_FORMAT, rrdvar_name(rva), rrdvar2number(rva)); netdata_log_debug(D_STREAM, "RRDVAR pushed HOST VARIABLE %s = " NETDATA_DOUBLE_FORMAT, rrdvar_name(rva), rrdvar2number(rva));
} }
void rrdpush_sender_send_this_host_variable_now(RRDHOST *host, const RRDVAR_ACQUIRED *rva) { void rrdpush_sender_send_this_host_variable_now(RRDHOST *host, const RRDVAR_ACQUIRED *rva) {
@ -242,7 +242,7 @@ static void rrdpush_sender_thread_send_custom_host_variables(RRDHOST *host) {
sender_commit(host->sender, wb, STREAM_TRAFFIC_TYPE_METADATA); sender_commit(host->sender, wb, STREAM_TRAFFIC_TYPE_METADATA);
sender_thread_buffer_free(); sender_thread_buffer_free();
debug(D_STREAM, "RRDVAR sent %d VARIABLES", ret); netdata_log_debug(D_STREAM, "RRDVAR sent %d VARIABLES", ret);
} }
} }
@ -752,7 +752,7 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
netdata_log_error("STREAM %s [send to %s]: cannot enlarge the socket buffer.", rrdhost_hostname(host), s->connected_to); netdata_log_error("STREAM %s [send to %s]: cannot enlarge the socket buffer.", rrdhost_hostname(host), s->connected_to);
http[bytes] = '\0'; http[bytes] = '\0';
debug(D_STREAM, "Response to sender from far end: %s", http); netdata_log_debug(D_STREAM, "Response to sender from far end: %s", http);
if(!rrdpush_sender_validate_response(host, s, http, bytes)) if(!rrdpush_sender_validate_response(host, s, http, bytes))
return false; return false;
@ -765,7 +765,7 @@ static bool rrdpush_sender_thread_connect_to_parent(RRDHOST *host, int default_p
log_sender_capabilities(s); log_sender_capabilities(s);
debug(D_STREAM, "STREAM: Connected on fd %d...", s->rrdpush_sender_socket); netdata_log_debug(D_STREAM, "STREAM: Connected on fd %d...", s->rrdpush_sender_socket);
return true; return true;
} }
@ -824,7 +824,7 @@ static ssize_t attempt_to_send(struct sender_state *s) {
sender_lock(s); sender_lock(s);
char *chunk; char *chunk;
size_t outstanding = cbuffer_next_unsafe(s->buffer, &chunk); size_t outstanding = cbuffer_next_unsafe(s->buffer, &chunk);
debug(D_STREAM, "STREAM: Sending data. Buffer r=%zu w=%zu s=%zu, next chunk=%zu", cb->read, cb->write, cb->size, outstanding); netdata_log_debug(D_STREAM, "STREAM: Sending data. Buffer r=%zu w=%zu s=%zu, next chunk=%zu", cb->read, cb->write, cb->size, outstanding);
#ifdef ENABLE_HTTPS #ifdef ENABLE_HTTPS
if(SSL_connection(&s->ssl)) if(SSL_connection(&s->ssl))
@ -839,18 +839,18 @@ static ssize_t attempt_to_send(struct sender_state *s) {
cbuffer_remove_unsafe(s->buffer, ret); cbuffer_remove_unsafe(s->buffer, ret);
s->sent_bytes_on_this_connection += ret; s->sent_bytes_on_this_connection += ret;
s->sent_bytes += ret; s->sent_bytes += ret;
debug(D_STREAM, "STREAM %s [send to %s]: Sent %zd bytes", rrdhost_hostname(s->host), s->connected_to, ret); netdata_log_debug(D_STREAM, "STREAM %s [send to %s]: Sent %zd bytes", rrdhost_hostname(s->host), s->connected_to, ret);
} }
else if (ret == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK)) else if (ret == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
debug(D_STREAM, "STREAM %s [send to %s]: unavailable after polling POLLOUT", rrdhost_hostname(s->host), s->connected_to); netdata_log_debug(D_STREAM, "STREAM %s [send to %s]: unavailable after polling POLLOUT", rrdhost_hostname(s->host), s->connected_to);
else if (ret == -1) { else if (ret == -1) {
worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_SEND_ERROR); worker_is_busy(WORKER_SENDER_JOB_DISCONNECT_SEND_ERROR);
debug(D_STREAM, "STREAM: Send failed - closing socket..."); netdata_log_debug(D_STREAM, "STREAM: Send failed - closing socket...");
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); 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);
rrdpush_sender_thread_close_socket(s->host); rrdpush_sender_thread_close_socket(s->host);
} }
else else
debug(D_STREAM, "STREAM: send() returned 0 -> no error but no transmission"); netdata_log_debug(D_STREAM, "STREAM: send() returned 0 -> no error but no transmission");
replication_recalculate_buffer_used_ratio_unsafe(s); replication_recalculate_buffer_used_ratio_unsafe(s);
sender_unlock(s); sender_unlock(s);
@ -1388,7 +1388,7 @@ void *rrdpush_sender_thread(void *ptr) {
int poll_rc = poll(fds, 2, 1000); int poll_rc = poll(fds, 2, 1000);
debug(D_STREAM, "STREAM: poll() finished collector=%d socket=%d (current chunk %zu bytes)...", netdata_log_debug(D_STREAM, "STREAM: poll() finished collector=%d socket=%d (current chunk %zu bytes)...",
fds[Collector].revents, fds[Socket].revents, outstanding); fds[Collector].revents, fds[Socket].revents, outstanding);
if(unlikely(rrdhost_sender_should_exit(s))) if(unlikely(rrdhost_sender_should_exit(s)))
@ -1403,7 +1403,7 @@ void *rrdpush_sender_thread(void *ptr) {
// Spurious wake-ups without error - loop again // Spurious wake-ups without error - loop again
if (poll_rc == 0 || ((poll_rc == -1) && (errno == EAGAIN || errno == EINTR))) { if (poll_rc == 0 || ((poll_rc == -1) && (errno == EAGAIN || errno == EINTR))) {
netdata_thread_testcancel(); netdata_thread_testcancel();
debug(D_STREAM, "Spurious wakeup"); netdata_log_debug(D_STREAM, "Spurious wakeup");
now_s = now_monotonic_sec(); now_s = now_monotonic_sec();
continue; continue;
} }
@ -1430,7 +1430,7 @@ void *rrdpush_sender_thread(void *ptr) {
// If the collector woke us up then empty the pipe to remove the signal // If the collector woke us up then empty the pipe to remove the signal
if (fds[Collector].revents & (POLLIN|POLLPRI)) { if (fds[Collector].revents & (POLLIN|POLLPRI)) {
worker_is_busy(WORKER_SENDER_JOB_PIPE_READ); worker_is_busy(WORKER_SENDER_JOB_PIPE_READ);
debug(D_STREAM, "STREAM: Data added to send buffer (current buffer chunk %zu bytes)...", outstanding); netdata_log_debug(D_STREAM, "STREAM: Data added to send buffer (current buffer chunk %zu bytes)...", outstanding);
if (read(fds[Collector].fd, thread_data->pipe_buffer, pipe_buffer_size) == -1) if (read(fds[Collector].fd, thread_data->pipe_buffer, pipe_buffer_size) == -1)
netdata_log_error("STREAM %s [send to %s]: cannot read from internal pipe.", rrdhost_hostname(s->host), s->connected_to); netdata_log_error("STREAM %s [send to %s]: cannot read from internal pipe.", rrdhost_hostname(s->host), s->connected_to);

View file

@ -17,29 +17,29 @@ extern size_t procfile_max_allocation;
static inline void pflines_reset(pflines *fl) { static inline void pflines_reset(pflines *fl) {
// debug(D_PROCFILE, PF_PREFIX ": resetting lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting lines");
fl->len = 0; fl->len = 0;
} }
static inline void pflines_free(pflines *fl) { static inline void pflines_free(pflines *fl) {
// debug(D_PROCFILE, PF_PREFIX ": freeing lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": freeing lines");
freez(fl); freez(fl);
} }
static inline void pfwords_reset(pfwords *fw) { static inline void pfwords_reset(pfwords *fw) {
// debug(D_PROCFILE, PF_PREFIX ": resetting words"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": resetting words");
fw->len = 0; fw->len = 0;
} }
static inline void pfwords_add(procfile *ff, char *str) { static inline void pfwords_add(procfile *ff, char *str) {
// debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding word No %d: '%s'", fw->len, str);
pfwords *fw = ff->words; pfwords *fw = ff->words;
if(unlikely(fw->len == fw->size)) { if(unlikely(fw->len == fw->size)) {
// debug(D_PROCFILE, PF_PREFIX ": expanding words"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding words");
ff->words = fw = reallocz(fw, sizeof(pfwords) + (fw->size + PFWORDS_INCREASE_STEP) * sizeof(char *)); ff->words = fw = reallocz(fw, sizeof(pfwords) + (fw->size + PFWORDS_INCREASE_STEP) * sizeof(char *));
fw->size += PFWORDS_INCREASE_STEP; fw->size += PFWORDS_INCREASE_STEP;
@ -50,11 +50,11 @@ static inline void pfwords_add(procfile *ff, char *str) {
NEVERNULL NEVERNULL
static inline size_t *pflines_add(procfile *ff) { static inline size_t *pflines_add(procfile *ff) {
// debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": adding line %d at word %d", fl->len, first_word);
pflines *fl = ff->lines; pflines *fl = ff->lines;
if(unlikely(fl->len == fl->size)) { if(unlikely(fl->len == fl->size)) {
// debug(D_PROCFILE, PF_PREFIX ": expanding lines"); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": expanding lines");
ff->lines = fl = reallocz(fl, sizeof(pflines) + (fl->size + PFLINES_INCREASE_STEP) * sizeof(ffline)); ff->lines = fl = reallocz(fl, sizeof(pflines) + (fl->size + PFLINES_INCREASE_STEP) * sizeof(ffline));
fl->size += PFLINES_INCREASE_STEP; fl->size += PFLINES_INCREASE_STEP;
@ -70,7 +70,7 @@ static inline size_t *pflines_add(procfile *ff) {
NOINLINE NOINLINE
static void procfile_parser(procfile *ff) { static void procfile_parser(procfile *ff) {
// debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Parsing file '%s'", ff->filename);
char *s = ff->data // our current position char *s = ff->data // our current position
, *e = &ff->data[ff->len] // the terminating null , *e = &ff->data[ff->len] // the terminating null
@ -115,7 +115,7 @@ static void procfile_parser(procfile *ff) {
(*line_words)++; (*line_words)++;
t = ++s; t = ++s;
// debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": ended line %d with %d words", l, ff->lines->lines[l].words);
line_words = pflines_add(ff); line_words = pflines_add(ff);
break; break;
@ -190,7 +190,7 @@ static void procfile_parser(procfile *ff) {
procfile *procfile_readall1(procfile *ff) { procfile *procfile_readall1(procfile *ff) {
// debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename); // netdata_log_debug(D_PROCFILE, PF_PREFIX ": Reading file '%s'.", ff->filename);
ff->len = 0; // zero the used size ff->len = 0; // zero the used size
ssize_t r = 1; // read at least once ssize_t r = 1; // read at least once
@ -199,12 +199,12 @@ procfile *procfile_readall1(procfile *ff) {
ssize_t x = ff->size - s; ssize_t x = ff->size - s;
if(unlikely(!x)) { if(unlikely(!x)) {
debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", procfile_filename(ff)); netdata_log_debug(D_PROCFILE, PF_PREFIX ": Expanding data buffer for file '%s'.", procfile_filename(ff));
ff = reallocz(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER); ff = reallocz(ff, sizeof(procfile) + ff->size + PROCFILE_INCREMENT_BUFFER);
ff->size += PROCFILE_INCREMENT_BUFFER; ff->size += PROCFILE_INCREMENT_BUFFER;
} }
debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s)); netdata_log_debug(D_PROCFILE, "Reading file '%s', from position %zd with length %zd", procfile_filename(ff), s, (ssize_t)(ff->size - s));
r = read(ff->fd, &ff->data[s], ff->size - s); r = read(ff->fd, &ff->data[s], ff->size - s);
if(unlikely(r == -1)) { if(unlikely(r == -1)) {
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); 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);
@ -215,7 +215,7 @@ procfile *procfile_readall1(procfile *ff) {
ff->len += r; ff->len += r;
} }
// debug(D_PROCFILE, "Rewinding file '%s'", ff->filename); // netdata_log_debug(D_PROCFILE, "Rewinding file '%s'", ff->filename);
if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) { if(unlikely(lseek(ff->fd, 0, SEEK_SET) == -1)) {
if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) netdata_log_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff)); if(unlikely(!(ff->flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) netdata_log_error(PF_PREFIX ": Cannot rewind on file '%s'.", procfile_filename(ff));
procfile_close(ff); procfile_close(ff);
@ -232,7 +232,7 @@ procfile *procfile_readall1(procfile *ff) {
if(unlikely(ff->words->len > procfile_max_words)) procfile_max_words = ff->words->len; if(unlikely(ff->words->len > procfile_max_words)) procfile_max_words = ff->words->len;
} }
// debug(D_PROCFILE, "File '%s' updated.", ff->filename); // netdata_log_debug(D_PROCFILE, "File '%s' updated.", ff->filename);
return ff; return ff;
} }

View file

@ -905,7 +905,7 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
if(!name || !*name) continue; if(!name || !*name) continue;
if(!value || !*value) continue; if(!value || !*value) continue;
debug(D_WEB_CLIENT, "%llu: API v1 badge.svg query param '%s' with value '%s'", w->id, name, value); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 badge.svg query param '%s' with value '%s'", w->id, name, value);
// name and value are now the parameters // name and value are now the parameters
// they are not null and not empty // they are not null and not empty
@ -1040,7 +1040,7 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
units = rrdset_units(st); units = rrdset_units(st);
} }
debug(D_WEB_CLIENT, "%llu: API command 'badge.svg' for chart '%s', alarm '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%d', options '0x%08x'" netdata_log_debug(D_WEB_CLIENT, "%llu: API command 'badge.svg' for chart '%s', alarm '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%d', options '0x%08x'"
, w->id , w->id
, chart , chart
, alarm?alarm:"" , alarm?alarm:""

View file

@ -14,7 +14,7 @@
void free_silencers(SILENCER *t) { void free_silencers(SILENCER *t) {
if (!t) return; if (!t) return;
if (t->next) free_silencers(t->next); if (t->next) free_silencers(t->next);
debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s:%s", t->alarms, netdata_log_debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s:%s", t->alarms,
t->charts, t->contexts, t->hosts, t->families); t->charts, t->contexts, t->hosts, t->families);
simple_pattern_free(t->alarms_pattern); simple_pattern_free(t->alarms_pattern);
simple_pattern_free(t->charts_pattern); simple_pattern_free(t->charts_pattern);
@ -133,7 +133,7 @@ int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, c
buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR); buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR);
ret = HTTP_RESP_FORBIDDEN; ret = HTTP_RESP_FORBIDDEN;
} else { } else {
debug(D_HEALTH, "HEALTH command API: Comparing secret '%s' to '%s'", w->auth_bearer_token, api_secret); netdata_log_debug(D_HEALTH, "HEALTH command API: Comparing secret '%s' to '%s'", w->auth_bearer_token, api_secret);
if (strcmp(w->auth_bearer_token, api_secret)) { if (strcmp(w->auth_bearer_token, api_secret)) {
buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR); buffer_strcat(wb, HEALTH_CMDAPI_MSG_AUTHERROR);
ret = HTTP_RESP_FORBIDDEN; ret = HTTP_RESP_FORBIDDEN;
@ -146,7 +146,7 @@ int web_client_api_request_v1_mgmt_health(RRDHOST *host, struct web_client *w, c
if (!key || !*key) continue; if (!key || !*key) continue;
if (!value || !*value) continue; if (!value || !*value) continue;
debug(D_WEB_CLIENT, "%llu: API v1 health query param '%s' with value '%s'", w->id, key, value); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 health query param '%s' with value '%s'", w->id, key, value);
// name and value are now the parameters // name and value are now the parameters
if (!strcmp(key, "cmd")) { if (!strcmp(key, "cmd")) {

View file

@ -414,7 +414,7 @@ inline int web_client_api_request_v1_alarm_count(RRDHOST *host, struct web_clien
if(!name || !*name) continue; if(!name || !*name) continue;
if(!value || !*value) continue; if(!value || !*value) continue;
debug(D_WEB_CLIENT, "%llu: API v1 alarm_count query param '%s' with value '%s'", w->id, name, value); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 alarm_count query param '%s' with value '%s'", w->id, name, value);
char* p = value; char* p = value;
if(!strcmp(name, "status")) { if(!strcmp(name, "status")) {
@ -654,7 +654,7 @@ inline int web_client_api_request_v1_chart(RRDHOST *host, struct web_client *w,
// returns the HTTP code // returns the HTTP code
static inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, char *url) { static inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, char *url) {
debug(D_WEB_CLIENT, "%llu: API v1 data with URL '%s'", w->id, url); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 data with URL '%s'", w->id, url);
int ret = HTTP_RESP_BAD_REQUEST; int ret = HTTP_RESP_BAD_REQUEST;
BUFFER *dimensions = NULL; BUFFER *dimensions = NULL;
@ -693,7 +693,7 @@ static inline int web_client_api_request_v1_data(RRDHOST *host, struct web_clien
if(!name || !*name) continue; if(!name || !*name) continue;
if(!value || !*value) continue; if(!value || !*value) continue;
debug(D_WEB_CLIENT, "%llu: API v1 data query param '%s' with value '%s'", w->id, name, value); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 data query param '%s' with value '%s'", w->id, name, value);
// name and value are now the parameters // name and value are now the parameters
// they are not null and not empty // they are not null and not empty
@ -839,14 +839,14 @@ static inline int web_client_api_request_v1_data(RRDHOST *host, struct web_clien
if(outFileName && *outFileName) { if(outFileName && *outFileName) {
buffer_sprintf(w->response.header, "Content-Disposition: attachment; filename=\"%s\"\r\n", outFileName); buffer_sprintf(w->response.header, "Content-Disposition: attachment; filename=\"%s\"\r\n", outFileName);
debug(D_WEB_CLIENT, "%llu: generating outfilename header: '%s'", w->id, outFileName); netdata_log_debug(D_WEB_CLIENT, "%llu: generating outfilename header: '%s'", w->id, outFileName);
} }
if(format == DATASOURCE_DATATABLE_JSONP) { if(format == DATASOURCE_DATATABLE_JSONP) {
if(responseHandler == NULL) if(responseHandler == NULL)
responseHandler = "google.visualization.Query.setResponse"; responseHandler = "google.visualization.Query.setResponse";
debug(D_WEB_CLIENT_ACCESS, "%llu: GOOGLE JSON/JSONP: version = '%s', reqId = '%s', sig = '%s', out = '%s', responseHandler = '%s', outFileName = '%s'", netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: GOOGLE JSON/JSONP: version = '%s', reqId = '%s', sig = '%s', out = '%s', responseHandler = '%s', outFileName = '%s'",
w->id, google_version, google_reqId, google_sig, google_out, responseHandler, outFileName w->id, google_version, google_reqId, google_sig, google_out, responseHandler, outFileName
); );
@ -927,7 +927,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
*/ */
} }
debug(D_WEB_CLIENT, "%llu: API v1 registry with URL '%s'", w->id, url); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 registry with URL '%s'", w->id, url);
// TODO // TODO
// The browser may send multiple cookies with our id // The browser may send multiple cookies with our id
@ -961,7 +961,7 @@ inline int web_client_api_request_v1_registry(RRDHOST *host, struct web_client *
if (!name || !*name) continue; if (!name || !*name) continue;
if (!value || !*value) continue; if (!value || !*value) continue;
debug(D_WEB_CLIENT, "%llu: API v1 registry query param '%s' with value '%s'", w->id, name, value); netdata_log_debug(D_WEB_CLIENT, "%llu: API v1 registry query param '%s' with value '%s'", w->id, name, value);
uint32_t hash = simple_hash(name); uint32_t hash = simple_hash(name);

View file

@ -587,14 +587,14 @@ static int web_client_api_request_v2_data(RRDHOST *host __maybe_unused, struct w
if(outFileName && *outFileName) { if(outFileName && *outFileName) {
buffer_sprintf(w->response.header, "Content-Disposition: attachment; filename=\"%s\"\r\n", outFileName); buffer_sprintf(w->response.header, "Content-Disposition: attachment; filename=\"%s\"\r\n", outFileName);
debug(D_WEB_CLIENT, "%llu: generating outfilename header: '%s'", w->id, outFileName); netdata_log_debug(D_WEB_CLIENT, "%llu: generating outfilename header: '%s'", w->id, outFileName);
} }
if(format == DATASOURCE_DATATABLE_JSONP) { if(format == DATASOURCE_DATATABLE_JSONP) {
if(responseHandler == NULL) if(responseHandler == NULL)
responseHandler = "google.visualization.Query.setResponse"; responseHandler = "google.visualization.Query.setResponse";
debug(D_WEB_CLIENT_ACCESS, "%llu: GOOGLE JSON/JSONP: version = '%s', reqId = '%s', sig = '%s', out = '%s', responseHandler = '%s', outFileName = '%s'", netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: GOOGLE JSON/JSONP: version = '%s', reqId = '%s', sig = '%s', out = '%s', responseHandler = '%s', outFileName = '%s'",
w->id, google_version, google_reqId, google_sig, google_out, responseHandler, outFileName w->id, google_version, google_reqId, google_sig, google_out, responseHandler, outFileName
); );

View file

@ -41,11 +41,11 @@ static struct web_client *web_client_create_on_fd(POLLINFO *pi) {
int flag = 1; int flag = 1;
if(unlikely(web_client_check_tcp(w) && setsockopt(w->ifd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int)) != 0)) if(unlikely(web_client_check_tcp(w) && setsockopt(w->ifd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int)) != 0))
debug(D_WEB_CLIENT, "%llu: failed to enable TCP_NODELAY on socket fd %d.", w->id, w->ifd); netdata_log_debug(D_WEB_CLIENT, "%llu: failed to enable TCP_NODELAY on socket fd %d.", w->id, w->ifd);
flag = 1; flag = 1;
if(unlikely(setsockopt(w->ifd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int)) != 0)) if(unlikely(setsockopt(w->ifd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int)) != 0))
debug(D_WEB_CLIENT, "%llu: failed to enable SO_KEEPALIVE on socket fd %d.", w->id, w->ifd); netdata_log_debug(D_WEB_CLIENT, "%llu: failed to enable SO_KEEPALIVE on socket fd %d.", w->id, w->ifd);
web_client_update_acl_matches(w); web_client_update_acl_matches(w);
web_client_enable_wait_receive(w); web_client_enable_wait_receive(w);
@ -101,7 +101,7 @@ static void *web_server_file_add_callback(POLLINFO *pi, short int *events, void
worker_private->files_read++; worker_private->files_read++;
debug(D_WEB_CLIENT, "%llu: ADDED FILE READ ON FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: ADDED FILE READ ON FD %d", w->id, pi->fd);
*events = POLLIN; *events = POLLIN;
pi->data = w; pi->data = w;
@ -111,14 +111,14 @@ static void *web_server_file_add_callback(POLLINFO *pi, short int *events, void
static void web_server_file_del_callback(POLLINFO *pi) { static void web_server_file_del_callback(POLLINFO *pi) {
struct web_client *w = (struct web_client *)pi->data; struct web_client *w = (struct web_client *)pi->data;
debug(D_WEB_CLIENT, "%llu: RELEASE FILE READ ON FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: RELEASE FILE READ ON FD %d", w->id, pi->fd);
worker_is_busy(WORKER_JOB_DEL_FILE); worker_is_busy(WORKER_JOB_DEL_FILE);
w->pollinfo_filecopy_slot = 0; w->pollinfo_filecopy_slot = 0;
if(unlikely(!w->pollinfo_slot)) { if(unlikely(!w->pollinfo_slot)) {
debug(D_WEB_CLIENT, "%llu: CROSS WEB CLIENT CLEANUP (iFD %d, oFD %d)", w->id, pi->fd, w->ofd); netdata_log_debug(D_WEB_CLIENT, "%llu: CROSS WEB CLIENT CLEANUP (iFD %d, oFD %d)", w->id, pi->fd, w->ofd);
web_server_log_connection(w, "DISCONNECTED"); web_server_log_connection(w, "DISCONNECTED");
web_client_request_done(w); web_client_request_done(w);
web_client_release_to_cache(w); web_client_release_to_cache(w);
@ -137,18 +137,18 @@ static int web_server_file_read_callback(POLLINFO *pi, short int *events) {
// if there is no POLLINFO linked to this, it means the client disconnected // if there is no POLLINFO linked to this, it means the client disconnected
// stop the file reading too // stop the file reading too
if(unlikely(!w->pollinfo_slot)) { if(unlikely(!w->pollinfo_slot)) {
debug(D_WEB_CLIENT, "%llu: PREVENTED ATTEMPT TO READ FILE ON FD %d, ON CLOSED WEB CLIENT", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: PREVENTED ATTEMPT TO READ FILE ON FD %d, ON CLOSED WEB CLIENT", w->id, pi->fd);
retval = -1; retval = -1;
goto cleanup; goto cleanup;
} }
if(unlikely(w->mode != WEB_CLIENT_MODE_FILECOPY || w->ifd == w->ofd)) { if(unlikely(w->mode != WEB_CLIENT_MODE_FILECOPY || w->ifd == w->ofd)) {
debug(D_WEB_CLIENT, "%llu: PREVENTED ATTEMPT TO READ FILE ON FD %d, ON NON-FILECOPY WEB CLIENT", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: PREVENTED ATTEMPT TO READ FILE ON FD %d, ON NON-FILECOPY WEB CLIENT", w->id, pi->fd);
retval = -1; retval = -1;
goto cleanup; goto cleanup;
} }
debug(D_WEB_CLIENT, "%llu: READING FILE ON FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: READING FILE ON FD %d", w->id, pi->fd);
worker_private->file_reads++; worker_private->file_reads++;
ssize_t ret = unlikely(web_client_read_file(w)); ssize_t ret = unlikely(web_client_read_file(w));
@ -157,12 +157,12 @@ static int web_server_file_read_callback(POLLINFO *pi, short int *events) {
POLLJOB *p = pi->p; // our POLLJOB POLLJOB *p = pi->p; // our POLLJOB
POLLINFO *wpi = pollinfo_from_slot(p, w->pollinfo_slot); // POLLINFO of the client socket POLLINFO *wpi = pollinfo_from_slot(p, w->pollinfo_slot); // POLLINFO of the client socket
debug(D_WEB_CLIENT, "%llu: SIGNALING W TO SEND (iFD %d, oFD %d)", w->id, pi->fd, wpi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: SIGNALING W TO SEND (iFD %d, oFD %d)", w->id, pi->fd, wpi->fd);
p->fds[wpi->slot].events |= POLLOUT; p->fds[wpi->slot].events |= POLLOUT;
} }
if(unlikely(ret <= 0 || w->ifd == w->ofd)) { if(unlikely(ret <= 0 || w->ifd == w->ofd)) {
debug(D_WEB_CLIENT, "%llu: DONE READING FILE ON FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: DONE READING FILE ON FD %d", w->id, pi->fd);
retval = -1; retval = -1;
goto cleanup; goto cleanup;
} }
@ -201,7 +201,7 @@ static void *web_server_add_callback(POLLINFO *pi, short int *events, void *data
*events = POLLIN; *events = POLLIN;
debug(D_WEB_CLIENT_ACCESS, "LISTENER on %d: new connection.", pi->fd); netdata_log_debug(D_WEB_CLIENT_ACCESS, "LISTENER on %d: new connection.", pi->fd);
struct web_client *w = web_client_create_on_fd(pi); struct web_client *w = web_client_create_on_fd(pi);
if (!strncmp(pi->client_port, "UNIX", 4)) { if (!strncmp(pi->client_port, "UNIX", 4)) {
@ -240,7 +240,7 @@ static void *web_server_add_callback(POLLINFO *pi, short int *events, void *data
} }
#endif #endif
debug(D_WEB_CLIENT, "%llu: ADDED CLIENT FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: ADDED CLIENT FD %d", w->id, pi->fd);
cleanup: cleanup:
worker_is_idle(); worker_is_idle();
@ -260,13 +260,13 @@ static void web_server_del_callback(POLLINFO *pi) {
POLLINFO *fpi = pollinfo_from_slot(pi->p, w->pollinfo_filecopy_slot); // POLLINFO of the client socket POLLINFO *fpi = pollinfo_from_slot(pi->p, w->pollinfo_filecopy_slot); // POLLINFO of the client socket
(void)fpi; (void)fpi;
debug(D_WEB_CLIENT, "%llu: THE CLIENT WILL BE FRED BY READING FILE JOB ON FD %d", w->id, fpi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: THE CLIENT WILL BE FRED BY READING FILE JOB ON FD %d", w->id, fpi->fd);
} }
else { else {
if(web_client_flag_check(w, WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET)) if(web_client_flag_check(w, WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET))
pi->flags |= POLLINFO_FLAG_DONT_CLOSE; pi->flags |= POLLINFO_FLAG_DONT_CLOSE;
debug(D_WEB_CLIENT, "%llu: CLOSING CLIENT FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: CLOSING CLIENT FD %d", w->id, pi->fd);
web_server_log_connection(w, "DISCONNECTED"); web_server_log_connection(w, "DISCONNECTED");
web_client_request_done(w); web_client_request_done(w);
web_client_release_to_cache(w); web_client_release_to_cache(w);
@ -289,7 +289,7 @@ static int web_server_rcv_callback(POLLINFO *pi, short int *events) {
bytes = web_client_receive(w); bytes = web_client_receive(w);
if (likely(bytes > 0)) { if (likely(bytes > 0)) {
debug(D_WEB_CLIENT, "%llu: processing received data on fd %d.", w->id, fd); netdata_log_debug(D_WEB_CLIENT, "%llu: processing received data on fd %d.", w->id, fd);
worker_is_idle(); worker_is_idle();
worker_is_busy(WORKER_JOB_PROCESS); worker_is_busy(WORKER_JOB_PROCESS);
web_client_process_request(w); web_client_process_request(w);
@ -300,11 +300,11 @@ static int web_server_rcv_callback(POLLINFO *pi, short int *events) {
else if(unlikely(w->mode == WEB_CLIENT_MODE_FILECOPY)) { else if(unlikely(w->mode == WEB_CLIENT_MODE_FILECOPY)) {
if(w->pollinfo_filecopy_slot == 0) { if(w->pollinfo_filecopy_slot == 0) {
debug(D_WEB_CLIENT, "%llu: FILECOPY DETECTED ON FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: FILECOPY DETECTED ON FD %d", w->id, pi->fd);
if (unlikely(w->ifd != -1 && w->ifd != w->ofd && w->ifd != fd)) { if (unlikely(w->ifd != -1 && w->ifd != w->ofd && w->ifd != fd)) {
// add a new socket to poll_events, with the same // add a new socket to poll_events, with the same
debug(D_WEB_CLIENT, "%llu: CREATING FILECOPY SLOT ON FD %d", w->id, pi->fd); netdata_log_debug(D_WEB_CLIENT, "%llu: CREATING FILECOPY SLOT ON FD %d", w->id, pi->fd);
POLLINFO *fpi = poll_add_fd( POLLINFO *fpi = poll_add_fd(
pi->p pi->p
@ -366,7 +366,7 @@ static int web_server_snd_callback(POLLINFO *pi, short int *events) {
struct web_client *w = (struct web_client *)pi->data; struct web_client *w = (struct web_client *)pi->data;
int fd = pi->fd; int fd = pi->fd;
debug(D_WEB_CLIENT, "%llu: sending data on fd %d.", w->id, fd); netdata_log_debug(D_WEB_CLIENT, "%llu: sending data on fd %d.", w->id, fd);
int ret = web_client_send(w); int ret = web_client_send(w);

View file

@ -164,7 +164,7 @@ static void web_client_reset_allocations(struct web_client *w, bool free_all) {
void web_client_request_done(struct web_client *w) { void web_client_request_done(struct web_client *w) {
web_client_uncork_socket(w); web_client_uncork_socket(w);
debug(D_WEB_CLIENT, "%llu: Resetting client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Resetting client.", w->id);
if(likely(buffer_strlen(w->url_as_received))) { if(likely(buffer_strlen(w->url_as_received))) {
struct timeval tv; struct timeval tv;
@ -233,7 +233,7 @@ void web_client_request_done(struct web_client *w) {
if(unlikely(w->mode == WEB_CLIENT_MODE_FILECOPY)) { if(unlikely(w->mode == WEB_CLIENT_MODE_FILECOPY)) {
if(w->ifd != w->ofd) { if(w->ifd != w->ofd) {
debug(D_WEB_CLIENT, "%llu: Closing filecopy input file descriptor %d.", w->id, w->ifd); netdata_log_debug(D_WEB_CLIENT, "%llu: Closing filecopy input file descriptor %d.", w->id, w->ifd);
if(web_server_mode != WEB_SERVER_MODE_STATIC_THREADED) { if(web_server_mode != WEB_SERVER_MODE_STATIC_THREADED) {
if (w->ifd != -1){ if (w->ifd != -1){
@ -480,7 +480,7 @@ static bool find_filename_to_serve(const char *filename, char *dst, size_t dst_l
} }
static int mysendfile(struct web_client *w, char *filename) { static int mysendfile(struct web_client *w, char *filename) {
debug(D_WEB_CLIENT, "%llu: Looking for file '%s/%s'", w->id, netdata_configured_web_dir, filename); netdata_log_debug(D_WEB_CLIENT, "%llu: Looking for file '%s/%s'", w->id, netdata_configured_web_dir, filename);
if(!web_client_can_access_dashboard(w)) if(!web_client_can_access_dashboard(w))
return web_client_permission_denied(w); return web_client_permission_denied(w);
@ -492,7 +492,7 @@ static int mysendfile(struct web_client *w, char *filename) {
char *s; char *s;
for(s = filename; *s ;s++) { for(s = filename; *s ;s++) {
if( !isalnum(*s) && *s != '/' && *s != '.' && *s != '-' && *s != '_') { if( !isalnum(*s) && *s != '/' && *s != '.' && *s != '-' && *s != '_') {
debug(D_WEB_CLIENT_ACCESS, "%llu: File '%s' is not acceptable.", w->id, filename); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: File '%s' is not acceptable.", w->id, filename);
w->response.data->content_type = CT_TEXT_HTML; w->response.data->content_type = CT_TEXT_HTML;
buffer_sprintf(w->response.data, "Filename contains invalid characters: "); buffer_sprintf(w->response.data, "Filename contains invalid characters: ");
buffer_strcat_htmlescape(w->response.data, filename); buffer_strcat_htmlescape(w->response.data, filename);
@ -502,7 +502,7 @@ static int mysendfile(struct web_client *w, char *filename) {
// if the filename contains a double dot refuse to serve it // if the filename contains a double dot refuse to serve it
if(strstr(filename, "..") != 0) { if(strstr(filename, "..") != 0) {
debug(D_WEB_CLIENT_ACCESS, "%llu: File '%s' is not acceptable.", w->id, filename); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: File '%s' is not acceptable.", w->id, filename);
w->response.data->content_type = CT_TEXT_HTML; w->response.data->content_type = CT_TEXT_HTML;
buffer_strcat(w->response.data, "Relative filenames are not supported: "); buffer_strcat(w->response.data, "Relative filenames are not supported: ");
buffer_strcat_htmlescape(w->response.data, filename); buffer_strcat_htmlescape(w->response.data, filename);
@ -548,7 +548,7 @@ static int mysendfile(struct web_client *w, char *filename) {
sock_setnonblock(w->ifd); sock_setnonblock(w->ifd);
w->response.data->content_type = contenttype_for_filename(web_filename); w->response.data->content_type = contenttype_for_filename(web_filename);
debug(D_WEB_CLIENT_ACCESS, "%llu: Sending file '%s' (%"PRId64" bytes, ifd %d, ofd %d).", w->id, web_filename, (int64_t)statbuf.st_size, w->ifd, w->ofd); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: Sending file '%s' (%"PRId64" bytes, ifd %d, ofd %d).", w->id, web_filename, (int64_t)statbuf.st_size, w->ifd, w->ofd);
w->mode = WEB_CLIENT_MODE_FILECOPY; w->mode = WEB_CLIENT_MODE_FILECOPY;
web_client_enable_wait_receive(w); web_client_enable_wait_receive(w);
@ -569,7 +569,7 @@ static int mysendfile(struct web_client *w, char *filename) {
void web_client_enable_deflate(struct web_client *w, int gzip) { void web_client_enable_deflate(struct web_client *w, int gzip) {
if(unlikely(w->response.zinitialized)) { if(unlikely(w->response.zinitialized)) {
debug(D_DEFLATE, "%llu: Compression has already be initialized for this client.", w->id); netdata_log_debug(D_DEFLATE, "%llu: Compression has already be initialized for this client.", w->id);
return; return;
} }
@ -610,7 +610,7 @@ void web_client_enable_deflate(struct web_client *w, int gzip) {
w->response.zinitialized = true; w->response.zinitialized = true;
w->flags |= WEB_CLIENT_CHUNKED_TRANSFER; w->flags |= WEB_CLIENT_CHUNKED_TRANSFER;
debug(D_DEFLATE, "%llu: Initialized compression.", w->id); netdata_log_debug(D_DEFLATE, "%llu: Initialized compression.", w->id);
} }
void buffer_data_options2string(BUFFER *wb, uint32_t options) { void buffer_data_options2string(BUFFER *wb, uint32_t options) {
@ -711,7 +711,7 @@ int web_client_api_request(RRDHOST *host, struct web_client *w, char *url_path_f
// get the api version // get the api version
char *tok = strsep_skip_consecutive_separators(&url_path_fragment, "/"); char *tok = strsep_skip_consecutive_separators(&url_path_fragment, "/");
if(tok && *tok) { if(tok && *tok) {
debug(D_WEB_CLIENT, "%llu: Searching for API version '%s'.", w->id, tok); netdata_log_debug(D_WEB_CLIENT, "%llu: Searching for API version '%s'.", w->id, tok);
if(strcmp(tok, "v2") == 0) if(strcmp(tok, "v2") == 0)
return web_client_api_request_v2(host, w, url_path_fragment); return web_client_api_request_v2(host, w, url_path_fragment);
else if(strcmp(tok, "v1") == 0) else if(strcmp(tok, "v1") == 0)
@ -1161,7 +1161,7 @@ void web_client_build_http_header(struct web_client *w) {
} }
// prepare the HTTP response header // prepare the HTTP response header
debug(D_WEB_CLIENT, "%llu: Generating HTTP header with response %d.", w->id, w->response.code); netdata_log_debug(D_WEB_CLIENT, "%llu: Generating HTTP header with response %d.", w->id, w->response.code);
const char *content_type_string = web_content_type_to_string(w->response.data->content_type); const char *content_type_string = web_content_type_to_string(w->response.data->content_type);
const char *code_msg = web_response_code_to_string(w->response.code); const char *code_msg = web_response_code_to_string(w->response.code);
@ -1268,7 +1268,7 @@ static inline void web_client_send_http_header(struct web_client *w) {
web_client_build_http_header(w); web_client_build_http_header(w);
// sent the HTTP header // sent the HTTP header
debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %zu: '%s'" netdata_log_debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %zu: '%s'"
, w->id , w->id
, buffer_strlen(w->response.header_output) , buffer_strlen(w->response.header_output)
, buffer_tostring(w->response.header_output) , buffer_tostring(w->response.header_output)
@ -1348,7 +1348,7 @@ static inline int web_client_switch_host(RRDHOST *host, struct web_client *w, ch
char *tok = strsep_skip_consecutive_separators(&url, "/"); char *tok = strsep_skip_consecutive_separators(&url, "/");
if(tok && *tok) { if(tok && *tok) {
debug(D_WEB_CLIENT, "%llu: Searching for host with name '%s'.", w->id, tok); netdata_log_debug(D_WEB_CLIENT, "%llu: Searching for host with name '%s'.", w->id, tok);
if(nodeid) { if(nodeid) {
host = find_host_by_node_id(tok); host = find_host_by_node_id(tok);
@ -1420,12 +1420,12 @@ int web_client_api_request_with_node_selection(RRDHOST *host, struct web_client
if(unlikely(hash == hash_api && strcmp(tok, "api") == 0)) { if(unlikely(hash == hash_api && strcmp(tok, "api") == 0)) {
// current API // current API
debug(D_WEB_CLIENT_ACCESS, "%llu: API request ...", w->id); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: API request ...", w->id);
return check_host_and_call(host, w, decoded_url_path, web_client_api_request); return check_host_and_call(host, w, decoded_url_path, web_client_api_request);
} }
else if(unlikely((hash == hash_host && strcmp(tok, "host") == 0) || (hash == hash_node && strcmp(tok, "node") == 0))) { else if(unlikely((hash == hash_host && strcmp(tok, "host") == 0) || (hash == hash_node && strcmp(tok, "node") == 0))) {
// host switching // host switching
debug(D_WEB_CLIENT_ACCESS, "%llu: host switch request ...", w->id); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: host switch request ...", w->id);
return web_client_switch_host(host, w, decoded_url_path, hash == hash_node, web_client_api_request_with_node_selection); return web_client_switch_host(host, w, decoded_url_path, hash == hash_node, web_client_api_request_with_node_selection);
} }
} }
@ -1475,14 +1475,14 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
char *tok = strsep_skip_consecutive_separators(&decoded_url_path, "/?"); char *tok = strsep_skip_consecutive_separators(&decoded_url_path, "/?");
if(likely(tok && *tok)) { if(likely(tok && *tok)) {
uint32_t hash = simple_hash(tok); uint32_t hash = simple_hash(tok);
debug(D_WEB_CLIENT, "%llu: Processing command '%s'.", w->id, tok); netdata_log_debug(D_WEB_CLIENT, "%llu: Processing command '%s'.", w->id, tok);
if(likely(hash == hash_api && strcmp(tok, "api") == 0)) { // current API if(likely(hash == hash_api && strcmp(tok, "api") == 0)) { // current API
debug(D_WEB_CLIENT_ACCESS, "%llu: API request ...", w->id); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: API request ...", w->id);
return check_host_and_call(host, w, decoded_url_path, web_client_api_request); return check_host_and_call(host, w, decoded_url_path, web_client_api_request);
} }
else if(unlikely((hash == hash_host && strcmp(tok, "host") == 0) || (hash == hash_node && strcmp(tok, "node") == 0))) { // host switching else if(unlikely((hash == hash_host && strcmp(tok, "host") == 0) || (hash == hash_node && strcmp(tok, "node") == 0))) { // host switching
debug(D_WEB_CLIENT_ACCESS, "%llu: host switch request ...", w->id); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: host switch request ...", w->id);
return web_client_switch_host(host, w, decoded_url_path, hash == hash_node, web_client_process_url); return web_client_switch_host(host, w, decoded_url_path, hash == hash_node, web_client_process_url);
} }
else if(unlikely(hash == hash_v2 && strcmp(tok, "v2") == 0)) { else if(unlikely(hash == hash_v2 && strcmp(tok, "v2") == 0)) {
@ -1507,7 +1507,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
if(unlikely(!web_client_can_access_netdataconf(w))) if(unlikely(!web_client_can_access_netdataconf(w)))
return web_client_permission_denied(w); return web_client_permission_denied(w);
debug(D_WEB_CLIENT_ACCESS, "%llu: generating netdata.conf ...", w->id); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: generating netdata.conf ...", w->id);
w->response.data->content_type = CT_TEXT_PLAIN; w->response.data->content_type = CT_TEXT_PLAIN;
buffer_flush(w->response.data); buffer_flush(w->response.data);
config_generate(w->response.data, 0); config_generate(w->response.data, 0);
@ -1539,7 +1539,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
// get the name of the data to show // get the name of the data to show
tok = strsep_skip_consecutive_separators(&decoded_url_path, "&"); tok = strsep_skip_consecutive_separators(&decoded_url_path, "&");
if(tok && *tok) { if(tok && *tok) {
debug(D_WEB_CLIENT, "%llu: Searching for RRD data with name '%s'.", w->id, tok); netdata_log_debug(D_WEB_CLIENT, "%llu: Searching for RRD data with name '%s'.", w->id, tok);
// do we have such a data set? // do we have such a data set?
RRDSET *st = rrdset_find_byname(host, tok); RRDSET *st = rrdset_find_byname(host, tok);
@ -1548,7 +1548,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
w->response.data->content_type = CT_TEXT_HTML; w->response.data->content_type = CT_TEXT_HTML;
buffer_strcat(w->response.data, "Chart is not found: "); buffer_strcat(w->response.data, "Chart is not found: ");
buffer_strcat_htmlescape(w->response.data, tok); buffer_strcat_htmlescape(w->response.data, tok);
debug(D_WEB_CLIENT_ACCESS, "%llu: %s is not found.", w->id, tok); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: %s is not found.", w->id, tok);
return HTTP_RESP_NOT_FOUND; return HTTP_RESP_NOT_FOUND;
} }
@ -1562,7 +1562,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
w->response.data->content_type = CT_TEXT_HTML; w->response.data->content_type = CT_TEXT_HTML;
buffer_sprintf(w->response.data, "Chart has now debug %s: ", rrdset_flag_check(st, RRDSET_FLAG_DEBUG)?"enabled":"disabled"); buffer_sprintf(w->response.data, "Chart has now debug %s: ", rrdset_flag_check(st, RRDSET_FLAG_DEBUG)?"enabled":"disabled");
buffer_strcat_htmlescape(w->response.data, tok); buffer_strcat_htmlescape(w->response.data, tok);
debug(D_WEB_CLIENT_ACCESS, "%llu: debug for %s is %s.", w->id, tok, rrdset_flag_check(st, RRDSET_FLAG_DEBUG)?"enabled":"disabled"); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: debug for %s is %s.", w->id, tok, rrdset_flag_check(st, RRDSET_FLAG_DEBUG)?"enabled":"disabled");
return HTTP_RESP_OK; return HTTP_RESP_OK;
} }
@ -1574,7 +1574,7 @@ static inline int web_client_process_url(RRDHOST *host, struct web_client *w, ch
if(unlikely(!web_client_can_access_netdataconf(w))) if(unlikely(!web_client_can_access_netdataconf(w)))
return web_client_permission_denied(w); return web_client_permission_denied(w);
debug(D_WEB_CLIENT_ACCESS, "%llu: Mirroring...", w->id); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: Mirroring...", w->id);
// replace the zero bytes with spaces // replace the zero bytes with spaces
buffer_char_replace(w->response.data, '\0', ' '); buffer_char_replace(w->response.data, '\0', ' ');
@ -1676,7 +1676,7 @@ void web_client_process_request(struct web_client *w) {
buffer_flush(w->url_as_received); buffer_flush(w->url_as_received);
buffer_strcat(w->url_as_received, "too big request"); buffer_strcat(w->url_as_received, "too big request");
debug(D_WEB_CLIENT_ACCESS, "%llu: Received request is too big (%zu bytes).", w->id, w->response.data->len); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: Received request is too big (%zu bytes).", w->id, w->response.data->len);
size_t len = w->response.data->len; size_t len = w->response.data->len;
buffer_flush(w->response.data); buffer_flush(w->response.data);
@ -1710,28 +1710,28 @@ void web_client_process_request(struct web_client *w) {
} }
#endif #endif
case HTTP_VALIDATION_MALFORMED_URL: case HTTP_VALIDATION_MALFORMED_URL:
debug(D_WEB_CLIENT_ACCESS, "%llu: Malformed URL '%s'.", w->id, w->response.data->buffer); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: Malformed URL '%s'.", w->id, w->response.data->buffer);
buffer_flush(w->response.data); buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Malformed URL...\r\n"); buffer_strcat(w->response.data, "Malformed URL...\r\n");
w->response.code = HTTP_RESP_BAD_REQUEST; w->response.code = HTTP_RESP_BAD_REQUEST;
break; break;
case HTTP_VALIDATION_EXCESS_REQUEST_DATA: case HTTP_VALIDATION_EXCESS_REQUEST_DATA:
debug(D_WEB_CLIENT_ACCESS, "%llu: Excess data in request '%s'.", w->id, w->response.data->buffer); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: Excess data in request '%s'.", w->id, w->response.data->buffer);
buffer_flush(w->response.data); buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Excess data in request.\r\n"); buffer_strcat(w->response.data, "Excess data in request.\r\n");
w->response.code = HTTP_RESP_BAD_REQUEST; w->response.code = HTTP_RESP_BAD_REQUEST;
break; break;
case HTTP_VALIDATION_TOO_MANY_READ_RETRIES: case HTTP_VALIDATION_TOO_MANY_READ_RETRIES:
debug(D_WEB_CLIENT_ACCESS, "%llu: Too many retries to read request '%s'.", w->id, w->response.data->buffer); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: Too many retries to read request '%s'.", w->id, w->response.data->buffer);
buffer_flush(w->response.data); buffer_flush(w->response.data);
buffer_strcat(w->response.data, "Too many retries to read request.\r\n"); buffer_strcat(w->response.data, "Too many retries to read request.\r\n");
w->response.code = HTTP_RESP_BAD_REQUEST; w->response.code = HTTP_RESP_BAD_REQUEST;
break; break;
case HTTP_VALIDATION_NOT_SUPPORTED: case HTTP_VALIDATION_NOT_SUPPORTED:
debug(D_WEB_CLIENT_ACCESS, "%llu: HTTP method requested is not supported '%s'.", w->id, w->response.data->buffer); netdata_log_debug(D_WEB_CLIENT_ACCESS, "%llu: HTTP method requested is not supported '%s'.", w->id, w->response.data->buffer);
buffer_flush(w->response.data); buffer_flush(w->response.data);
buffer_strcat(w->response.data, "HTTP method requested is not supported...\r\n"); buffer_strcat(w->response.data, "HTTP method requested is not supported...\r\n");
@ -1756,21 +1756,21 @@ void web_client_process_request(struct web_client *w) {
switch(w->mode) { switch(w->mode) {
case WEB_CLIENT_MODE_STREAM: case WEB_CLIENT_MODE_STREAM:
debug(D_WEB_CLIENT, "%llu: STREAM done.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: STREAM done.", w->id);
break; break;
case WEB_CLIENT_MODE_OPTIONS: case WEB_CLIENT_MODE_OPTIONS:
debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%zu bytes) to client.", w->id, w->response.data->len); netdata_log_debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
break; break;
case WEB_CLIENT_MODE_POST: case WEB_CLIENT_MODE_POST:
case WEB_CLIENT_MODE_GET: case WEB_CLIENT_MODE_GET:
debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%zu bytes) to client.", w->id, w->response.data->len); netdata_log_debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
break; break;
case WEB_CLIENT_MODE_FILECOPY: case WEB_CLIENT_MODE_FILECOPY:
if(w->response.rlen) { if(w->response.rlen) {
debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %zu bytes to client.", w->id, w->response.rlen); netdata_log_debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %zu bytes to client.", w->id, w->response.rlen);
web_client_enable_wait_receive(w); web_client_enable_wait_receive(w);
/* /*
@ -1787,7 +1787,7 @@ void web_client_process_request(struct web_client *w) {
*/ */
} }
else else
debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending an unknown amount of bytes to client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending an unknown amount of bytes to client.", w->id);
break; break;
default: default:
@ -1798,7 +1798,7 @@ void web_client_process_request(struct web_client *w) {
ssize_t web_client_send_chunk_header(struct web_client *w, size_t len) ssize_t web_client_send_chunk_header(struct web_client *w, size_t len)
{ {
debug(D_DEFLATE, "%llu: OPEN CHUNK of %zu bytes (hex: %zx).", w->id, len, len); netdata_log_debug(D_DEFLATE, "%llu: OPEN CHUNK of %zu bytes (hex: %zx).", w->id, len, len);
char buf[24]; char buf[24];
ssize_t bytes; ssize_t bytes;
bytes = (ssize_t)sprintf(buf, "%zX\r\n", len); bytes = (ssize_t)sprintf(buf, "%zX\r\n", len);
@ -1806,15 +1806,15 @@ ssize_t web_client_send_chunk_header(struct web_client *w, size_t len)
bytes = web_client_send_data(w,buf,strlen(buf),0); bytes = web_client_send_data(w,buf,strlen(buf),0);
if(bytes > 0) { if(bytes > 0) {
debug(D_DEFLATE, "%llu: Sent chunk header %zd bytes.", w->id, bytes); netdata_log_debug(D_DEFLATE, "%llu: Sent chunk header %zd bytes.", w->id, bytes);
w->statistics.sent_bytes += bytes; w->statistics.sent_bytes += bytes;
} }
else if(bytes == 0) { else if(bytes == 0) {
debug(D_WEB_CLIENT, "%llu: Did not send chunk header to the client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Did not send chunk header to the client.", w->id);
} }
else { else {
debug(D_WEB_CLIENT, "%llu: Failed to send chunk header to client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Failed to send chunk header to client.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} }
@ -1828,15 +1828,15 @@ ssize_t web_client_send_chunk_close(struct web_client *w)
ssize_t bytes; ssize_t bytes;
bytes = web_client_send_data(w,"\r\n",2,0); bytes = web_client_send_data(w,"\r\n",2,0);
if(bytes > 0) { if(bytes > 0) {
debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes); netdata_log_debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
w->statistics.sent_bytes += bytes; w->statistics.sent_bytes += bytes;
} }
else if(bytes == 0) { else if(bytes == 0) {
debug(D_WEB_CLIENT, "%llu: Did not send chunk suffix to the client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Did not send chunk suffix to the client.", w->id);
} }
else { else {
debug(D_WEB_CLIENT, "%llu: Failed to send chunk suffix to client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Failed to send chunk suffix to client.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} }
@ -1850,15 +1850,15 @@ ssize_t web_client_send_chunk_finalize(struct web_client *w)
ssize_t bytes; ssize_t bytes;
bytes = web_client_send_data(w,"\r\n0\r\n\r\n",7,0); bytes = web_client_send_data(w,"\r\n0\r\n\r\n",7,0);
if(bytes > 0) { if(bytes > 0) {
debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes); netdata_log_debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
w->statistics.sent_bytes += bytes; w->statistics.sent_bytes += bytes;
} }
else if(bytes == 0) { else if(bytes == 0) {
debug(D_WEB_CLIENT, "%llu: Did not send chunk finalize suffix to the client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Did not send chunk finalize suffix to the client.", w->id);
} }
else { else {
debug(D_WEB_CLIENT, "%llu: Failed to send chunk finalize suffix to client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Failed to send chunk finalize suffix to client.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} }
@ -1872,13 +1872,13 @@ ssize_t web_client_send_deflate(struct web_client *w)
// when using compression, // when using compression,
// w->response.sent is the amount of bytes passed through compression // w->response.sent is the amount of bytes passed through compression
debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %zu, w->response.sent = %zu, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %u, w->response.zstream.avail_out = %u, w->response.zstream.total_in = %lu, w->response.zstream.total_out = %lu.", netdata_log_debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %zu, w->response.sent = %zu, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %u, w->response.zstream.avail_out = %u, w->response.zstream.total_in = %lu, w->response.zstream.total_out = %lu.",
w->id, w->response.data->len, w->response.sent, w->response.zhave, w->response.zsent, w->response.zstream.avail_in, w->response.zstream.avail_out, w->response.zstream.total_in, w->response.zstream.total_out); w->id, w->response.data->len, w->response.sent, w->response.zhave, w->response.zsent, w->response.zstream.avail_in, w->response.zstream.avail_out, w->response.zstream.total_in, w->response.zstream.total_out);
if(w->response.data->len - w->response.sent == 0 && w->response.zstream.avail_in == 0 && w->response.zhave == w->response.zsent && w->response.zstream.avail_out != 0) { if(w->response.data->len - w->response.sent == 0 && w->response.zstream.avail_in == 0 && w->response.zhave == w->response.zsent && w->response.zstream.avail_out != 0) {
// there is nothing to send // there is nothing to send
debug(D_WEB_CLIENT, "%llu: Out of output data.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Out of output data.", w->id);
// finalize the chunk // finalize the chunk
if(w->response.sent != 0) { if(w->response.sent != 0) {
@ -1888,20 +1888,20 @@ ssize_t web_client_send_deflate(struct web_client *w)
if(w->mode == WEB_CLIENT_MODE_FILECOPY && web_client_has_wait_receive(w) && w->response.rlen && w->response.rlen > w->response.data->len) { if(w->mode == WEB_CLIENT_MODE_FILECOPY && web_client_has_wait_receive(w) && w->response.rlen && w->response.rlen > w->response.data->len) {
// we have to wait, more data will come // we have to wait, more data will come
debug(D_WEB_CLIENT, "%llu: Waiting for more data to become available.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Waiting for more data to become available.", w->id);
web_client_disable_wait_send(w); web_client_disable_wait_send(w);
return t; return t;
} }
if(unlikely(!web_client_has_keepalive(w))) { if(unlikely(!web_client_has_keepalive(w))) {
debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %zu bytes sent.", w->id, w->response.sent); netdata_log_debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %zu bytes sent.", w->id, w->response.sent);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
return t; return t;
} }
// reset the client // reset the client
web_client_request_done(w); web_client_request_done(w);
debug(D_WEB_CLIENT, "%llu: Done sending all data on socket.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Done sending all data on socket.", w->id);
return t; return t;
} }
@ -1914,7 +1914,7 @@ ssize_t web_client_send_deflate(struct web_client *w)
if(t < 0) return t; if(t < 0) return t;
} }
debug(D_DEFLATE, "%llu: Compressing %zu new bytes starting from %zu (and %u left behind).", w->id, (w->response.data->len - w->response.sent), w->response.sent, w->response.zstream.avail_in); netdata_log_debug(D_DEFLATE, "%llu: Compressing %zu new bytes starting from %zu (and %u left behind).", w->id, (w->response.data->len - w->response.sent), w->response.sent, w->response.zstream.avail_in);
// give the compressor all the data not passed through the compressor yet // give the compressor all the data not passed through the compressor yet
if(w->response.data->len > w->response.sent) { if(w->response.data->len > w->response.sent) {
@ -1931,10 +1931,10 @@ ssize_t web_client_send_deflate(struct web_client *w)
if((w->mode == WEB_CLIENT_MODE_GET || w->mode == WEB_CLIENT_MODE_POST) if((w->mode == WEB_CLIENT_MODE_GET || w->mode == WEB_CLIENT_MODE_POST)
|| (w->mode == WEB_CLIENT_MODE_FILECOPY && !web_client_has_wait_receive(w) && w->response.data->len == w->response.rlen)) { || (w->mode == WEB_CLIENT_MODE_FILECOPY && !web_client_has_wait_receive(w) && w->response.data->len == w->response.rlen)) {
flush = Z_FINISH; flush = Z_FINISH;
debug(D_DEFLATE, "%llu: Requesting Z_FINISH, if possible.", w->id); netdata_log_debug(D_DEFLATE, "%llu: Requesting Z_FINISH, if possible.", w->id);
} }
else { else {
debug(D_DEFLATE, "%llu: Requesting Z_SYNC_FLUSH.", w->id); netdata_log_debug(D_DEFLATE, "%llu: Requesting Z_SYNC_FLUSH.", w->id);
} }
// compress // compress
@ -1950,30 +1950,30 @@ ssize_t web_client_send_deflate(struct web_client *w)
// keep track of the bytes passed through the compressor // keep track of the bytes passed through the compressor
w->response.sent = w->response.data->len; w->response.sent = w->response.data->len;
debug(D_DEFLATE, "%llu: Compression produced %zu bytes.", w->id, w->response.zhave); netdata_log_debug(D_DEFLATE, "%llu: Compression produced %zu bytes.", w->id, w->response.zhave);
// open a new chunk // open a new chunk
ssize_t t2 = web_client_send_chunk_header(w, w->response.zhave); ssize_t t2 = web_client_send_chunk_header(w, w->response.zhave);
if(t2 < 0) return t2; if(t2 < 0) return t2;
t += t2; t += t2;
} }
debug(D_WEB_CLIENT, "%llu: Sending %zu bytes of data (+%zd of chunk header).", w->id, w->response.zhave - w->response.zsent, t); netdata_log_debug(D_WEB_CLIENT, "%llu: Sending %zu bytes of data (+%zd of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
len = web_client_send_data(w,&w->response.zbuffer[w->response.zsent], (size_t) (w->response.zhave - w->response.zsent), MSG_DONTWAIT); len = web_client_send_data(w,&w->response.zbuffer[w->response.zsent], (size_t) (w->response.zhave - w->response.zsent), MSG_DONTWAIT);
if(len > 0) { if(len > 0) {
w->statistics.sent_bytes += len; w->statistics.sent_bytes += len;
w->response.zsent += len; w->response.zsent += len;
len += t; len += t;
debug(D_WEB_CLIENT, "%llu: Sent %zd bytes.", w->id, len); netdata_log_debug(D_WEB_CLIENT, "%llu: Sent %zd bytes.", w->id, len);
} }
else if(len == 0) { else if(len == 0) {
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client (zhave = %zu, zsent = %zu, need to send = %zu).", netdata_log_debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client (zhave = %zu, zsent = %zu, need to send = %zu).",
w->id, w->response.zhave, w->response.zsent, w->response.zhave - w->response.zsent); w->id, w->response.zhave, w->response.zsent, w->response.zhave - w->response.zsent);
} }
else { else {
debug(D_WEB_CLIENT, "%llu: Failed to send data to client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Failed to send data to client.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} }
@ -1988,7 +1988,7 @@ ssize_t web_client_send(struct web_client *w) {
if(unlikely(w->response.data->len - w->response.sent == 0)) { if(unlikely(w->response.data->len - w->response.sent == 0)) {
// there is nothing to send // there is nothing to send
debug(D_WEB_CLIENT, "%llu: Out of output data.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Out of output data.", w->id);
// there can be two cases for this // there can be two cases for this
// A. we have done everything // A. we have done everything
@ -1996,19 +1996,19 @@ ssize_t web_client_send(struct web_client *w) {
if(w->mode == WEB_CLIENT_MODE_FILECOPY && web_client_has_wait_receive(w) && w->response.rlen && w->response.rlen > w->response.data->len) { if(w->mode == WEB_CLIENT_MODE_FILECOPY && web_client_has_wait_receive(w) && w->response.rlen && w->response.rlen > w->response.data->len) {
// we have to wait, more data will come // we have to wait, more data will come
debug(D_WEB_CLIENT, "%llu: Waiting for more data to become available.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Waiting for more data to become available.", w->id);
web_client_disable_wait_send(w); web_client_disable_wait_send(w);
return 0; return 0;
} }
if(unlikely(!web_client_has_keepalive(w))) { if(unlikely(!web_client_has_keepalive(w))) {
debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %zu bytes sent.", w->id, w->response.sent); netdata_log_debug(D_WEB_CLIENT, "%llu: Closing (keep-alive is not enabled). %zu bytes sent.", w->id, w->response.sent);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
return 0; return 0;
} }
web_client_request_done(w); web_client_request_done(w);
debug(D_WEB_CLIENT, "%llu: Done sending all data on socket. Waiting for next request on the same socket.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Done sending all data on socket. Waiting for next request on the same socket.", w->id);
return 0; return 0;
} }
@ -2016,13 +2016,13 @@ ssize_t web_client_send(struct web_client *w) {
if(likely(bytes > 0)) { if(likely(bytes > 0)) {
w->statistics.sent_bytes += bytes; w->statistics.sent_bytes += bytes;
w->response.sent += bytes; w->response.sent += bytes;
debug(D_WEB_CLIENT, "%llu: Sent %zd bytes.", w->id, bytes); netdata_log_debug(D_WEB_CLIENT, "%llu: Sent %zd bytes.", w->id, bytes);
} }
else if(likely(bytes == 0)) { else if(likely(bytes == 0)) {
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client.", w->id);
} }
else { else {
debug(D_WEB_CLIENT, "%llu: Failed to send data to client.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Failed to send data to client.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} }
@ -2046,8 +2046,8 @@ ssize_t web_client_read_file(struct web_client *w)
w->response.data->len += bytes; w->response.data->len += bytes;
w->response.data->buffer[w->response.data->len] = '\0'; w->response.data->buffer[w->response.data->len] = '\0';
debug(D_WEB_CLIENT, "%llu: Read %zd bytes.", w->id, bytes); netdata_log_debug(D_WEB_CLIENT, "%llu: Read %zd bytes.", w->id, bytes);
debug(D_WEB_DATA, "%llu: Read data: '%s'.", w->id, &w->response.data->buffer[old]); netdata_log_debug(D_WEB_DATA, "%llu: Read data: '%s'.", w->id, &w->response.data->buffer[old]);
web_client_enable_wait_send(w); web_client_enable_wait_send(w);
@ -2055,7 +2055,7 @@ ssize_t web_client_read_file(struct web_client *w)
web_client_disable_wait_receive(w); web_client_disable_wait_receive(w);
} }
else if(likely(bytes == 0)) { else if(likely(bytes == 0)) {
debug(D_WEB_CLIENT, "%llu: Out of input file data.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Out of input file data.", w->id);
// if we cannot read, it means we have an error on input. // if we cannot read, it means we have an error on input.
// if however, we are copying a file from ifd to ofd, we should not return an error. // if however, we are copying a file from ifd to ofd, we should not return an error.
@ -2065,7 +2065,7 @@ ssize_t web_client_read_file(struct web_client *w)
// let it finish copying... // let it finish copying...
web_client_disable_wait_receive(w); web_client_disable_wait_receive(w);
debug(D_WEB_CLIENT, "%llu: Read the whole file.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: Read the whole file.", w->id);
if(web_server_mode != WEB_SERVER_MODE_STATIC_THREADED) { if(web_server_mode != WEB_SERVER_MODE_STATIC_THREADED) {
if (w->ifd != w->ofd) close(w->ifd); if (w->ifd != w->ofd) close(w->ifd);
@ -2074,7 +2074,7 @@ ssize_t web_client_read_file(struct web_client *w)
w->ifd = w->ofd; w->ifd = w->ofd;
} }
else { else {
debug(D_WEB_CLIENT, "%llu: read data failed.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: read data failed.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} }
@ -2120,18 +2120,18 @@ ssize_t web_client_receive(struct web_client *w)
w->response.data->len += bytes; w->response.data->len += bytes;
w->response.data->buffer[w->response.data->len] = '\0'; w->response.data->buffer[w->response.data->len] = '\0';
debug(D_WEB_CLIENT, "%llu: Received %zd bytes.", w->id, bytes); netdata_log_debug(D_WEB_CLIENT, "%llu: Received %zd bytes.", w->id, bytes);
debug(D_WEB_DATA, "%llu: Received data: '%s'.", w->id, &w->response.data->buffer[old]); netdata_log_debug(D_WEB_DATA, "%llu: Received data: '%s'.", w->id, &w->response.data->buffer[old]);
} }
else if(unlikely(bytes < 0 && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR))) { else if(unlikely(bytes < 0 && (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR))) {
web_client_enable_wait_receive(w); web_client_enable_wait_receive(w);
return 0; return 0;
} }
else if (bytes < 0) { else if (bytes < 0) {
debug(D_WEB_CLIENT, "%llu: receive data failed.", w->id); netdata_log_debug(D_WEB_CLIENT, "%llu: receive data failed.", w->id);
WEB_CLIENT_IS_DEAD(w); WEB_CLIENT_IS_DEAD(w);
} else } else
debug(D_WEB_CLIENT, "%llu: Received %zd bytes.", w->id, bytes); netdata_log_debug(D_WEB_CLIENT, "%llu: Received %zd bytes.", w->id, bytes);
return(bytes); return(bytes);
} }

View file

@ -48,7 +48,7 @@ void debug_sockets() {
buffer_strcat(wb, (api_sockets.fds_acl_flags[i] & WEB_CLIENT_ACL_MGMT)?"management ":""); buffer_strcat(wb, (api_sockets.fds_acl_flags[i] & WEB_CLIENT_ACL_MGMT)?"management ":"");
buffer_strcat(wb, (api_sockets.fds_acl_flags[i] & WEB_CLIENT_ACL_STREAMING)?"streaming ":""); buffer_strcat(wb, (api_sockets.fds_acl_flags[i] & WEB_CLIENT_ACL_STREAMING)?"streaming ":"");
buffer_strcat(wb, (api_sockets.fds_acl_flags[i] & WEB_CLIENT_ACL_NETDATACONF)?"netdata.conf ":""); buffer_strcat(wb, (api_sockets.fds_acl_flags[i] & WEB_CLIENT_ACL_NETDATACONF)?"netdata.conf ":"");
debug(D_WEB_CLIENT, "Socket fd %d name '%s' acl_flags: %s", netdata_log_debug(D_WEB_CLIENT, "Socket fd %d name '%s' acl_flags: %s",
i, i,
api_sockets.fds_names[i], api_sockets.fds_names[i],
buffer_tostring(wb)); buffer_tostring(wb));