mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 21:25:24 +03:00
Update stats every 10 seconds, keeping the last 10 minutes
This commit is contained in:
parent
8295a0d11a
commit
bf8d4adfc5
@ -1,5 +1,6 @@
|
||||
"""Emit stats to listeners."""
|
||||
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
@ -52,13 +53,20 @@ class StatsEmitter(threading.Thread):
|
||||
|
||||
def run(self) -> None:
|
||||
time.sleep(10)
|
||||
while not self.stop_event.wait(self.config.mqtt.stats_interval):
|
||||
for counter in itertools.cycle(range(self.config.record.expire_interval)):
|
||||
if self.stop_event.wait(5):
|
||||
break
|
||||
|
||||
logger.debug("Starting stats collection")
|
||||
stats = stats_snapshot(
|
||||
self.config, self.stats_tracking, self.hwaccel_errors
|
||||
)
|
||||
self.stats_history.append(stats)
|
||||
self.stats_history = self.stats_history[-MAX_STATS_POINTS:]
|
||||
self.requestor.send_data("stats", json.dumps(stats))
|
||||
|
||||
if counter == 0:
|
||||
self.requestor.send_data("stats", json.dumps(stats))
|
||||
|
||||
logger.debug("Finished stats collection")
|
||||
|
||||
logger.info("Exiting stats emitter...")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user