diff options
author | Christian Hesse <mail@eworm.de> | 2022-05-20 08:48:06 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2022-06-02 11:14:36 +0200 |
commit | 61c9b29ec33ef249bb7b4371b0a213fa4ff4e2c7 (patch) | |
tree | f974859b8df00fa1965044ec7e5a3fb64fa24ec9 | |
parent | 89f4c91ccf35b65905dda8ce584d8a53faf6c957 (diff) |
log-forward: use warning-sign for severity warning and up
-rw-r--r-- | log-forward | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/log-forward b/log-forward index 3867519..55df2dc 100644 --- a/log-forward +++ b/log-forward @@ -19,6 +19,7 @@ :global LogForwardRateLimit; :global NotificationsWithSymbols; +:global CharacterReplace; :global EscapeForRegEx; :global HexToNum; :global IfThenElse; @@ -26,6 +27,7 @@ :global QuotedPrintable; :global ScriptLock; :global SendNotification2; +:global SymbolByUnicodeName; :global SymbolForNotification; $ScriptLock $0; @@ -43,12 +45,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 +59,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 +75,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) \ |