summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2017-06-22 18:02:58 +0200
committerUrban Müller2017-06-22 18:02:58 +0200
commit434f607ada78cb2a2b4c6dadb09d040c8bbe161e (patch)
tree874cad3dcaa9e9c456927e6a41df3cbc5d71bd5f
parent7ef973af86c070965a4d7c1caf3b13844c4c741b (diff)
downloaditools-434f607ada78cb2a2b4c6dadb09d040c8bbe161e.tar.gz
itools-434f607ada78cb2a2b4c6dadb09d040c8bbe161e.tar.bz2
itools-434f607ada78cb2a2b4c6dadb09d040c8bbe161e.zip
only send error mails once per cluster and service
-rw-r--r--it.class9
1 files changed, 4 insertions, 5 deletions
diff --git a/it.class b/it.class
index 3e83081..8d47b3d 100644
--- a/it.class
+++ b/it.class
@@ -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]);
}
}
}