log-forward: add filter on log message text

This commit is contained in:
Christian Hesse 2020-09-25 22:21:59 +02:00
parent c3ea555233
commit 697e32a306
6 changed files with 11 additions and 5 deletions

View file

@ -31,9 +31,10 @@ Just install the script:
Configuration
-------------
The configuration goes to `global-config-overlay`, there is just one parameters:
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
Also notification settings are required for e-mail and telegram.

View file

@ -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 28;
:global GlobalConfigVersion 29;
# This is used for DNS and backup file.
:global Domain "example.com";
@ -48,6 +48,9 @@
# This defines a filter on log topics not to be forwarded.
:global LogForwardFilter "(debug|info|script)";
# ... and the same for log message text.
:global LogForwardFilterMessage "^\$";
#:global LogForwardFilterMessage "(^\$|message text|...)";
# Specify an address to enable auto update to version assumed safe.
# The configured channel (bugfix, current, release-candidate) is appended.

View file

@ -9,7 +9,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 change notifications.
:global GlobalConfigVersion 28;
:global GlobalConfigVersion 29;
# Copy configuration from global-config here and modify it.

View file

@ -32,4 +32,5 @@
26="Made check count threshold in 'netwatch-notify' configurable.";
27="Added queue for Telegram notifications to resend later on error.";
28="Made 'dhcp-to-dns' act on all bound leases, not just dynamic ones.";
29="Added filter on log message text for 'log-forward'.";
};

View file

@ -8,7 +8,7 @@
# https://git.eworm.de/cgit/routeros-scripts/about/
# expected configuration version
:global ExpectedConfigVersion 28;
:global ExpectedConfigVersion 29;
# global variables not to be changed by user
:global GlobalFunctionsReady false;

View file

@ -8,6 +8,7 @@
:global Identity;
:global LogForwardFilter;
:global LogForwardFilterMessage;
:global LogForwardLast;
:global LogPrintExit;
@ -29,7 +30,7 @@ $WaitFullyConnected;
:local Messages "";
:local MessageVal;
:foreach Message in=[ / log find where !(topics~$LogForwardFilter) ] do={
:foreach Message in=[ / log find where !(topics~$LogForwardFilter) !(message~$LogForwardFilterMessage) ] do={
:set MessageVal [ / log get $Message ];
:if ($LogForwardLast = ($MessageVal->".id")) do={