diff --git a/server_config.json b/server_config.json index b7285a3..a5b08f7 100644 --- a/server_config.json +++ b/server_config.json @@ -3,7 +3,7 @@ "port": 15002, "server_list":["76", "174", "233", "222"], "note_dict":{ - "174": "test note" + "76": "目前该服务器gpu的信息获取有问题,还不清楚是什么情况。大概三月份之后有空再修一下。" }, "api_name": "api" -} \ No newline at end of file +} diff --git a/web/css/style_1.css b/web/css/style_1.css index 4a37211..0b90a43 100644 --- a/web/css/style_1.css +++ b/web/css/style_1.css @@ -21,6 +21,16 @@ margin: 12px; } +.note-info { + border-style: solid; + border-width: 4px; + border-color: #a10000; + border-radius: 8px; + padding: 6px 10px; + margin-top: 4px; + margin-bottom: 6px; +} + .server-name { background-color: rgb(0, 0, 0); color: white; diff --git a/web/js/script.js b/web/js/script.js index a5e76d5..0a94370 100644 --- a/web/js/script.js +++ b/web/js/script.js @@ -113,6 +113,16 @@ function displayServerData(data){ serverName.textContent = serverTitle + " - Not update -"; } + // 添加公告 + if ('note' in serverData && serverData['note'] != ''){ + let noteInfo = document.createElement('div'); + noteInfo.className = 'note-info'; + + noteInfo.innerHTML = '
公告
' + serverData['note']; + + serverCard.appendChild(noteInfo); + } + // 网速 if ('network_list' in serverData){ let networkInfo = document.createElement('div'); @@ -214,13 +224,14 @@ function displayServerData(data){ let markLightOccupy = ' 占用'; let markOccupy = ' 占用'; let tmpMark = markFree; - if (gpu.used_memory < 1000 && gpu.utilization < 20){ - tmpMark = markFree; + let memory_used_ratio = gpu.used_memory / gpu.total_memory; + if (memory_used_ratio > 0.25 && gpu.utilization > 50){ + tmpMark = markOccupy; } - else if (gpu.util_mem < 50){ + else if (memory_used_ratio > 0.25 || gpu.utilization > 50){ tmpMark = markLightOccupy; }else{ - tmpMark = markOccupy; + tmpMark = markFree; } gpuInfo.innerHTML = '' + gpu.idx + ' - ' + gpu.name + tmpMark + '
' + '温度: ' + gpu.temperature + '°C
' @@ -276,5 +287,5 @@ function displayServerData(data){ // 页面加载时获取数据并定时刷新 document.addEventListener('DOMContentLoaded', function() { fetchData(); - setInterval(fetchData, 3500); // 每3.5秒刷新一次数据 + setInterval(fetchData, 4000); // 每4秒刷新一次数据 });