allow certain parts of netdata to run with log flood protection temporarily disabled
Costa Tsaousis (ktsaou) committed
Sep 4, 2016 at 14:42 UTC
e2df878c7b1b91522dadeee0ce1b9e95c4ee4026
4 files changed
+17
-6
src/daemon.c
+6
-3
@@ -15,27 +15,30 @@ void sig_handler_exit(int signo)
15
void sig_handler_logrotate(int signo)
16
{
17
if(signo) {
18
- error_log_limit_reset();
18
+ error_log_limit_unlimited();
19
info("Received signal %d to re-open the log files", signo);
20
reopen_all_log_files();
21
+ error_log_limit_reset();
22
}
23
}
24
25
void sig_handler_save(int signo)
26
{
27
if(signo) {
27
- error_log_limit_reset();
28
+ error_log_limit_unlimited();
29
info("Received signal %d to save the database...", signo);
30
rrdset_save_all();
31
+ error_log_limit_reset();
32
}
33
}
34
35
void sig_handler_reload_health(int signo)
36
{
37
if(signo) {
36
- error_log_limit_reset();
38
+ error_log_limit_unlimited();
39
info("Received signal %d to reload health configuration...", signo);
40
health_reload();
41
+ error_log_limit_reset();
42
}
43
}
44
src/log.c
+1
@@ -111,6 +111,7 @@ void open_all_log_files() {
111
// ----------------------------------------------------------------------------
112
// error log throttling
113
114
+time_t error_log_throttle_period_backup = 0;
115
time_t error_log_throttle_period = 1200;
116
unsigned long error_log_errors_per_period = 200;
117
src/log.h
+2
-2
@@ -45,14 +45,14 @@ extern int access_log_syslog;
45
extern int error_log_syslog;
46
extern int output_log_syslog;
47
48
-extern time_t error_log_throttle_period;
48
+extern time_t error_log_throttle_period, error_log_throttle_period_backup;
49
extern unsigned long error_log_errors_per_period;
50
extern int error_log_limit(int reset);
51
52
extern void open_all_log_files();
53
extern void reopen_all_log_files();
54
55
-#define error_log_limit_reset() do { error_log_limit(1); } while(0)
55
+#define error_log_limit_reset() do { error_log_throttle_period = error_log_throttle_period_backup; error_log_limit(1); } while(0)
56
#define error_log_limit_unlimited() do { error_log_throttle_period = 0; } while(0)
57
58
#define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
src/main.c
+8
-1
@@ -478,7 +478,8 @@ int main(int argc, char **argv)
478
stderr_filename = config_get("global", "error log", LOG_DIR "/error.log");
479
stdaccess_filename = config_get("global", "access log", LOG_DIR "/access.log");
480
481
- error_log_throttle_period = config_get_number("global", "errors flood protection period", error_log_throttle_period);
481
+ error_log_throttle_period_backup =
482
+ error_log_throttle_period = config_get_number("global", "errors flood protection period", error_log_throttle_period);
483
setenv("NETDATA_ERRORS_THROTTLE_PERIOD", config_get("global", "errors flood protection period" , ""), 1);
484
485
error_log_errors_per_period = (unsigned long)config_get_number("global", "errors to trigger flood protection", error_log_errors_per_period);
@@ -489,6 +490,7 @@ int main(int argc, char **argv)
490
error_log_throttle_period = 0;
491
error_log_errors_per_period = 0;
492
}
493
+ error_log_limit_unlimited();
494
495
// --------------------------------------------------------------------
496
@@ -665,6 +667,11 @@ int main(int argc, char **argv)
667
if(check_config)
668
exit(1);
669
670
+ // ------------------------------------------------------------------------
671
+ // enable log flood protection
672
+
673
+ error_log_limit_reset();
674
+
675
// ------------------------------------------------------------------------
676
// spawn the threads
677