diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2024-01-20 15:51:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-20 15:51:39 +0200 |
commit | 4b5453e197af9c61a4465d8fe34ab860bef2c49b (patch) | |
tree | bb004a88abfd669666dc1f900c337fdcef3b34cf | |
parent | b9a6eddd1d7e62470d4fc2e08aea3ebc6a5eedd6 (diff) |
fix verify_netdata_host_prefix log spam (#16814)
-rw-r--r-- | collectors/apps.plugin/apps_plugin.c | 2 | ||||
-rw-r--r-- | collectors/cgroups.plugin/cgroup-network.c | 2 | ||||
-rw-r--r-- | collectors/debugfs.plugin/debugfs_plugin.c | 2 | ||||
-rw-r--r-- | collectors/ebpf.plugin/ebpf.c | 2 | ||||
-rw-r--r-- | collectors/systemd-journal.plugin/systemd-main.c | 2 | ||||
-rw-r--r-- | daemon/main.c | 2 | ||||
-rw-r--r-- | libnetdata/libnetdata.c | 11 | ||||
-rw-r--r-- | libnetdata/libnetdata.h | 2 | ||||
-rw-r--r-- | logsmanagement/logsmanagement.c | 2 |
9 files changed, 15 insertions, 12 deletions
diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c index 1aa306a992..6caad8cb1b 100644 --- a/collectors/apps.plugin/apps_plugin.c +++ b/collectors/apps.plugin/apps_plugin.c @@ -5270,7 +5270,7 @@ int main(int argc, char **argv) { procfile_open_flags = O_RDONLY|O_NOFOLLOW; netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - if(verify_netdata_host_prefix() == -1) exit(1); + if(verify_netdata_host_prefix(true) == -1) exit(1); user_config_dir = getenv("NETDATA_USER_CONFIG_DIR"); if(user_config_dir == NULL) { diff --git a/collectors/cgroups.plugin/cgroup-network.c b/collectors/cgroups.plugin/cgroup-network.c index 79c78732a5..508ea07c68 100644 --- a/collectors/cgroups.plugin/cgroup-network.c +++ b/collectors/cgroups.plugin/cgroup-network.c @@ -666,7 +666,7 @@ int main(int argc, char **argv) { // make sure NETDATA_HOST_PREFIX is safe netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - if(verify_netdata_host_prefix() == -1) exit(1); + if(verify_netdata_host_prefix(false) == -1) exit(1); if(netdata_configured_host_prefix[0] != '\0' && verify_path(netdata_configured_host_prefix) == -1) fatal("invalid NETDATA_HOST_PREFIX '%s'", netdata_configured_host_prefix); diff --git a/collectors/debugfs.plugin/debugfs_plugin.c b/collectors/debugfs.plugin/debugfs_plugin.c index f66e4aa1bd..94e3db6319 100644 --- a/collectors/debugfs.plugin/debugfs_plugin.c +++ b/collectors/debugfs.plugin/debugfs_plugin.c @@ -163,7 +163,7 @@ int main(int argc, char **argv) nd_log_initialize_for_external_plugins("debugfs.plugin"); netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - if (verify_netdata_host_prefix() == -1) + if (verify_netdata_host_prefix(true) == -1) exit(1); user_config_dir = getenv("NETDATA_USER_CONFIG_DIR"); diff --git a/collectors/ebpf.plugin/ebpf.c b/collectors/ebpf.plugin/ebpf.c index 3ad701505b..c46688895f 100644 --- a/collectors/ebpf.plugin/ebpf.c +++ b/collectors/ebpf.plugin/ebpf.c @@ -4031,7 +4031,7 @@ int main(int argc, char **argv) ebpf_start_pthread_variables(); netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - if(verify_netdata_host_prefix() == -1) ebpf_exit(6); + if(verify_netdata_host_prefix(true) == -1) ebpf_exit(6); ebpf_allocate_common_vectors(); diff --git a/collectors/systemd-journal.plugin/systemd-main.c b/collectors/systemd-journal.plugin/systemd-main.c index f0c15c3c1b..e9f4ebd4cc 100644 --- a/collectors/systemd-journal.plugin/systemd-main.c +++ b/collectors/systemd-journal.plugin/systemd-main.c @@ -23,7 +23,7 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) { nd_log_initialize_for_external_plugins("systemd-journal.plugin"); netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - if(verify_netdata_host_prefix() == -1) exit(1); + if(verify_netdata_host_prefix(true) == -1) exit(1); // ------------------------------------------------------------------------ // initialization diff --git a/daemon/main.c b/daemon/main.c index a88fef5e1f..b096f13710 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1116,7 +1116,7 @@ static void get_netdata_configured_variables() { // get the hostname netdata_configured_host_prefix = config_get(CONFIG_SECTION_GLOBAL, "host access prefix", ""); - verify_netdata_host_prefix(); + verify_netdata_host_prefix(true); char buf[HOSTNAME_MAX + 1]; if (get_hostname(buf, HOSTNAME_MAX)) diff --git a/libnetdata/libnetdata.c b/libnetdata/libnetdata.c index 1c764e7956..e23dd798a5 100644 --- a/libnetdata/libnetdata.c +++ b/libnetdata/libnetdata.c @@ -1329,7 +1329,7 @@ static int is_virtual_filesystem(const char *path, char **reason) { return 0; } -int verify_netdata_host_prefix() { +int verify_netdata_host_prefix(bool log_msg) { if(!netdata_configured_host_prefix) netdata_configured_host_prefix = ""; @@ -1362,13 +1362,16 @@ int verify_netdata_host_prefix() { if(is_virtual_filesystem(path, &reason) == -1) goto failed; - if(netdata_configured_host_prefix && *netdata_configured_host_prefix) - netdata_log_info("Using host prefix directory '%s'", netdata_configured_host_prefix); + if (netdata_configured_host_prefix && *netdata_configured_host_prefix) { + if (log_msg) + netdata_log_info("Using host prefix directory '%s'", netdata_configured_host_prefix); + } return 0; failed: - netdata_log_error("Ignoring host prefix '%s': path '%s' %s", netdata_configured_host_prefix, path, reason); + if (log_msg) + netdata_log_error("Ignoring host prefix '%s': path '%s' %s", netdata_configured_host_prefix, path, reason); netdata_configured_host_prefix = ""; return -1; } diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h index 12a4232973..78513d0bce 100644 --- a/libnetdata/libnetdata.h +++ b/libnetdata/libnetdata.h @@ -559,7 +559,7 @@ extern int enable_ksm; char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len); -int verify_netdata_host_prefix(); +int verify_netdata_host_prefix(bool log_msg); extern volatile sig_atomic_t netdata_exit; diff --git a/logsmanagement/logsmanagement.c b/logsmanagement/logsmanagement.c index 7ab0023ad6..05c18d3434 100644 --- a/logsmanagement/logsmanagement.c +++ b/logsmanagement/logsmanagement.c @@ -79,7 +79,7 @@ int main(int argc, char **argv) { nd_log_initialize_for_external_plugins(program_name); // netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX"); - // if(verify_netdata_host_prefix() == -1) exit(1); + // if(verify_netdata_host_prefix(true) == -1) exit(1); int g_update_every = 0; for(int i = 1; i < argc ; i++) { |