summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2018-10-03 12:03:44 +0300
committerGitHub <noreply@github.com>2018-10-03 12:03:44 +0300
commitf934da9731e5995afbc3561a2a7cfb4f7945b619 (patch)
tree07ff298d3b7e3a765efe9470de252af908334c3b /src
parent843e236b4639617500f492f801df3a0c0f1460e7 (diff)
log flood should not be disabled; (#4344)
* log flood should not be disabled; #4312 * use 10x the logs with the minimum of 10000
Diffstat (limited to 'src')
-rw-r--r--src/log.c10
-rw-r--r--src/log.h11
-rw-r--r--src/main.c2
3 files changed, 14 insertions, 9 deletions
diff --git a/src/log.c b/src/log.c
index b9d47df71b..ceffb209ab 100644
--- a/src/log.c
+++ b/src/log.c
@@ -161,14 +161,16 @@ 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;
+unsigned long error_log_errors_per_period_backup = 0;
int error_log_limit(int reset) {
static time_t start = 0;
static unsigned long counter = 0, prevented = 0;
+ // fprintf(stderr, "FLOOD: counter=%lu, allowed=%lu, backup=%lu, period=%llu\n", counter, error_log_errors_per_period, error_log_errors_per_period_backup, (unsigned long long)error_log_throttle_period);
+
// do not throttle if the period is 0
if(error_log_throttle_period == 0)
return 0;
@@ -188,7 +190,7 @@ int error_log_limit(int reset) {
if(prevented) {
char date[LOG_DATE_LENGTH];
log_date(date, LOG_DATE_LENGTH);
- fprintf(stderr, "%s: %s Resetting logging for process '%s' (prevented %lu logs in the last %ld seconds).\n"
+ fprintf(stderr, "%s: %s LOG FLOOD PROTECTION reset for process '%s' (prevented %lu logs in the last %ld seconds).\n"
, date
, program_name
, program_name
@@ -209,7 +211,7 @@ int error_log_limit(int reset) {
if(prevented) {
char date[LOG_DATE_LENGTH];
log_date(date, LOG_DATE_LENGTH);
- fprintf(stderr, "%s: %s Resuming logging from process '%s' (prevented %lu logs in the last %ld seconds).\n"
+ fprintf(stderr, "%s: %s LOG FLOOD PROTECTION resuming logging from process '%s' (prevented %lu logs in the last %ld seconds).\n"
, date
, program_name
, program_name
@@ -231,7 +233,7 @@ int error_log_limit(int reset) {
if(!prevented) {
char date[LOG_DATE_LENGTH];
log_date(date, LOG_DATE_LENGTH);
- fprintf(stderr, "%s: %s Too many logs (%lu logs in %ld seconds, threshold is set to %lu logs in %ld seconds). Preventing more logs from process '%s' for %ld seconds.\n"
+ fprintf(stderr, "%s: %s LOG FLOOD PROTECTION too many logs (%lu logs in %ld seconds, threshold is set to %lu logs in %ld seconds). Preventing more logs from process '%s' for %ld seconds.\n"
, date
, program_name
, counter
diff --git a/src/log.h b/src/log.h
index d5faac6e90..032fbf9788 100644
--- a/src/log.h
+++ b/src/log.h
@@ -59,8 +59,8 @@ extern int access_log_syslog;
extern int error_log_syslog;
extern int output_log_syslog;
-extern time_t error_log_throttle_period, error_log_throttle_period_backup;
-extern unsigned long error_log_errors_per_period;
+extern time_t error_log_throttle_period;
+extern unsigned long error_log_errors_per_period, error_log_errors_per_period_backup;
extern int error_log_limit(int reset);
extern void open_all_log_files();
@@ -68,8 +68,11 @@ extern void reopen_all_log_files();
static inline void debug_dummy(void) {}
-#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 error_log_limit_reset() do { error_log_errors_per_period = error_log_errors_per_period_backup; error_log_limit(1); } while(0)
+#define error_log_limit_unlimited() do { \
+ error_log_limit_reset(); \
+ error_log_errors_per_period = ((error_log_errors_per_period_backup * 10) < 10000) ? 10000 : (error_log_errors_per_period_backup * 10); \
+ } while(0)
#ifdef NETDATA_INTERNAL_CHECKS
#define debug(type, args...) do { if(unlikely(debug_flags & type)) debug_int(__FILE__, __FUNCTION__, __LINE__, ##args); } while(0)
diff --git a/src/main.c b/src/main.c
index b80ecccf75..85f7a0a2e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -359,9 +359,9 @@ void log_init(void) {
snprintfz(filename, FILENAME_MAX, "%s/access.log", netdata_configured_log_dir);
stdaccess_filename = config_get(CONFIG_SECTION_GLOBAL, "access log", filename);
- error_log_throttle_period_backup =
error_log_throttle_period = config_get_number(CONFIG_SECTION_GLOBAL, "errors flood protection period", error_log_throttle_period);
error_log_errors_per_period = (unsigned long)config_get_number(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection", (long long int)error_log_errors_per_period);
+ error_log_errors_per_period_backup = error_log_errors_per_period;
setenv("NETDATA_ERRORS_THROTTLE_PERIOD", config_get(CONFIG_SECTION_GLOBAL, "errors flood protection period" , ""), 1);
setenv("NETDATA_ERRORS_PER_PERIOD", config_get(CONFIG_SECTION_GLOBAL, "errors to trigger flood protection", ""), 1);