From 697e32a30640c7bb8c132aaed44968081e6e3872 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 25 Sep 2020 22:21:59 +0200 Subject: log-forward: add filter on log message text --- doc/log-forward.md | 3 ++- global-config | 5 ++++- global-config-overlay | 2 +- global-config.changes | 1 + global-functions | 2 +- log-forward | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/log-forward.md b/doc/log-forward.md index bc7213a..afb695e 100644 --- a/doc/log-forward.md +++ b/doc/log-forward.md @@ -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. diff --git a/global-config b/global-config index 18754a8..446628f 100644 --- a/global-config +++ b/global-config @@ -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. diff --git a/global-config-overlay b/global-config-overlay index 48dbb9c..93c55ae 100644 --- a/global-config-overlay +++ b/global-config-overlay @@ -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. diff --git a/global-config.changes b/global-config.changes index e260565..605ceac 100644 --- a/global-config.changes +++ b/global-config.changes @@ -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'."; }; diff --git a/global-functions b/global-functions index adb9733..2d25b34 100644 --- a/global-functions +++ b/global-functions @@ -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; diff --git a/log-forward b/log-forward index 59a47c1..dc2ad05 100644 --- a/log-forward +++ b/log-forward @@ -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={ -- cgit v1.2.3-70-g09d2