mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
log-forward: add rate limit to prevent flooding
This commit is contained in:
parent
42289b6239
commit
744542e925
1 changed files with 15 additions and 0 deletions
15
log-forward
15
log-forward
|
@ -10,6 +10,7 @@
|
|||
:global LogForwardFilter;
|
||||
:global LogForwardFilterMessage;
|
||||
:global LogForwardLast;
|
||||
:global LogForwardRateLimit;
|
||||
|
||||
:global LogPrintExit;
|
||||
:global MailServerIsUp;
|
||||
|
@ -20,6 +21,15 @@
|
|||
|
||||
$ScriptLock "log-forward";
|
||||
|
||||
:if ([ :typeof $LogForwardRateLimit ] = "nothing") do={
|
||||
:set LogForwardRateLimit 0;
|
||||
}
|
||||
|
||||
:if ($LogForwardRateLimit > 30) do={
|
||||
:set LogForwardRateLimit ($LogForwardRateLimit - 1);
|
||||
$LogPrintExit info ("Rate limit in action, not forwarding logs!") true;
|
||||
}
|
||||
|
||||
$WaitFullyConnected;
|
||||
|
||||
:if ([ $MailServerIsUp ] = false) do={
|
||||
|
@ -48,5 +58,10 @@ $WaitFullyConnected;
|
|||
("The log on " . $Identity . " contains these " . $Count . " messages after " . \
|
||||
[ / system resource get uptime ] . " uptime.\n" . $Messages);
|
||||
|
||||
:set LogForwardRateLimit ($LogForwardRateLimit + 10);
|
||||
:set LogForwardLast ($MessageVal->".id");
|
||||
} else={
|
||||
:if ($LogForwardRateLimit > 0) do={
|
||||
:set LogForwardRateLimit ($LogForwardRateLimit - 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue