fix verify_netdata_host_prefix log spam (#16814)
Ilya Mashchenko committed
Jan 20, 2024 at 15:51 UTC
4b5453e197af9c61a4465d8fe34ab860bef2c49b
9 files changed
+15
-12
collectors/apps.plugin/apps_plugin.c
+1
-1
@@ -5270,7 +5270,7 @@ int main(int argc, char **argv) {
5270
procfile_open_flags = O_RDONLY|O_NOFOLLOW;
5271
5272
netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
5273
- if(verify_netdata_host_prefix() == -1) exit(1);
5273
+ if(verify_netdata_host_prefix(true) == -1) exit(1);
5274
5275
user_config_dir = getenv("NETDATA_USER_CONFIG_DIR");
5276
if(user_config_dir == NULL) {
collectors/cgroups.plugin/cgroup-network.c
+1
-1
@@ -666,7 +666,7 @@ int main(int argc, char **argv) {
666
// make sure NETDATA_HOST_PREFIX is safe
667
668
netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
669
- if(verify_netdata_host_prefix() == -1) exit(1);
669
+ if(verify_netdata_host_prefix(false) == -1) exit(1);
670
671
if(netdata_configured_host_prefix[0] != '\0' && verify_path(netdata_configured_host_prefix) == -1)
672
fatal("invalid NETDATA_HOST_PREFIX '%s'", netdata_configured_host_prefix);
collectors/debugfs.plugin/debugfs_plugin.c
+1
-1
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
163
nd_log_initialize_for_external_plugins("debugfs.plugin");
164
165
netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
166
- if (verify_netdata_host_prefix() == -1)
166
+ if (verify_netdata_host_prefix(true) == -1)
167
exit(1);
168
169
user_config_dir = getenv("NETDATA_USER_CONFIG_DIR");
collectors/ebpf.plugin/ebpf.c
+1
-1
@@ -4031,7 +4031,7 @@ int main(int argc, char **argv)
4031
ebpf_start_pthread_variables();
4032
4033
netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
4034
- if(verify_netdata_host_prefix() == -1) ebpf_exit(6);
4034
+ if(verify_netdata_host_prefix(true) == -1) ebpf_exit(6);
4035
4036
ebpf_allocate_common_vectors();
4037
collectors/systemd-journal.plugin/systemd-main.c
+1
-1
@@ -23,7 +23,7 @@ int main(int argc __maybe_unused, char **argv __maybe_unused) {
23
nd_log_initialize_for_external_plugins("systemd-journal.plugin");
24
25
netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
26
- if(verify_netdata_host_prefix() == -1) exit(1);
26
+ if(verify_netdata_host_prefix(true) == -1) exit(1);
27
28
// ------------------------------------------------------------------------
29
// initialization
daemon/main.c
+1
-1
@@ -1116,7 +1116,7 @@ static void get_netdata_configured_variables() {
1116
// get the hostname
1117
1118
netdata_configured_host_prefix = config_get(CONFIG_SECTION_GLOBAL, "host access prefix", "");
1119
- verify_netdata_host_prefix();
1119
+ verify_netdata_host_prefix(true);
1120
1121
char buf[HOSTNAME_MAX + 1];
1122
if (get_hostname(buf, HOSTNAME_MAX))
libnetdata/libnetdata.c
+7
-4
@@ -1329,7 +1329,7 @@ static int is_virtual_filesystem(const char *path, char **reason) {
1329
return 0;
1330
}
1331
1332
-int verify_netdata_host_prefix() {
1332
+int verify_netdata_host_prefix(bool log_msg) {
1333
if(!netdata_configured_host_prefix)
1334
netdata_configured_host_prefix = "";
1335
@@ -1362,13 +1362,16 @@ int verify_netdata_host_prefix() {
1362
if(is_virtual_filesystem(path, &reason) == -1)
1363
goto failed;
1364
1365
- if(netdata_configured_host_prefix && *netdata_configured_host_prefix)
1366
- netdata_log_info("Using host prefix directory '%s'", netdata_configured_host_prefix);
1365
+ if (netdata_configured_host_prefix && *netdata_configured_host_prefix) {
1366
+ if (log_msg)
1367
+ netdata_log_info("Using host prefix directory '%s'", netdata_configured_host_prefix);
1368
+ }
1369
1370
return 0;
1371
1372
failed:
1371
- netdata_log_error("Ignoring host prefix '%s': path '%s' %s", netdata_configured_host_prefix, path, reason);
1373
+ if (log_msg)
1374
+ netdata_log_error("Ignoring host prefix '%s': path '%s' %s", netdata_configured_host_prefix, path, reason);
1375
netdata_configured_host_prefix = "";
1376
return -1;
1377
}
libnetdata/libnetdata.h
+1
-1
@@ -559,7 +559,7 @@ extern int enable_ksm;
559
560
char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len);
561
562
-int verify_netdata_host_prefix();
562
+int verify_netdata_host_prefix(bool log_msg);
563
564
extern volatile sig_atomic_t netdata_exit;
565
logsmanagement/logsmanagement.c
+1
-1
@@ -79,7 +79,7 @@ int main(int argc, char **argv) {
79
nd_log_initialize_for_external_plugins(program_name);
80
81
// netdata_configured_host_prefix = getenv("NETDATA_HOST_PREFIX");
82
- // if(verify_netdata_host_prefix() == -1) exit(1);
82
+ // if(verify_netdata_host_prefix(true) == -1) exit(1);
83
84
int g_update_every = 0;
85
for(int i = 1; i < argc ; i++) {