diff --git a/backend/main.py b/backend/main.py index fbdc2ff..d7796e4 100644 --- a/backend/main.py +++ b/backend/main.py @@ -229,7 +229,8 @@ async def get_system_metrics(limit: int = 60) -> list[dict]: @app.get("/api/active-anomalies", summary="Currently anomalous processes") async def get_active_anomalies() -> list[dict]: - """Latest snapshot per PID — only rows where is_anomaly=1.""" + """Latest snapshot per PID — only rows where is_anomaly=1 and seen within last 30 s.""" + cutoff = (datetime.now(timezone.utc) - timedelta(seconds=30)).isoformat() async with aiosqlite.connect(DB_PATH) as db: db.row_factory = aiosqlite.Row async with db.execute(""" @@ -239,9 +240,10 @@ async def get_active_anomalies() -> list[dict]: SELECT pid, MAX(id) AS max_id FROM metrics GROUP BY pid ) latest ON m.id = latest.max_id WHERE m.is_anomaly = 1 + AND m.timestamp >= ? ORDER BY m.cpu_percent DESC LIMIT 20 - """) as cur: + """, (cutoff,)) as cur: return [dict(r) for r in await cur.fetchall()] diff --git a/docs/screenshots/alerts-page.png b/docs/screenshots/alerts-page.png new file mode 100644 index 0000000..6c4f3d9 Binary files /dev/null and b/docs/screenshots/alerts-page.png differ diff --git a/docs/screenshots/cpu-stress-detected-popup.png b/docs/screenshots/cpu-stress-detected-popup.png new file mode 100644 index 0000000..72ab62e Binary files /dev/null and b/docs/screenshots/cpu-stress-detected-popup.png differ diff --git a/docs/screenshots/cpu-stress-detected.png b/docs/screenshots/cpu-stress-detected.png new file mode 100644 index 0000000..f55d247 Binary files /dev/null and b/docs/screenshots/cpu-stress-detected.png differ diff --git a/docs/screenshots/main-page.png b/docs/screenshots/main-page.png new file mode 100644 index 0000000..6a591ae Binary files /dev/null and b/docs/screenshots/main-page.png differ diff --git a/docs/screenshots/memory-anomaly.png b/docs/screenshots/memory-anomaly.png new file mode 100644 index 0000000..18ea353 Binary files /dev/null and b/docs/screenshots/memory-anomaly.png differ diff --git a/docs/screenshots/process-page.png b/docs/screenshots/process-page.png new file mode 100644 index 0000000..9985f62 Binary files /dev/null and b/docs/screenshots/process-page.png differ