From c330b7962ae9af5093cfe47e9cb981f6e9720ca2 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 5 Feb 2007 15:50:28 +0000 Subject: grace period for it::error --- it.class | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/it.class b/it.class index e79f228..e02ba5f 100644 --- a/it.class +++ b/it.class @@ -67,7 +67,7 @@ function timerlog($label = '') * @param $to (optional) comma separated recipient list * @param named parameter id identifier of error. if given, only subsequent errors of same id will trigger message * @param named parameter timewindow number of seconds within which the second error must occur - * @param named parameter interval minimum number of seconds between alerts + * @param named parameter graceperiod numer of seconds within which additional errors are ignored */ function error($p = array(), $body = "", $to = "") { @@ -83,7 +83,7 @@ function error($p = array(), $body = "", $to = "") $p = array(); } - $p += array('timewindow' => 25*3600, 'interval' => 6*3600); + $p += array('timewindow' => 25*3600, 'graceperiod' => 60); if (!$to) $to = strtr(trim(@file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>',', ' '=>'')); @@ -93,10 +93,10 @@ function error($p = array(), $body = "", $to = "") $stampfn = $GLOBALS['ULTRAHOME'] . "/tmp/errstamp_" . urlencode($p['id']); $stampage = time() - @filemtime($stampfn); - if ($stampage >= 60 && $stampage <= $p['timewindow']) + if ($stampage >= $p['graceperiod'] && $stampage <= $p['timewindow']) $sendalert = true; - if ($stampage >= 60) # constantly occurring errors should not suppress mail + if ($stampage >= $p['graceperiod']) # constantly occurring errors should not suppress mail touch($stampfn); } else @@ -116,7 +116,7 @@ function error($p = array(), $body = "", $to = "") } else { - $cmd = "alert -l -i " . escapeshellarg($p['interval']) ." " . escapeshellarg($to) . " 4 " . escapeshellarg($title); + $cmd = "alert -l " . escapeshellarg($to) . " 4 " . escapeshellarg($title); EDC('exec', $cmd); if (($pipe = popen($cmd, "w"))) -- cgit v1.2.3