diff options
author | Urban Müller | 2017-06-22 18:02:58 +0200 |
---|---|---|
committer | Urban Müller | 2017-06-22 18:02:58 +0200 |
commit | 434f607ada78cb2a2b4c6dadb09d040c8bbe161e (patch) | |
tree | 874cad3dcaa9e9c456927e6a41df3cbc5d71bd5f | |
parent | 7ef973af86c070965a4d7c1caf3b13844c4c741b (diff) | |
download | itools-434f607ada78cb2a2b4c6dadb09d040c8bbe161e.tar.gz itools-434f607ada78cb2a2b4c6dadb09d040c8bbe161e.tar.bz2 itools-434f607ada78cb2a2b4c6dadb09d040c8bbe161e.zip |
only send error mails once per cluster and service
-rw-r--r-- | it.class | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -162,7 +162,7 @@ static function error($p = array()) 'omitdebuginfo' => false, 'failcount' => 2, ); - $p += array('blockmailid' => md5($p['to'])); + $p += array('blockmailid' => $GLOBALS['ULTRASITE'] . "." . md5($p['to'])); @mkdir("/tmp/alertdata"); @chmod("/tmp/alertdata", 0777); @@ -199,15 +199,14 @@ static function error($p = array()) if ($sendmail) { - $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . urlencode($p['blockmailid']); - $now = time(); + $lastsentfn = "/tmp/alertdata/it_error_mailsent_" . urlencode($p['blockmailid']); clearstatcache(); - $lastsenttime = @filemtime($lastsentfn); - $sendmail = $now - $lastsenttime > $p['blockmail']; + $sendmail = time() - max(@filemtime($lastsentfn), it_cache::get($lastsentfn, ['distributed' => true])) > $p['blockmail']; if ($sendmail) { @unlink($lastsentfn); @touch($lastsentfn); + it_cache::put($lastsentfn, time(), ['distributed' => true, 'ttl' => 7*86400, 'safety' => 0]); } } } |