diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2023-01-25 19:04:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 19:04:07 +0000 |
commit | 3e3ff4bee83363dca7cfb838baf1cf316960ed1b (patch) | |
tree | c62e0f721eb67856aeb7043ba4326af38159c850 /daemon | |
parent | bf38a22f323be8fa2b35bf782068d903064530ed (diff) |
Add Collector log (#14309)
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/README.md | 29 | ||||
-rw-r--r-- | daemon/global_statistics.c | 2 | ||||
-rw-r--r-- | daemon/main.c | 5 |
3 files changed, 24 insertions, 12 deletions
diff --git a/daemon/README.md b/daemon/README.md index 45eb27ae27..911075df52 100644 --- a/daemon/README.md +++ b/daemon/README.md @@ -210,25 +210,22 @@ You can send commands during runtime via [netdatacli](/cli/README.md). ## Log files -Netdata uses 3 log files: +Netdata uses 4 log files: 1. `error.log` -2. `access.log` -3. `debug.log` +2. `collector.log` +3. `access.log` +4. `debug.log` -Any of them can be disabled by setting it to `/dev/null` or `none` in `netdata.conf`. By default `error.log` and -`access.log` are enabled. `debug.log` is only enabled if debugging/tracing is also enabled (Netdata needs to be compiled -with debugging enabled). +Any of them can be disabled by setting it to `/dev/null` or `none` in `netdata.conf`. By default `error.log`, +`collector.log`, and `access.log` are enabled. `debug.log` is only enabled if debugging/tracing is also enabled +(Netdata needs to be compiled with debugging enabled). Log files are stored in `/var/log/netdata/` by default. ### error.log -The `error.log` is the `stderr` of the `netdata` daemon and all external plugins -run by `netdata`. - -So if any process, in the Netdata process tree, writes anything to its standard error, -it will appear in `error.log`. +The `error.log` is the `stderr` of the `netdata` daemon . For most Netdata programs (including standard external plugins shipped by netdata), the following lines may appear: @@ -243,6 +240,16 @@ program continues to run. When a Netdata program cannot run at all, a `FATAL` line is logged. +### collector.log + +The `collector.log` is the `stderr` of all [collectors](https://github.com/netdata/netdata/blob/master/collectors/COLLECTORS.md) + run by `netdata`. + +So if any process, in the Netdata process tree, writes anything to its standard error, +it will appear in `collector.log`. + +Data stored inside this file follows pattern already described for `error.log`. + ### access.log The `access.log` logs web requests. The format is: diff --git a/daemon/global_statistics.c b/daemon/global_statistics.c index cb89ed01d9..ea658435fa 100644 --- a/daemon/global_statistics.c +++ b/daemon/global_statistics.c @@ -3783,7 +3783,7 @@ static int read_thread_cpu_time_from_proc_stat(pid_t pid __maybe_unused, kernel_ // (re)open the procfile to the new filename bool set_quotes = (ff == NULL) ? true : false; - ff = procfile_reopen(ff, filename, NULL, PROCFILE_FLAG_DEFAULT); + ff = procfile_reopen(ff, filename, NULL, PROCFILE_FLAG_ERROR_ON_ERROR_LOG); if(unlikely(!ff)) return -1; if(set_quotes) diff --git a/daemon/main.c b/daemon/main.c index 1eff318f1a..608985bddf 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -831,6 +831,9 @@ static void log_init(void) { snprintfz(filename, FILENAME_MAX, "%s/error.log", netdata_configured_log_dir); stderr_filename = config_get(CONFIG_SECTION_LOGS, "error", filename); + snprintfz(filename, FILENAME_MAX, "%s/collector.log", netdata_configured_log_dir); + stdcollector_filename = config_get(CONFIG_SECTION_LOGS, "collector", filename); + snprintfz(filename, FILENAME_MAX, "%s/access.log", netdata_configured_log_dir); stdaccess_filename = config_get(CONFIG_SECTION_LOGS, "access", filename); @@ -1320,6 +1323,8 @@ int main(int argc, char **argv) { usec_t started_ut = now_monotonic_usec(); usec_t last_ut = started_ut; const char *prev_msg = NULL; + // Initialize stderror avoiding coredump when info() or error() is called + stderror = stderr; int i; int config_loaded = 0; |