Files
2023-07-13 17:44:07 +08:00

24 lines
915 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fastapi import APIRouter
from starlette.concurrency import run_in_threadpool
from backend.app.common.jwt import DependsJwtAuth
from backend.app.common.response.response_schema import response_base
from backend.app.utils.server_info import server_info
router = APIRouter()
@router.get('/server', summary='server 监控', dependencies=[DependsJwtAuth])
async def get_server_info():
"""IO密集型任务使用线程池尽量减少性能损耗"""
data = {
'cpu': await run_in_threadpool(server_info.get_cpu_info),
'mem': await run_in_threadpool(server_info.get_mem_info),
'sys': await run_in_threadpool(server_info.get_sys_info),
'disk': await run_in_threadpool(server_info.get_disk_info),
'service': await run_in_threadpool(server_info.get_service_info),
}
return await response_base.success(data=data)