mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
log-forward: generate filter in mod/notification-email
This commit is contained in:
parent
34ed387343
commit
868557a24a
2 changed files with 20 additions and 8 deletions
12
log-forward
12
log-forward
|
@ -19,11 +19,11 @@
|
||||||
:global LogForwardRateLimit;
|
:global LogForwardRateLimit;
|
||||||
:global NotificationsWithSymbols;
|
:global NotificationsWithSymbols;
|
||||||
|
|
||||||
:global EscapeForRegEx;
|
:global EitherOr;
|
||||||
:global HexToNum;
|
:global HexToNum;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
|
:global LogForwardFilterLogForwarding;
|
||||||
:global LogPrintExit2;
|
:global LogPrintExit2;
|
||||||
:global QuotedPrintable;
|
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
:global SendNotification2;
|
:global SendNotification2;
|
||||||
:global SymbolByUnicodeName;
|
:global SymbolByUnicodeName;
|
||||||
|
@ -48,12 +48,8 @@ $ScriptLock $0;
|
||||||
:local MessageVal;
|
:local MessageVal;
|
||||||
:local MessageDups ({});
|
:local MessageDups ({});
|
||||||
|
|
||||||
:local LogForwardFilterLogForwarding ("^Error sending e-mail <(" . \
|
:foreach Message in=[ /log/find where (!(message="") and \
|
||||||
[ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
|
!(message~[ $EitherOr [ $LogForwardFilterLogForwarding ] ("\$^") ]) and \
|
||||||
[ $SymbolForNotification "memo" ] . "Log Forwarding") ] ] . "|" . \
|
|
||||||
[ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
|
|
||||||
[ $SymbolForNotification "warning-sign" ] . "Log Forwarding") ] ] . ")>:");
|
|
||||||
:foreach Message in=[ /log/find where (!(message="") and !(message~$LogForwardFilterLogForwarding) and \
|
|
||||||
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
|
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
|
||||||
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
|
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
|
||||||
:set MessageVal [ /log/get $Message ];
|
:set MessageVal [ /log/get $Message ];
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
|
||||||
|
|
||||||
:global FlushEmailQueue;
|
:global FlushEmailQueue;
|
||||||
|
:global LogForwardFilterLogForwarding;
|
||||||
:global NotificationFunctions;
|
:global NotificationFunctions;
|
||||||
:global SendEMail;
|
:global SendEMail;
|
||||||
:global SendEMail2;
|
:global SendEMail2;
|
||||||
|
@ -88,6 +89,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# generate filter for log-forward
|
||||||
|
:set LogForwardFilterLogForwarding do={
|
||||||
|
:global Identity;
|
||||||
|
|
||||||
|
:global EscapeForRegEx;
|
||||||
|
:global QuotedPrintable;
|
||||||
|
:global SymbolForNotification;
|
||||||
|
|
||||||
|
:return ("^Error sending e-mail <(" . \
|
||||||
|
[ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
|
||||||
|
[ $SymbolForNotification "memo" ] . "Log Forwarding") ] ] . "|" . \
|
||||||
|
[ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
|
||||||
|
[ $SymbolForNotification "warning-sign" ] . "Log Forwarding") ] ] . ")>:");
|
||||||
|
}
|
||||||
|
|
||||||
# send notification via e-mail - expects one array argument
|
# send notification via e-mail - expects one array argument
|
||||||
:set ($NotificationFunctions->"email") do={
|
:set ($NotificationFunctions->"email") do={
|
||||||
:local Notification $1;
|
:local Notification $1;
|
||||||
|
|
Loading…
Reference in a new issue