修复CPU系统使用率、当前空闲率

This commit is contained in:
GitHubList
2024-08-28 00:03:15 +08:00
parent 556d32729a
commit 8f10146d39
2 changed files with 4 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ namespace Yi.Framework.Core.Helper
memoryMetrics.UsedRam = Math.Round(memoryMetrics.Used / 1024, 2) + "GB";
memoryMetrics.TotalRAM = Math.Round(memoryMetrics.Total / 1024, 2) + "GB";
memoryMetrics.RAMRate = Math.Ceiling(100 * memoryMetrics.Used / memoryMetrics.Total).ToString() + "%";
memoryMetrics.CPURate = Math.Ceiling(ParseToDouble(GetCPURate())) + "%";
memoryMetrics.CPURate = Math.Ceiling(ParseToDouble(GetCPURate()));
return memoryMetrics;
}
catch (Exception ex)
@@ -239,7 +239,7 @@ namespace Yi.Framework.Core.Helper
/// <summary>
/// CPU使用率%
/// </summary>
public string CPURate { get; set; }
public double CPURate { get; set; }
/// <summary>
/// 总内存 GB
/// </summary>

View File

@@ -23,11 +23,11 @@
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">系统使用率</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ Math.floor((server.cpu.used/server.cpu.total)*100)}}%</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ server.cpu.cpuRate}}%</div></td>
</tr>
<tr>
<td class="el-table__cell is-leaf"><div class="cell">当前空闲率</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ Math.floor((server.cpu.free/server.cpu.total)*100) }}%</div></td>
<td class="el-table__cell is-leaf"><div class="cell" v-if="server.cpu">{{ 100-server.cpu.cpuRate}}%</div></td>
</tr>
</tbody>
</table>