From 6624c175344cc631c452d19eb1d3e25f0853598a Mon Sep 17 00:00:00 2001 From: f0o Date: Sun, 17 May 2015 12:13:52 +0000 Subject: [PATCH] Allow a user-defined window to add tolerance to delay-values This is to counter cronjob irregularities as they arent always executed on *:00 dead --- alerts.php | 2 +- doc/Extensions/Alerting.md | 4 ++-- includes/defaults.inc.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/alerts.php b/alerts.php index b7c6acc63b..d7b4f8d55c 100755 --- a/alerts.php +++ b/alerts.php @@ -191,7 +191,7 @@ function RunAlerts() { $noiss = true; } if( !empty($rextra['delay']) ) { - if( (time()-strtotime($alert['time_logged'])) < $rextra['delay'] || (!empty($alert['details']['delay']) && (time()-$alert['details']['delay']) < $rextra['delay']) ) { + if( (time()-strtotime($alert['time_logged'])+$config['alert']['tolerance-window']) < $rextra['delay'] || (!empty($alert['details']['delay']) && (time()-$alert['details']['delay']+$config['alert']['tolerance-window']) < $rextra['delay']) ) { continue; } else { $alert['details']['delay'] = time(); diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 5c170cf108..1bfba162fd 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -152,8 +152,8 @@ $config['email_smtp_auth'] = FALSE; // Whether or $config['email_smtp_username'] = NULL; // SMTP username. $config['email_smtp_password'] = NULL; // Password for SMTP authentication. -$config['alerts']['email']['default_only'] = FALSE; // Only send alerts to default-contact -$config['alerts']['email']['default'] = NULL; // Default-Contact +$config['alert']['default_only'] = false; //Only issue to default_mail +$config['alert']['default_mail'] = ''; //Default email ``` ## API diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index b8943412f4..dca985947d 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -237,6 +237,7 @@ $config['alert'] = array( 'admins' => false, //Issue to administrators 'default_only' => false, //Only issue to default 'default_mail' => '', //Default email + 'tolerance-window' => 10, //Allow +/-10s tolerance to delay values to counter cron-irregularities ); //Legacy options