mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-07-25 21:34:30 +02:00
log-forward: implement reverse logic to include messages...
... even if a filter matches to exclude them. Let's have an example: :global LogForwardFilter "(debug|info)"; :global LogForwardInclude "account"; This will forward everything about topic *account* (login, logout, failed login, ...) - even with topic *info*.
This commit is contained in:
parent
d5f43aa26d
commit
de61c14c60
6 changed files with 20 additions and 7 deletions
|
@ -38,6 +38,9 @@ The configuration goes to `global-config-overlay`, these are the parameters:
|
|||
|
||||
* `LogForwardFilter`: define topics *not* to be forwarded
|
||||
* `LogForwardFilterMessage`: define message text *not* to be forwarded
|
||||
* `LogForwardInclude`: define topics to be forwarded (even if filter matches)
|
||||
* `LogForwardIncludeMessage`: define message text to be forwarded (even if
|
||||
filter matches)
|
||||
|
||||
Also notification settings are required for e-mail, matrix and/or telegram.
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
# Make sure all configuration properties are up to date and this
|
||||
# value is in sync with value in script 'global-functions'!
|
||||
:global GlobalConfigVersion 54;
|
||||
:global GlobalConfigVersion 55;
|
||||
|
||||
# This is used for DNS and backup file.
|
||||
:global Domain "example.com";
|
||||
|
@ -69,14 +69,20 @@
|
|||
:global BackupUploadUser "mikrotik";
|
||||
:global BackupUploadPass "v3ry-s3cr3t";
|
||||
|
||||
# This defines what log messages to filter by topic or message
|
||||
# This defines what log messages to filter or include by topic or message
|
||||
# text. Regular expressions are supported. Do *NOT* set an empty string,
|
||||
# that will filter everything!
|
||||
# that will filter or include everything!
|
||||
# These are filters, so excluding messages from forwarding.
|
||||
:global LogForwardFilter "(debug|info)";
|
||||
:global LogForwardFilterMessage [];
|
||||
#:global LogForwardFilterMessage "message text";
|
||||
#:global LogForwardFilterMessage "(message text|another text|...)";
|
||||
# ... and another setting with reverse logic. This includes messages even
|
||||
# if filtered above.
|
||||
:global LogForwardInclude [];
|
||||
:global LogForwardIncludeMessage [];
|
||||
#:global LogForwardInclude "account";
|
||||
#:global LogForwardIncludeMessage "message text";
|
||||
|
||||
# Specify an address to enable auto update to version assumed safe.
|
||||
# The configured channel (bugfix, current, release-candidate) is appended.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# Make sure all configuration properties are up to date and this
|
||||
# value is in sync with value in script 'global-functions'!
|
||||
# Comment or remove to disable news and change notifications.
|
||||
:global GlobalConfigVersion 54;
|
||||
:global GlobalConfigVersion 55;
|
||||
|
||||
# Copy configuration from global-config here and modify it.
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
52="Updated Let's Encrypt trust chain to use root certificate 'ISRG Root X1'. Do not re-import the old chain!";
|
||||
53="Added support to send notifications via Matrix.";
|
||||
54="Support for Telegram notifications moved to a module. It is installed automatically if required.";
|
||||
55="Added reverse logic in 'log-forward', so messages can be included even if filtered before.";
|
||||
};
|
||||
|
||||
# Migration steps to be applied on script updates
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# https://git.eworm.de/cgit/routeros-scripts/about/
|
||||
|
||||
# expected configuration version
|
||||
:global ExpectedConfigVersion 54;
|
||||
:global ExpectedConfigVersion 55;
|
||||
|
||||
# global variables not to be changed by user
|
||||
:global GlobalFunctionsReady false;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
:global Identity;
|
||||
:global LogForwardFilter;
|
||||
:global LogForwardFilterMessage;
|
||||
:global LogForwardInclude;
|
||||
:global LogForwardIncludeMessage;
|
||||
:global LogForwardLast;
|
||||
:global LogForwardRateLimit;
|
||||
:global NotificationsWithSymbols;
|
||||
|
@ -48,8 +50,9 @@ $WaitFullyConnected;
|
|||
:local LogForwardFilterLogForwarding ("^" . [ $EscapeForRegEx ("Error sending e-mail <" . \
|
||||
[ $QuotedPrintable ("[" . $Identity . "] " . [ $SymbolForNotification "warning-sign" ] . \
|
||||
"Log Forwarding") ] . ">:") ]);
|
||||
:foreach Message in=[ / log find where !(topics~$LogForwardFilter) !(message="") \
|
||||
!(message~$LogForwardFilterLogForwarding) !(message~$LogForwardFilterMessage) ] do={
|
||||
:foreach Message in=[ / log find where (!(message="") and !(message~$LogForwardFilterLogForwarding) and \
|
||||
!(topics~$LogForwardFilter) and !(message~$LogForwardFilterMessage)) or \
|
||||
topics~$LogForwardInclude or message~$LogForwardIncludeMessage ] do={
|
||||
:set MessageVal [ / log get $Message ];
|
||||
|
||||
:if ($LogForwardLast = ($MessageVal->".id")) do={
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue