From b27c5c6bdf0a369e2974f9d8e4ca65fb610ca9aa Mon Sep 17 00:00:00 2001 From: liuwei Date: Wed, 4 Jun 2025 09:06:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96IO=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/blueprints/system.py | 3 ++- admin/dashboard/templates/index.html | 1 + main.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/dashboard/blueprints/system.py b/admin/dashboard/blueprints/system.py index ab5ff76..1a6373c 100644 --- a/admin/dashboard/blueprints/system.py +++ b/admin/dashboard/blueprints/system.py @@ -41,7 +41,8 @@ def api_system_info(): "memory_usage": psutil.virtual_memory().percent, "disk_usage": psutil.disk_usage('/').percent, "uptime": time.time() - APP_START_TIME, # 使用应用启动时间计算运行时长 - "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + "open_files": psutil.Process(os.getpid()).open_files() } return jsonify({"success": True, "data": system_info}) diff --git a/admin/dashboard/templates/index.html b/admin/dashboard/templates/index.html index bc8f5fa..33786b3 100644 --- a/admin/dashboard/templates/index.html +++ b/admin/dashboard/templates/index.html @@ -177,6 +177,7 @@ Python版本: {% raw %}{{ systemInfo.python_version }}{% endraw %} | 运行时间: {% raw %}{{ formattedUptime }}{% endraw %} | 最后更新: {% raw %}{{ systemInfo.timestamp }}{% endraw %} + 打开文件数: {% raw %}{{ systemInfo.open_files }}{% endraw %} diff --git a/main.py b/main.py index c9e580d..6165d33 100644 --- a/main.py +++ b/main.py @@ -137,5 +137,10 @@ def jobs(robot: Robot): logger.info("图片缓存更新完成") + @async_job.every_minutes(1) + async def check_open_files(): + os.open + + if __name__ == "__main__": main()