Move port traffic to device-centric monitoring with a dedicated wall and collect logs.

Split the ops wall to its own route with fullscreen charts, persist collect errors as device events, and polish wall legend layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-01 15:45:20 +08:00
parent 5079343b2a
commit 214bc56774
24 changed files with 3309 additions and 1357 deletions

View file

@ -7,7 +7,7 @@ from datetime import datetime
from sqlalchemy.orm import Session
from .models import PortTrafficTask
from .models import PortTrafficDevice
_log = logging.getLogger("netx.port_traffic.recovery")
@ -15,17 +15,17 @@ _log = logging.getLogger("netx.port_traffic.recovery")
def recover_port_traffic_on_startup(db: Session) -> int:
"""Clear stuck collect_running flags so scheduler can resume."""
now = datetime.utcnow()
rows = db.query(PortTrafficTask).filter(PortTrafficTask.collect_running.is_(True)).all()
rows = db.query(PortTrafficDevice).filter(PortTrafficDevice.collect_running.is_(True)).all()
n = 0
for task in rows:
task.collect_running = False
if not task.last_collect_ended_at:
task.last_collect_ended_at = now
if not task.last_error:
task.last_error = "requeued_after_restart"
task.updated_at = now
for device in rows:
device.collect_running = False
if not device.last_collect_ended_at:
device.last_collect_ended_at = now
if not device.last_error:
device.last_error = "requeued_after_restart"
device.updated_at = now
n += 1
if n:
db.commit()
_log.info("port_traffic recovery cleared collect_running on %s task(s)", n)
_log.info("port_traffic recovery cleared collect_running on %s device(s)", n)
return n