From 86786178c0bca29d05b4afc8799633dfb23fc842 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Tue, 12 May 2020 17:30:36 +0200 Subject: compactify error mails --- it.class | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/it.class b/it.class index a4341ae..97a2e5d 100644 --- a/it.class +++ b/it.class @@ -256,10 +256,9 @@ static function error($p = array()) } $body = - ($p['omitdebuginfo'] >= 2 ? "" : ($url && !$toscreen? "{$p['title']}\n\nUrl: $url\n\n" : "") . - ($trace ? ($sendmail ? "" : " ") . "Trace: $trace\n\n" : "")) . - (!$sendmail || $p['omitdebuginfo'] >= 2 ? "" : "Host: " . getenv('HOSTNAME') . "\n\n") . - (!$sendmail || $p['omitdebuginfo'] >= 2 ? "" : "Time: " . date("Y-m-d H:i:s") . (($t = time() - $_SERVER['REQUEST_TIME']) ? " (invoked {$t}s before)" : "") . "\n\n") . # no it::date() due to time- debug param + ($p['omitdebuginfo'] >= 2 ? "" : ($url && !$toscreen? "{$p['title']}\nUrl: $url\n" : "") . + ($trace ? ($sendmail ? "" : " ") . "Trace: $trace\n" : "")) . + (!$sendmail || $p['omitdebuginfo'] >= 2 ? "" : "Host: " . getenv('HOSTNAME') . " at " . date("Y-m-d H:i:s") . (($t = time() - $_SERVER['REQUEST_TIME']) ? " (invoked {$t}s before)" : "") . "\n") . # no it::date() due to time- debug param self::$error_context . ($p['body'] ? ($p['omitdebuginfo'] ? "" : "Body:\n") . trim($p['body'])."\n\n" : ""); @@ -273,9 +272,8 @@ static function error($p = array()) if ($level >= $p['backtraceskip'] && $tracesize < 100000 && ($tracesize += strlen(print_r($stackframe, true))) < 100000) # save mem $stackframes[] = $stackframe; - $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 .= !$trace ? "" : "Overview: ssh " . getenv('HOSTNAME') . " 'cat /tmp/alertdata/alertlog | fgrep \"" . it::replace(["'" => " "], $trace) . "\"'\n\n"; + $body .= $p['id'] ? "Filter: timewindow=" . $p['graceperiod'] . "-" . ($p['graceperiod'] + $p['timewindow']) . " (previous err: " . it::date('', $errstamp) . ")\n" : ""; + $body .= $origp['blockmail'] ? "Block-resend: " . $origp['blockmail'] . " seconds\n" : ""; $body .= ($trace and $t = it::exec('grep -h {0} `ls /tmp/alertdata/alertlog-*|tail -3` /dev/null 2>/dev/null | grep ^2 | cut -d : -f 1-2 | sort | uniq -c | tail -10', $trace)) ? "Histogram: (last 10 affected minutes in 3 days)\n$t\n" : ""; $body .= $_GET ? "\$_GET: " . var_export($_GET, true) . "\n\n" : ""; $body .= $_POST ? "\$_POST: " . var_export($_POST, true) . "\n\n" : ""; -- cgit v1.2.3