feat: add health check endpoint and related schemas with tests

This commit is contained in:
Jokob @NetAlertX
2026-02-17 23:01:49 +00:00
parent 9ac8f6fe34
commit 264cae3338
6 changed files with 451 additions and 1 deletions

View File

@@ -651,6 +651,34 @@ class NetworkInterfacesResponse(BaseResponse):
interfaces: Dict[str, Any] = Field(..., description="Details about network interfaces.")
# =============================================================================
# HEALTH CHECK SCHEMAS
# =============================================================================
class HealthCheckResponse(BaseResponse):
"""System health check with vitality metrics."""
model_config = ConfigDict(
extra="allow",
json_schema_extra={
"examples": [{
"success": True,
"db_size_mb": 125.45,
"mem_usage_pct": 65,
"load_1m": 2.15,
"storage_pct": 42,
"cpu_temp": 58
}]
}
)
db_size_mb: float = Field(..., description="Database size in MB (app.db + app.db-wal)")
mem_usage_pct: int = Field(..., ge=0, le=100, description="Memory usage percentage (0-100)")
load_1m: float = Field(..., description="1-minute load average")
storage_pct: int = Field(..., ge=0, le=100, description="Disk usage percentage of /data mount (0-100)")
cpu_temp: Optional[int] = Field(None, description="CPU temperature in Celsius (nullable if unavailable)")
# =============================================================================
# EVENTS SCHEMAS
# =============================================================================