summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2017-12-18 16:55:07 +0100
committerUrban Müller2017-12-18 16:55:07 +0100
commit3ef4cba3eb9e2978195c41c05e1e4a0581c76c5d (patch)
treeb54a6f1331c871643f0249f46bbe64fa362820da
parent440f08f07dab0233716937e432d921436a342ee1 (diff)
downloaditools-3ef4cba3eb9e2978195c41c05e1e4a0581c76c5d.tar.gz
itools-3ef4cba3eb9e2978195c41c05e1e4a0581c76c5d.tar.bz2
itools-3ef4cba3eb9e2978195c41c05e1e4a0581c76c5d.zip
show blockmail parameters, show most recent errors
-rw-r--r--it.class14
1 files changed, 8 insertions, 6 deletions
diff --git a/it.class b/it.class
index 0ca1460..9b31421 100644
--- a/it.class
+++ b/it.class
@@ -85,7 +85,8 @@ static function log($name /* ... */)
* @param $name Name of logfile. Will be in log/ of service unless it starts with /
* @param $line Line to log.
*/
-static function log_line($name, $line) {
+static function log_line($name, $line)
+{
$basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name";
$fullfn = $basefn . "-" . date('Ymd');
@@ -154,7 +155,7 @@ static function timerlog($label = '')
*/
static function error($p = array())
{
- $p = (array)$p;
+ $p = $origp = (array)$p;
$p['title'] = $p[0] ?: $p['title']; # handle 'it_error' => "oops" that was cast to array on the way
if (!error_reporting() || $p[0] === false || $p['title'] === false) # called with @ or suppressed
@@ -261,9 +262,11 @@ static function error($p = array())
$stackframes[] = $stackframe;
$body .= "Host: " . getenv('HOSTNAME') . "\n\n";
- $body .= $p['id'] ? "Filter: timewindow=" . $p['graceperiod'] . "-" . ($p['graceperiod'] + $p['timewindow']) . " (previous err: " . it::date('', $errstamp) . ")\n\n" : "";
$body .= "Time: " . date("Y-m-d H:i:s") . (($t = time() - $_SERVER['REQUEST_TIME']) ? " (started {$t}s before)" : "") . "\n\n"; # no it::date() due to time- debug param
- $body .= "Overview: ssh " . getenv('HOSTNAME') . " 'tail -100000 /tmp/alertdata/alert.log | grep \"$trace\"'\n\n";
+ $body .= $p['id'] ? "Filter: timewindow=" . $p['graceperiod'] . "-" . ($p['graceperiod'] + $p['timewindow']) . " (previous err: " . it::date('', $errstamp) . ")\n\n" : "";
+ $body .= $origp['blockmail'] ? "Block-resend: " . $origp['blockmail'] . " seconds\n\n" : "";
+ $body .= "Overview: ssh " . getenv('HOSTNAME') . " 'cat /tmp/alertdata/alertlog | grep \"$trace\"'\n\n";
+ $body .= ($t = it::exec('grep {0} /tmp/alertdata/alertlog 2>/dev/null | tail -10 | cut -b 1-100', $trace)) ? "Most-recent: (last 10 today)\n$t\n" : "";
$body .= $_GET ? "\$_GET: " . var_export($_GET, true) . "\n\n" : "";
$body .= $_POST ? "\$_POST: " . var_export($_POST, true) . "\n\n" : "";
$body .= $_COOKIE ? "\$_COOKIE: " . var_export($_COOKIE, true) . "\n\n" : "";
@@ -287,8 +290,7 @@ static function error($p = array())
if ($_SERVER['REMOTE_ADDR']) # additional entry in log/error_log
error_log("it::error: " . $p['title'] . " Url: $url");
- file_put_contents("/tmp/alertdata/alert.log", date("Y-m-d H:i:s") . " " . $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url\n", FILE_APPEND);
- @chmod("/tmp/alertdata/alert.log", 0777);
+ it::log("/tmp/alertdata/alertlog", $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url");
if ($p['fatal'])
exit(99);