]> arthur.barton.de Git - netdata.git/commitdiff
allow certain parts of netdata to run with log flood protection temporarily disabled
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 4 Sep 2016 11:42:49 +0000 (14:42 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 4 Sep 2016 11:42:49 +0000 (14:42 +0300)
src/daemon.c
src/log.c
src/log.h
src/main.c

index bc4614f079063f33d8902f5d52fa259404653900..1c34405d826a89902580af25316b532ae9480f86 100644 (file)
@@ -15,27 +15,30 @@ void sig_handler_exit(int signo)
 void sig_handler_logrotate(int signo)
 {
     if(signo) {
-        error_log_limit_reset();
+        error_log_limit_unlimited();
         info("Received signal %d to re-open the log files", signo);
         reopen_all_log_files();
+        error_log_limit_reset();
     }
 }
 
 void sig_handler_save(int signo)
 {
     if(signo) {
-        error_log_limit_reset();
+        error_log_limit_unlimited();
         info("Received signal %d to save the database...", signo);
         rrdset_save_all();
+        error_log_limit_reset();
     }
 }
 
 void sig_handler_reload_health(int signo)
 {
     if(signo) {
-        error_log_limit_reset();
+        error_log_limit_unlimited();
         info("Received signal %d to reload health configuration...", signo);
         health_reload();
+        error_log_limit_reset();
     }
 }
 
index e952c57243c3f278a4fa25321a85c111f9f9768b..fbb172b0a05450c6de2f608379766b1289094464 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -111,6 +111,7 @@ void open_all_log_files() {
 // ----------------------------------------------------------------------------
 // error log throttling
 
+time_t error_log_throttle_period_backup = 0;
 time_t error_log_throttle_period = 1200;
 unsigned long error_log_errors_per_period = 200;
 
index 93d95321ee3599d36276d8388a8a3ffa7f17b097..3a022fc93959cba965940bb66b21c9ad6943fac5 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -45,14 +45,14 @@ extern int access_log_syslog;
 extern int error_log_syslog;
 extern int output_log_syslog;
 
-extern time_t error_log_throttle_period;
+extern time_t error_log_throttle_period, error_log_throttle_period_backup;
 extern unsigned long error_log_errors_per_period;
 extern int error_log_limit(int reset);
 
 extern void open_all_log_files();
 extern void reopen_all_log_files();
 
-#define error_log_limit_reset() do { error_log_limit(1); } while(0)
+#define error_log_limit_reset() do { error_log_throttle_period = error_log_throttle_period_backup; error_log_limit(1); } while(0)
 #define error_log_limit_unlimited() do { error_log_throttle_period = 0; } while(0)
 
 #define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
index 3db28e4f81e90e5d0783fca789ca525076dcb5e7..5dbd575805c870d90891d086528aa02c4f5d7123 100644 (file)
@@ -478,7 +478,8 @@ int main(int argc, char **argv)
         stderr_filename    = config_get("global", "error log",  LOG_DIR "/error.log");
         stdaccess_filename = config_get("global", "access log", LOG_DIR "/access.log");
 
-        error_log_throttle_period = config_get_number("global", "errors flood protection period", error_log_throttle_period);
+        error_log_throttle_period_backup =
+            error_log_throttle_period = config_get_number("global", "errors flood protection period", error_log_throttle_period);
         setenv("NETDATA_ERRORS_THROTTLE_PERIOD", config_get("global", "errors flood protection period"    , ""), 1);
 
         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)
             error_log_throttle_period = 0;
             error_log_errors_per_period = 0;
         }
+        error_log_limit_unlimited();
 
         // --------------------------------------------------------------------
 
@@ -665,6 +667,11 @@ int main(int argc, char **argv)
     if(check_config)
         exit(1);
 
+    // ------------------------------------------------------------------------
+    // enable log flood protection
+
+    error_log_limit_reset();
+
     // ------------------------------------------------------------------------
     // spawn the threads