From ecbba836d997a9be17d2476f3614633c3a361a76 Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Mon, 1 Jun 2026 17:13:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=9B=91=E6=8E=A7=E9=98=88=E5=80=BC?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=96=B0=E5=A2=9ECPU=E6=B8=A9=E5=BA=A6?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 默认阈值: 80°C (范围 30-120°C) - 同时监控 CPU0 和 CPU1 (双路服务器) - 超温时弹窗警告 + 桌面通知 --- config.py | 1 + templates_full.txt | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 19c82ec..4b9a4b1 100644 --- a/config.py +++ b/config.py @@ -26,6 +26,7 @@ APP_PORT = 16022 # 监控配置 DEFAULT_THRESHOLDS = { 'cpu': 80, + 'cpu_temp': 80, 'memory': 85, 'disk': 90, 'interval': 60 diff --git a/templates_full.txt b/templates_full.txt index 839721b..262ea05 100644 --- a/templates_full.txt +++ b/templates_full.txt @@ -305,6 +305,16 @@ % +
+
+ + CPU 温度 +
+
+ + °C +
+
@@ -756,7 +766,7 @@ let realtimeTimer = null; let realtimeInterval = 2; // 秒 let lastAlertTime = 0; // 上次警告时间 - let thresholds = { cpu: 80, memory: 85, disk: 90, interval: 60 }; + let thresholds = { cpu: 80, cpu_temp: 80, memory: 85, disk: 90, interval: 60 }; let desktopNotifyEnabled = false; function switchTab(tab) { @@ -799,6 +809,7 @@ if (config.thresholds) { thresholds = config.thresholds; document.getElementById('thresholdCpu').value = thresholds.cpu || 80; + document.getElementById('thresholdCpuTemp').value = thresholds.cpu_temp || 80; document.getElementById('thresholdMemory').value = thresholds.memory || 85; document.getElementById('thresholdDisk').value = thresholds.disk || 90; document.getElementById('thresholdInterval').value = thresholds.interval || 60; @@ -811,6 +822,7 @@ // 保存阈值设置 async function saveThresholds() { thresholds.cpu = parseInt(document.getElementById('thresholdCpu').value) || 80; + thresholds.cpu_temp = parseInt(document.getElementById('thresholdCpuTemp').value) || 80; thresholds.memory = parseInt(document.getElementById('thresholdMemory').value) || 85; thresholds.disk = parseInt(document.getElementById('thresholdDisk').value) || 90; thresholds.interval = parseInt(document.getElementById('thresholdInterval').value) || 60; @@ -935,6 +947,12 @@ if (data.disk.percent >= thresholds.disk) { warnings.push(`磁盘使用率 ${data.disk.percent.toFixed(1)}% 超过阈值 ${thresholds.disk}%`); } + if (data.cpu.temp_package_0 !== null && data.cpu.temp_package_0 >= thresholds.cpu_temp) { + warnings.push(`CPU0 温度 ${data.cpu.temp_package_0.toFixed(1)}°C 超过阈值 ${thresholds.cpu_temp}°C`); + } + if (data.cpu.temp_package_1 !== null && data.cpu.temp_package_1 >= thresholds.cpu_temp) { + warnings.push(`CPU1 温度 ${data.cpu.temp_package_1.toFixed(1)}°C 超过阈值 ${thresholds.cpu_temp}°C`); + } if (warnings.length > 0) { lastAlertTime = now;