diff options
author | Christian Hesse <mail@eworm.de> | 2021-03-04 18:42:57 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2021-03-04 18:44:34 +0100 |
commit | f762d395ebd7ffe914ea3e95571e18cd7e1bcb85 (patch) | |
tree | 8ec7c165f212e841c7cb6f06bd4a5b05ed9b10ca /log-forward | |
parent | d1741c99fe7dc803a9597e05b8b97a14843cb412 (diff) |
log-forward: skip multi-repeated messages
Diffstat (limited to 'log-forward')
-rw-r--r-- | log-forward | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/log-forward b/log-forward index def04e6..ecb55cc 100644 --- a/log-forward +++ b/log-forward @@ -37,18 +37,28 @@ $ScriptLock $0; $WaitFullyConnected; :local Count 0; +:local Duplicates false; :local Messages ""; :local MessageVal; +:local MessageDups [ :toarray "" ]; :foreach Message in=[ / log find where !(topics~$LogForwardFilter) !(message~$LogForwardFilterMessage) ] do={ :set MessageVal [ / log get $Message ]; :if ($LogForwardLast = ($MessageVal->".id")) do={ - :set Messages ""; :set Count 0; + :set Duplicates false; + :set Messages ""; + :set MessageDups [ :toarray "" ]; } else={ - :set Messages ($Messages . "\n" . $MessageVal->"time" . " " . \ - [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message"); + :local DupCount ($MessageDups->($MessageVal->"message")); + :if ($DupCount < 3) do={ + :set Messages ($Messages . "\n" . $MessageVal->"time" . " " . \ + [ :tostr ($MessageVal->"topics") ] . " " . $MessageVal->"message"); + } else={ + :set Duplicates true; + } + :set ($MessageDups->($MessageVal->"message")) ($DupCount + 1); :set Count ($Count + 1); } } @@ -57,7 +67,8 @@ $WaitFullyConnected; $SendNotification ([ $SymbolForNotification "warning-sign" ] . "Log Forwarding") \ ("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) \ "this message" ("these " . $Count . " messages") ] . " after " . \ - [ / system resource get uptime ] . " uptime.\n" . $Messages); + [ / system resource get uptime ] . " uptime." . [ $IfThenElse ($Duplicates = true) \ + (" Multi-repeated messages have been skipped.") ] . "\n" . $Messages); :set LogForwardRateLimit ($LogForwardRateLimit + 10); :set LogForwardLast ($MessageVal->".id"); |