mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
firewall: throttle live logging (https://github.com/opnsense/core/issues/7975)
This commit is contained in:
parent
a05e1c32fe
commit
2e50dc12de
@ -178,8 +178,10 @@ if __name__ == '__main__':
|
||||
)
|
||||
|
||||
last_t = time.time()
|
||||
throttle = 100
|
||||
try:
|
||||
while True:
|
||||
start_t = time.time()
|
||||
ready, _, _ = select.select([f.stdout], [], [], 1)
|
||||
if not ready:
|
||||
# timeout, send keepalive
|
||||
@ -197,6 +199,10 @@ if __name__ == '__main__':
|
||||
print(f"event: message\ndata: {ujson.dumps(rule)}\n\n", flush=True)
|
||||
else:
|
||||
break
|
||||
|
||||
elapsed = round((time.time() - start_t) * 1000)
|
||||
ttw = max(0, throttle - elapsed)
|
||||
time.sleep(ttw / 1000)
|
||||
except KeyboardInterrupt:
|
||||
f.kill()
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user