aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-01-11 09:21:13 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-01-11 12:28:31 +0100
commit868557a24ae544f778531df71c4842fac72f308d (patch)
treeb5e1c776ef4dc764d89082489bc9707c990b8c84
parent34ed387343e2818a4321352c904b54fa9aea0424 (diff)
log-forward: generate filter in mod/notification-email
-rw-r--r--log-forward12
-rw-r--r--mod/notification-email16
2 files changed, 20 insertions, 8 deletions
diff --git a/log-forward b/log-forward
index df69008..642035c 100644
--- a/log-forward
+++ b/log-forward
@@ -19,11 +19,11 @@
:global LogForwardRateLimit;
:global NotificationsWithSymbols;
-:global EscapeForRegEx;
+:global EitherOr;
:global HexToNum;
:global IfThenElse;
+:global LogForwardFilterLogForwarding;
:global LogPrintExit2;
-:global QuotedPrintable;
:global ScriptLock;
:global SendNotification2;
:global SymbolByUnicodeName;
@@ -48,12 +48,8 @@ $ScriptLock $0;
:local MessageVal;
:local MessageDups ({});
-:local LogForwardFilterLogForwarding ("^Error sending e-mail <(" . \
- [ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
- [ $SymbolForNotification "memo" ] . "Log Forwarding") ] ] . "|" . \
- [ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \
- [ $SymbolForNotification "warning-sign" ] . "Log Forwarding") ] ] . ")>:");
-:foreach Message in=[ /log/find where (!(message="") and !(message~$LogForwardFilterLogForwarding) and \
+:foreach Message in=[ /log/find where (!(message="") and \
+ !(message~[ $EitherOr [ $LogForwardFilterLogForwarding ] ("\$^") ]) and \
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
:set MessageVal [ /log/get $Message ];
diff --git a/mod/notification-email b/mod/notification-email
index ea7d26a..8f624e9 100644
--- a/mod/notification-email
+++ b/mod/notification-email
@@ -4,6 +4,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/COPYING.md
:global FlushEmailQueue;
+:global LogForwardFilterLogForwarding;
:global NotificationFunctions;
:global SendEMail;
: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
:set ($NotificationFunctions->"email") do={
:local Notification $1;