Add the staff stats dashboard
Backend: GET /api/stats/ (staff only) gathers psutil CPU/memory counters, nvidia-smi GPU stats, the cached disk numbers and the running/finished download + match jobs. Root logging now also writes a rotating file (backend/logs/j621.log) so the dashboard can tail it, and psutil joins the requirements. The storage payload computation is shared with the existing storage endpoint. Frontend: a /stats route + Stats nav entry for staff, polling every 2 s — per-core CPU bars, memory and swap, GPUs (utilization, VRAM, temperature), disk with the media/temp breakdown, active jobs with progress bars, recently finished jobs with summaries, and the log tail with level colours and an auto-scroll toggle. Section 4 of the roadmap is complete.
This commit is contained in:
@@ -203,6 +203,31 @@ REST_FRAMEWORK = {
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
LOGS_DIR = BASE_DIR / "logs"
|
||||
LOG_FILE = LOGS_DIR / "j621.log"
|
||||
try:
|
||||
LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
except OSError: # read-only checkout: keep console logging only
|
||||
pass
|
||||
|
||||
_log_handlers = {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "simple",
|
||||
},
|
||||
}
|
||||
_root_handlers = ["console"]
|
||||
if LOGS_DIR.exists():
|
||||
_log_handlers["file"] = {
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": str(LOG_FILE),
|
||||
"maxBytes": 5 * 1024 * 1024,
|
||||
"backupCount": 3,
|
||||
"encoding": "utf-8",
|
||||
"formatter": "simple",
|
||||
}
|
||||
_root_handlers.append("file")
|
||||
|
||||
LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
@@ -212,14 +237,9 @@ LOGGING = {
|
||||
"style": "{",
|
||||
},
|
||||
},
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "simple",
|
||||
},
|
||||
},
|
||||
"handlers": _log_handlers,
|
||||
"root": {
|
||||
"handlers": ["console"],
|
||||
"handlers": _root_handlers,
|
||||
"level": "INFO",
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user