aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-05-20 08:48:06 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-05-20 09:09:13 +0200
commit5e9cb354f5968c14dea7e01988f2b2d2533bf26e (patch)
tree5956b559af9e17c1322285e0f4e8ed7fe8673bc7
parent89f4c91ccf35b65905dda8ce584d8a53faf6c957 (diff)
log-forward: use warning-sign for severity warning and upHEADnextmain
-rw-r--r--log-forward14
1 files changed, 10 insertions, 4 deletions
diff --git a/log-forward b/log-forward
index 3867519..813fd06 100644
--- a/log-forward
+++ b/log-forward
@@ -26,6 +26,7 @@
:global QuotedPrintable;
:global ScriptLock;
:global SendNotification2;
+:global SymbolByUnicodeName;
:global SymbolForNotification;
$ScriptLock $0;
@@ -43,12 +44,13 @@ $ScriptLock $0;
:local Duplicates false;
:local Last [ $IfThenElse ([ :len $LogForwardLast ] > 0) [ $HexToNum $LogForwardLast ] -1 ];
:local Messages "";
+:local Warning false;
:local MessageVal;
:local MessageDups [ :toarray "" ];
-:local LogForwardFilterLogForwarding ("^" . [ $EscapeForRegEx ("Error sending e-mail <" . \
- [ $QuotedPrintable ("[" . $Identity . "] " . [ $SymbolForNotification "memo" ] . \
- "Log Forwarding") ] . ">:") ]);
+:local LogForwardFilterLogForwarding ("^" . [ $CharacterReplace [ $EscapeForRegEx ("Error sending e-mail <" . \
+ [ $QuotedPrintable ("[" . $Identity . "] %SYMBOLREGEX%Log Forwarding") ] . ">:") ] "%SYMBOLREGEX%" \
+ ("((" . [ $SymbolByUnicodeName "memo" ] . "|" . [ $SymbolByUnicodeName "warning-sign" ] . ") )?") ]);
:foreach Message in=[ /log/find where (!(message="") and !(message~$LogForwardFilterLogForwarding) and \
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
@@ -56,6 +58,9 @@ $ScriptLock $0;
:if ($Last < [ $HexToNum ($MessageVal->".id") ]) do={
:local DupCount ($MessageDups->($MessageVal->"message"));
+ :if ($MessageVal->"topics" ~ "(emergency|alert|critical|error|warning)") do={
+ :set Warning true;
+ }
:if ($DupCount < 3) do={
:set Messages ($Messages . "\n" . [ $IfThenElse ($NotificationsWithSymbols = true) (" \E2\97\8F ") ] . \
$MessageVal->"time" . " " . [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message");
@@ -69,7 +74,8 @@ $ScriptLock $0;
:if ($Count > 0) do={
$SendNotification2 ({ origin=$0; \
- subject=([ $SymbolForNotification "memo" ] . "Log Forwarding"); \
+ subject=([ $SymbolForNotification [ $IfThenElse ($Warning = true) "warning-sign" "memo" ] ] . \
+ "Log Forwarding"); \
message=("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) \
"this message" ("these " . $Count . " messages") ] . " after " . \
[ /system/resource/get uptime ] . " uptime." . [ $IfThenElse ($Duplicates = true) \