|
|
@ -1,6 +1,6 @@ |
|
|
|
// 请求服务器获取数据
|
|
|
|
function fetchData() { |
|
|
|
fetch('http://127.0.0.1:15002/api/get_data') |
|
|
|
fetch('http://10.1.16.174:15002/api/get_data') |
|
|
|
// 获取服务器和显卡数据
|
|
|
|
.then(response => response.json()) // 解析 JSON 响应
|
|
|
|
.then(data => { |
|
|
@ -101,18 +101,20 @@ function displayServerData(data){ |
|
|
|
let networkInfo = document.createElement('div'); |
|
|
|
networkInfo.className = 'network-info'; |
|
|
|
|
|
|
|
// todo 暂时采用所有网卡均值的方法
|
|
|
|
// todo 暂时采用所有网卡总和的方法
|
|
|
|
let inSum = 0; |
|
|
|
let outSum = 0; |
|
|
|
let tmpTitle = ""; |
|
|
|
serverData.network_list.forEach(function(network){ |
|
|
|
inSum += network['in']; |
|
|
|
outSum += network['out']; |
|
|
|
tmpTitle += network['name'] + " in: " + parse_data_unit(network['in']) + "/s out: " + parse_data_unit(network['out']) + "/s\n"; |
|
|
|
}); |
|
|
|
|
|
|
|
let inStr = parse_data_unit(inSum / serverData.network_list.length); |
|
|
|
let outStr = parse_data_unit(outSum / serverData.network_list.length); |
|
|
|
let inStr = parse_data_unit(inSum); |
|
|
|
let outStr = parse_data_unit(outSum); |
|
|
|
|
|
|
|
networkInfo.innerHTML += "<strong> 网络 : </strong> in:" + inStr + "/s out:" + outStr + "/s</span><br>"; |
|
|
|
networkInfo.innerHTML += "<strong> 网络 : </strong> <span title=\"" + tmpTitle + "\">in:" + inStr + "/s out:" + outStr + "/s</span><br>"; |
|
|
|
|
|
|
|
serverCard.appendChild(networkInfo); |
|
|
|
// 分割线
|
|
|
@ -258,4 +260,4 @@ function displayServerData(data){ |
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
fetchData(); |
|
|
|
setInterval(fetchData, 3500); // 每3.5秒刷新一次数据
|
|
|
|
}); |
|
|
|
}); |
|
|
|