mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
- 修改alembic配置以使用异步数据库URI和更新Base类引用 - 新增数据库Schema优化脚本,统一字段长度,添加索引,规范外键策略 - 重构API路由管理,按模块类型分组并统一前缀 - 删除示例、监控及系统各子模块的模型定义,减少冗余代码 - 将mcp_server相关代码迁移到module_ai模块下,规范模块目录结构 - 迁移example控制器至module_application.application模块,并重命名相关服务和参数名 - 优化示例控制器中的依赖和响应结构,统一命名规范
81 lines
2.8 KiB
Python
81 lines
2.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
from typing import List
|
|
|
|
|
|
class CpuInfoSchema(BaseModel):
|
|
"""CPU信息模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
cpu_num: int = Field(description="CPU核心数")
|
|
used: float = Field(ge=0, le=100, description="CPU用户使用率(%)")
|
|
sys: float = Field(ge=0, le=100, description="CPU系统使用率(%)")
|
|
free: float = Field(ge=0, le=100, description="CPU空闲率(%)")
|
|
|
|
|
|
class MemoryInfoSchema(BaseModel):
|
|
"""内存信息模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
total: str = Field(description="内存总量")
|
|
used: str = Field(description="已用内存")
|
|
free: str = Field(description="剩余内存")
|
|
usage: float = Field(ge=0, le=100, description="使用率(%)")
|
|
|
|
|
|
class SysInfoSchema(BaseModel):
|
|
"""系统信息模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
computer_ip: str = Field(description="服务器IP")
|
|
computer_name: str = Field(description="服务器名称")
|
|
os_arch: str = Field(description="系统架构")
|
|
os_name: str = Field(description="操作系统")
|
|
user_dir: str = Field(description="项目路径")
|
|
|
|
|
|
class PyInfoSchema(BaseModel):
|
|
"""Python运行信息模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
name: str = Field(description="Python名称")
|
|
version: str = Field(description="Python版本")
|
|
start_time: str = Field(description="启动时间")
|
|
run_time: str = Field(description="运行时长")
|
|
home: str = Field(description="安装路径")
|
|
memory_used: str = Field(description="内存占用")
|
|
memory_usage: float = Field(ge=0, le=100, description="内存使用率(%)")
|
|
memory_total: str = Field(description="总内存")
|
|
memory_free: str = Field(description="剩余内存")
|
|
|
|
|
|
class DiskInfoSchema(BaseModel):
|
|
"""磁盘信息模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
dir_name: str = Field(description="磁盘路径")
|
|
sys_type_name: str = Field(description="文件系统类型")
|
|
type_name: str = Field(description="磁盘类型")
|
|
total: str = Field(description="总容量")
|
|
used: str = Field(description="已用容量")
|
|
free: str = Field(description="可用容量")
|
|
usage: float = Field(ge=0, le=100, description="使用率(%)")
|
|
|
|
|
|
class ServerMonitorSchema(BaseModel):
|
|
"""服务器监控信息模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
cpu: CpuInfoSchema = Field(description="CPU信息")
|
|
mem: MemoryInfoSchema = Field(description="内存信息")
|
|
py: PyInfoSchema = Field(description="Python运行信息")
|
|
sys: SysInfoSchema = Field(description="系统信息")
|
|
disks: List[DiskInfoSchema] = Field(default_factory=list, description="磁盘信息")
|