mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-01 13:44:26 +02:00
log-forward: use warning-sign for severity warning and up
This commit is contained in:
parent
89f4c91ccf
commit
61c9b29ec3
1 changed files with 11 additions and 4 deletions
15
log-forward
15
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) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue