feat: 监控阈值设置新增CPU温度项
- 默认阈值: 80°C (范围 30-120°C) - 同时监控 CPU0 和 CPU1 (双路服务器) - 超温时弹窗警告 + 桌面通知
This commit is contained in:
@@ -26,6 +26,7 @@ APP_PORT = 16022
|
||||
# 监控配置
|
||||
DEFAULT_THRESHOLDS = {
|
||||
'cpu': 80,
|
||||
'cpu_temp': 80,
|
||||
'memory': 85,
|
||||
'disk': 90,
|
||||
'interval': 60
|
||||
|
||||
@@ -305,6 +305,16 @@
|
||||
<span class="text-gray-500 text-xs">%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="threshold-item">
|
||||
<div class="threshold-label">
|
||||
<i class="ri-temp-hot-line threshold-icon text-red-400"></i>
|
||||
<span class="text-gray-300 text-sm">CPU 温度</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<input type="number" id="thresholdCpuTemp" class="threshold-input" min="30" max="120" value="80" onchange="saveThresholds()">
|
||||
<span class="text-gray-500 text-xs">°C</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="threshold-item">
|
||||
<div class="threshold-label">
|
||||
<i class="ri-database-2-line threshold-icon text-green-400"></i>
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user