mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
log-forward: skip multi-repeated messages
This commit is contained in:
parent
d1741c99fe
commit
f762d395eb
1 changed files with 15 additions and 4 deletions
19
log-forward
19
log-forward
|
@ -37,18 +37,28 @@ $ScriptLock $0;
|
||||||
$WaitFullyConnected;
|
$WaitFullyConnected;
|
||||||
|
|
||||||
:local Count 0;
|
:local Count 0;
|
||||||
|
:local Duplicates false;
|
||||||
:local Messages "";
|
:local Messages "";
|
||||||
:local MessageVal;
|
:local MessageVal;
|
||||||
|
:local MessageDups [ :toarray "" ];
|
||||||
|
|
||||||
:foreach Message in=[ / log find where !(topics~$LogForwardFilter) !(message~$LogForwardFilterMessage) ] do={
|
:foreach Message in=[ / log find where !(topics~$LogForwardFilter) !(message~$LogForwardFilterMessage) ] do={
|
||||||
:set MessageVal [ / log get $Message ];
|
:set MessageVal [ / log get $Message ];
|
||||||
|
|
||||||
:if ($LogForwardLast = ($MessageVal->".id")) do={
|
:if ($LogForwardLast = ($MessageVal->".id")) do={
|
||||||
:set Messages "";
|
|
||||||
:set Count 0;
|
:set Count 0;
|
||||||
|
:set Duplicates false;
|
||||||
|
:set Messages "";
|
||||||
|
:set MessageDups [ :toarray "" ];
|
||||||
} else={
|
} else={
|
||||||
:set Messages ($Messages . "\n" . $MessageVal->"time" . " " . \
|
:local DupCount ($MessageDups->($MessageVal->"message"));
|
||||||
[ :tostr ($MessageVal->"topics") ] . " " . $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);
|
:set Count ($Count + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +67,8 @@ $WaitFullyConnected;
|
||||||
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "Log Forwarding") \
|
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "Log Forwarding") \
|
||||||
("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) \
|
("The log on " . $Identity . " contains " . [ $IfThenElse ($Count = 1) \
|
||||||
"this message" ("these " . $Count . " messages") ] . " after " . \
|
"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 LogForwardRateLimit ($LogForwardRateLimit + 10);
|
||||||
:set LogForwardLast ($MessageVal->".id");
|
:set LogForwardLast ($MessageVal->".id");
|
||||||
|
|
Loading…
Reference in a new issue