mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-11-04 02:56:54 +09:00
Introduce serverkit-gpu extension: backend plugin with GPU API and service (nvidia-smi based) providing per-GPU metrics and best-effort container resolution for GPU processes. Files added: backend/app/plugins/serverkit-gpu/{__init__.py,gpu.py,gpu_service.py,plugin.json}. Also update several frontend plugin.json files (including serverkit-gpu) to match manifest formatting (trailing newline adjustments). The GPU service degrades gracefully when nvidia-smi or Docker info is unavailable.
21 lines
722 B
Python
21 lines
722 B
Python
"""GPU Monitor API endpoints (serverkit-gpu extension).
|
|
|
|
Mounted under ``/api/v1/gpu`` via the manifest's ``entry_point`` + ``url_prefix``
|
|
(the same prefix the core route used, so the frontend is unchanged — decision D9).
|
|
Thin routing layer over :class:`GpuService`; read-only metrics, JWT-protected.
|
|
"""
|
|
from flask import Blueprint, jsonify
|
|
from flask_jwt_extended import jwt_required
|
|
|
|
from .gpu_service import GpuService
|
|
|
|
gpu_bp = Blueprint('gpu', __name__)
|
|
|
|
|
|
@gpu_bp.route('/', methods=['GET'])
|
|
@jwt_required()
|
|
def gpu_info():
|
|
"""Per-GPU stats (utilization, VRAM, temperature, power, fan, driver) plus
|
|
the GPU compute processes, with best-effort container resolution."""
|
|
return jsonify(GpuService.info())
|