From 21e39611bc0710e213c12efe72d85f0589e1dd7b Mon Sep 17 00:00:00 2001 From: amtoaer Date: Mon, 4 Sep 2023 23:07:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=86=85=E5=AD=98=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E5=9B=BE=E4=BD=BF=E7=94=A8=E7=99=BE=E5=88=86=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/dashboard.py | 2 +- app/utils/system.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/endpoints/dashboard.py b/app/api/endpoints/dashboard.py index 8b883ac9..f8782698 100644 --- a/app/api/endpoints/dashboard.py +++ b/app/api/endpoints/dashboard.py @@ -134,7 +134,7 @@ def cpu(_: schemas.TokenPayload = Depends(verify_token)) -> Any: return SystemUtils.cpu_usage() -@router.get("/memory", summary="获取当前内存使用率", response_model=int) +@router.get("/memory", summary="获取当前内存使用量和使用率", response_model=List[int]) def memory(_: schemas.TokenPayload = Depends(verify_token)) -> Any: """ 获取当前内存使用率 diff --git a/app/utils/system.py b/app/utils/system.py index 6bcc3086..a2092450 100644 --- a/app/utils/system.py +++ b/app/utils/system.py @@ -287,8 +287,8 @@ class SystemUtils: return psutil.cpu_percent() @staticmethod - def memory_usage(): + def memory_usage() -> List[int]: """ - 获取内存使用大小 + 获取内存使用量和使用率 """ - return psutil.virtual_memory().used + return [psutil.virtual_memory().used, int(psutil.virtual_memory().percent)]